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);
}
}
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);
}
}
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());
}
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();
}
};
}
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();
}
};
}
Aggregations