Search in sources :

Example 46 with Cluster

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

the class NotificationSinkBundleSourceHintProviderTest method getHintsOnCluster.

@Test
public void getHintsOnCluster() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    cluster.setName("cluster1");
    Service service = new Service();
    service.setId(1L);
    service.setName(Constants.Email.SERVICE_NAME);
    Map<String, String> confMap = new HashMap<>();
    confMap.put(Constants.Email.PROPERTY_KEY_HOST, "svr1");
    confMap.put(Constants.Email.PROPERTY_KEY_PORT, "1111");
    confMap.put(Constants.Email.PROPERTY_KEY_SSL, "true");
    confMap.put(Constants.Email.PROPERTY_KEY_STARTTLS, "true");
    confMap.put(Constants.Email.PROPERTY_KEY_PROTOCOL, "smtp");
    confMap.put(Constants.Email.PROPERTY_KEY_AUTH, "true");
    ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
    serviceConfiguration.setId(1L);
    serviceConfiguration.setName(Constants.Email.CONF_TYPE_PROPERTIES);
    serviceConfiguration.setConfiguration(objectMapper.writeValueAsString(confMap));
    new Expectations() {

        {
            environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
            result = service;
            environmentService.getServiceConfigurationByName(service.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
            result = serviceConfiguration;
        }
    };
    provider.init(environmentService);
    Map<String, Object> hints = provider.getHintsOnCluster(cluster, null, null);
    Assert.assertNotNull(hints);
    Assert.assertEquals("svr1", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_HOST));
    Assert.assertEquals("1111", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_PORT));
    Assert.assertEquals("true", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_SSL));
    Assert.assertEquals("true", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_STARTTLS));
    Assert.assertEquals("smtp", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_PROTOCOL));
    Assert.assertEquals("true", hints.get(NotificationSinkBundleHintProvider.FIELD_NAME_AUTH));
}
Also used : Expectations(mockit.Expectations) ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) HashMap(java.util.HashMap) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 47 with Cluster

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

the class AbstractServiceRegistrarTest method getTestCluster.

protected Cluster getTestCluster(Long clusterId) {
    Cluster cluster = new Cluster();
    cluster.setId(clusterId);
    cluster.setName("cluster" + clusterId);
    return cluster;
}
Also used : Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster)

Example 48 with Cluster

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

the class DruidServiceRegistrarTest method testRegister_zookeeper_connection_notPresent.

@Test
public void testRegister_zookeeper_connection_notPresent() throws Exception {
    Cluster cluster = getTestCluster(1L);
    DruidServiceRegistrar registerer = initializeServiceRegistrar();
    try {
        Config config = new Config();
        config.put(DruidServiceRegistrar.PARAM_INDEXING_SERVICE_NAME, "druid/overlord");
        config.put(DruidServiceRegistrar.PARAM_DISCOVERY_CURATOR_PATH, "/prod/discovery");
        registerer.register(cluster, config, Collections.emptyList());
        fail("Should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // OK
        Service druidService = environmentService.getServiceByName(cluster.getId(), Constants.Druid.SERVICE_NAME);
        assertNull(druidService);
    }
}
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 49 with Cluster

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

the class EmailServiceRegistrarTest method testRegister.

@Test
public void testRegister() throws Exception {
    Cluster cluster = getTestCluster(1L);
    EmailServiceRegistrar registrar = initializeServiceRegistrar();
    Config config = new Config();
    config.setAny("host", "host");
    config.setAny("port", 1111);
    config.setAny("ssl", true);
    config.setAny("starttls", true);
    config.setAny("protocol", "smtp");
    config.setAny("auth", true);
    registrar.register(cluster, config, Collections.emptyList());
    Service emailService = environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
    assertNotNull(emailService);
    ServiceConfiguration propertiesConf = environmentService.getServiceConfigurationByName(emailService.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
    assertNotNull(propertiesConf);
}
Also used : ServiceConfiguration(com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration) 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)

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