Search in sources :

Example 41 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class StormServiceRegistrarTest method testRegister_component_nimbus_notPresent.

@Test
public void testRegister_component_nimbus_notPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    StormServiceRegistrar registrar = initializeServiceRegistrar();
    try {
        Config config = new Config();
        // no nimbus params
        config.put(StormServiceRegistrar.PARAM_UI_HOST, "storm-1");
        config.put(StormServiceRegistrar.PARAM_UI_PORT, (Object) 8080);
        registrar.register(cluster, config, Collections.emptyList());
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service stormService = environmentService.getServiceByName(cluster.getId(), Constants.Storm.SERVICE_NAME);
        assertNull(stormService);
    }
}
Also used : Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Example 42 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class ZookeeperServiceRegistrarTest method testRegisterZookeeperServerPropertyNotPresent.

@Test
public void testRegisterZookeeperServerPropertyNotPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    ZookeeperServiceRegistrar registrar = initializeServiceRegistrar();
    try {
        registrar.register(cluster, new Config(), Collections.emptyList());
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service zkService = environmentService.getServiceByName(cluster.getId(), Constants.Zookeeper.SERVICE_NAME);
        assertNull(zkService);
    }
}
Also used : Config(com.hortonworks.streamline.common.Config) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Test(org.junit.Test)

Example 43 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class AbstractBundleHintProviderTest method testProvide.

@Test
public void testProvide() throws Exception {
    Cluster cluster1 = createDummyCluster(1L, "cluster1");
    Cluster cluster2 = createDummyCluster(2L, "cluster2");
    Cluster cluster3 = createDummyCluster(3L, "cluster3");
    List<NamespaceServiceClusterMap> testServiceClusterMappings = createDummyServiceClusterMappings(Lists.newArrayList(cluster1, cluster2, cluster3));
    new Expectations() {

        {
            environmentService.getCluster(1L);
            result = cluster1;
            environmentService.getCluster(2L);
            result = cluster2;
            environmentService.getCluster(3L);
            result = cluster3;
            environmentService.listServiceClusterMapping(TEST_NAMESPACE_ID, TEST_SERVICE_NAME);
            result = testServiceClusterMappings;
        }
    };
    Namespace namespace = new Namespace();
    namespace.setId(TEST_NAMESPACE_ID);
    Map<Long, ComponentBundleHintProvider.BundleHintsResponse> hints = provider.provide(namespace, null, null);
    Assert.assertEquals(3, hints.size());
    Assert.assertEquals(cluster1, hints.get(cluster1.getId()).getCluster());
    Assert.assertEquals(TEST_HINTS, hints.get(cluster1.getId()).getHints());
    Assert.assertEquals(cluster2, hints.get(cluster2.getId()).getCluster());
    Assert.assertEquals(TEST_HINTS, hints.get(cluster2.getId()).getHints());
    Assert.assertEquals(cluster3, hints.get(cluster3.getId()).getCluster());
    Assert.assertEquals(TEST_HINTS, hints.get(cluster3.getId()).getHints());
}
Also used : Expectations(mockit.Expectations) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) Test(org.junit.Test)

Example 44 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class AbstractKafkaBundleHintProviderTest method getHintsOnClusterWithZkServiceNotAvailable.

protected void getHintsOnClusterWithZkServiceNotAvailable() throws Exception {
    final List<String> topics = Lists.newArrayList("test1", "test2", "test3");
    new Expectations() {

        {
            kafkaMetadataService.getTopicsFromZk();
            result = new KafkaTopics(topics, security);
            zookeeperMetadataService.getZookeeperServers();
            result = new ServiceNotFoundException(1L, ServiceConfigurations.ZOOKEEPER.name());
        }
    };
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    cluster.setName("cluster1");
    Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
    Assert.assertNotNull(hints);
    Assert.assertEquals(4, hints.size());
    Assert.assertEquals(topics, hints.get(KafkaBundleHintProvider.FIELD_NAME_TOPIC));
    new Verifications() {

        {
            kafkaMetadataService.getTopicsFromZk();
            zookeeperMetadataService.getZookeeperServers();
        }
    };
}
Also used : Expectations(mockit.Expectations) KafkaTopics(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics) ServiceNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ServiceNotFoundException) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Verifications(mockit.Verifications)

Example 45 with Cluster

use of com.hortonworks.streamline.streams.cluster.catalog.Cluster in project streamline by hortonworks.

the class AbstractKafkaBundleHintProviderTest method getHintsOnCluster.

protected void getHintsOnCluster() throws Exception {
    final List<String> topics = Lists.newArrayList("test1", "test2", "test3");
    final List<HostPort> zkHosts = Lists.newArrayList(new HostPort("svr1", 2181), new HostPort("svr2", 2181), new HostPort("svr3", 2181));
    final Map<KafkaBrokerListeners.Protocol, List<String>> protocolToHostsWithPort = getProtocolToHostsWithPort();
    new Expectations() {

        {
            kafkaMetadataService.getTopicsFromZk();
            result = new KafkaTopics(topics, security);
            zookeeperMetadataService.getZookeeperServers();
            result = zkHosts;
            kafkaMetadataService.getKafkaBrokerListeners().getProtocolToHostsWithPort();
            result = protocolToHostsWithPort;
        }
    };
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    cluster.setName("cluster1");
    Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
    Assert.assertNotNull(hints);
    Assert.assertEquals(4, hints.size());
    Assert.assertEquals(topics, hints.get(KafkaBundleHintProvider.FIELD_NAME_TOPIC));
    Assert.assertEquals(AbstractKafkaBundleHintProvider.mapValuesJoiner(protocolToHostsWithPort, ","), hints.get(KafkaBundleHintProvider.FIELD_NAME_BOOTSTRAP_SERVERS));
    new Verifications() {

        {
            kafkaMetadataService.getTopicsFromZk();
            zookeeperMetadataService.getZookeeperServers();
        }
    };
}
Also used : Expectations(mockit.Expectations) HostPort(com.hortonworks.streamline.streams.cluster.service.metadata.common.HostPort) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Verifications(mockit.Verifications) KafkaTopics(com.hortonworks.streamline.streams.cluster.service.metadata.json.KafkaTopics) List(java.util.List)

Aggregations

Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)49 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)31 Test (org.junit.Test)30 Config (com.hortonworks.streamline.common.Config)25 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)15 ManualServiceRegistrar (com.hortonworks.streamline.streams.cluster.register.ManualServiceRegistrar)9 InputStream (java.io.InputStream)9 Timed (com.codahale.metrics.annotation.Timed)8 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)8 Path (javax.ws.rs.Path)8 Expectations (mockit.Expectations)8 NamespaceServiceClusterMap (com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)7 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)6 HashMap (java.util.HashMap)5 ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Map (java.util.Map)4 POST (javax.ws.rs.POST)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3