Search in sources :

Example 11 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetComponentsByHostGroupWhenComponentsIsEmpty.

@Test
public void testGetComponentsByHostGroupWhenComponentsIsEmpty() throws IOException {
    init();
    String hostGroupName = "hostGroup";
    HostgroupView hostGroup = new HostgroupView(hostGroupName, 1, InstanceGroupType.CORE, 1);
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    List<HostgroupView> hostGroups = singletonList(hostGroup);
    when(blueprintTextProcessor.getComponentsByHostGroup()).thenReturn(emptyMap());
    Map<String, Map<String, String>> actual = underTest.getComponentsByHostGroup(blueprintTextProcessor, hostGroups);
    Assert.assertEquals(emptyMap(), actual);
    verify(configUtils, times(0)).isConfigUpdateNeeded(hostGroup);
}
Also used : HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 12 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetComponentsByHostGroupWhenConfigUpdateIsNotNeed.

@Test
public void testGetComponentsByHostGroupWhenConfigUpdateIsNotNeed() throws IOException {
    init();
    String hostGroupName = "hostGroup";
    HostgroupView hostGroup = new HostgroupView(hostGroupName, 1, InstanceGroupType.CORE, 1);
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Set<String>> componentsByHostgroup = new HashMap<>();
    componentsByHostgroup.put(hostGroupName, Sets.newHashSet("serviceName"));
    ServiceConfig serviceConfig = new ServiceConfig("serviceName", emptyList(), emptyMap(), emptyMap());
    List<HostgroupView> hostGroups = singletonList(hostGroup);
    Set<String> components = singleton("component");
    Map<String, Map<String, String>> properties = new HashMap<>();
    properties.put("key", singletonMap("propKey", "propValue"));
    when(blueprintTextProcessor.getComponentsByHostGroup()).thenReturn(componentsByHostgroup);
    when(hadoopConfigurationUtils.findHostGroupForNode(hostGroups, hostGroupName)).thenReturn(hostGroup);
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(false);
    when(configUtils.getServiceConfig(eq("serviceName"), anyMapOf(String.class, ServiceConfig.class))).thenReturn(serviceConfig);
    when(blueprintTextProcessor.getComponentsInHostGroup(hostGroup.getName())).thenReturn(components);
    when(configUtils.getProperties(eq(serviceConfig), eq(true), eq(-1), eq(components))).thenReturn(properties);
    Map<String, Map<String, String>> actual = underTest.getComponentsByHostGroup(blueprintTextProcessor, hostGroups);
    Map<String, Map<String, String>> expected = properties;
    Assert.assertEquals(expected, actual);
}
Also used : Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) HashMap(java.util.HashMap) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 13 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetComponentsByHostGroup.

@Test
public void testGetComponentsByHostGroup() throws IOException {
    init();
    String hostGroupName = "hostGroup";
    HostgroupView hostGroup = new HostgroupView(hostGroupName, 1, InstanceGroupType.CORE, 1);
    String blueprintText = "blueprintText";
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Set<String>> componentsByHostgroup = new HashMap<>();
    componentsByHostgroup.put(hostGroupName, Sets.newHashSet("serviceName1", "serviceName2"));
    ServiceConfig serviceConfig1 = new ServiceConfig("serviceName1", emptyList(), emptyMap(), emptyMap());
    ServiceConfig serviceConfig2 = new ServiceConfig("serviceName2", emptyList(), emptyMap(), emptyMap());
    List<HostgroupView> hostGroups = singletonList(hostGroup);
    Set<String> components = singleton("component");
    Map<String, Map<String, String>> properties1 = new HashMap<>();
    properties1.put("key1", singletonMap("propKey1", "propValue1"));
    Map<String, Map<String, String>> properties2 = new HashMap<>();
    properties2.put("key2", singletonMap("propKey2", "propValue2"));
    when(blueprintTextProcessor.getComponentsByHostGroup()).thenReturn(componentsByHostgroup);
    when(hadoopConfigurationUtils.findHostGroupForNode(hostGroups, hostGroupName)).thenReturn(hostGroup);
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(true);
    when(configUtils.getServiceConfig(eq("serviceName1"), anyMapOf(String.class, ServiceConfig.class))).thenReturn(serviceConfig1);
    when(configUtils.getServiceConfig(eq("serviceName2"), anyMapOf(String.class, ServiceConfig.class))).thenReturn(serviceConfig2);
    when(blueprintTextProcessor.getComponentsInHostGroup(hostGroup.getName())).thenReturn(components);
    when(configUtils.getProperties(eq(serviceConfig1), eq(true), eq(0), eq(components))).thenReturn(properties1);
    when(configUtils.getProperties(eq(serviceConfig2), eq(true), eq(0), eq(components))).thenReturn(properties2);
    Map<String, Map<String, String>> actual = underTest.getComponentsByHostGroup(blueprintTextProcessor, hostGroups);
    Map<String, Map<String, String>> expected = properties1;
    expected.putAll(properties2);
    Assert.assertEquals(expected, actual);
}
Also used : Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) HashMap(java.util.HashMap) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 14 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetComponentsByHostGroupWhenServiceConfigIsNull.

@Test
public void testGetComponentsByHostGroupWhenServiceConfigIsNull() throws IOException {
    init();
    String hostGroupName = "hostGroup";
    HostgroupView hostGroup = new HostgroupView(hostGroupName, 1, InstanceGroupType.CORE, 1);
    String blueprintText = "blueprintText";
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Set<String>> componentsByHostgroup = new HashMap<>();
    componentsByHostgroup.put(hostGroupName, Sets.newHashSet("serviceName"));
    List<HostgroupView> hostGroups = singletonList(hostGroup);
    when(blueprintTextProcessor.getComponentsByHostGroup()).thenReturn(componentsByHostgroup);
    when(hadoopConfigurationUtils.findHostGroupForNode(hostGroups, hostGroupName)).thenReturn(hostGroup);
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(true);
    when(configUtils.getServiceConfig(eq("serviceName"), anyMapOf(String.class, ServiceConfig.class))).thenReturn(null);
    Map<String, Map<String, String>> actual = underTest.getComponentsByHostGroup(blueprintTextProcessor, hostGroups);
    Assert.assertEquals(emptyMap(), actual);
    verify(blueprintTextProcessor, times(0)).getComponentsInHostGroup(hostGroupName);
}
Also used : Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) HashMap(java.util.HashMap) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 15 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetComponentsByHostGroupWhenServicesIsEmpty.

@Test
public void testGetComponentsByHostGroupWhenServicesIsEmpty() throws IOException {
    init();
    String hostGroupName = "hostGroup";
    HostgroupView hostGroup = new HostgroupView(hostGroupName, 1, InstanceGroupType.CORE, 1);
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Set<String>> componentsByHostgroup = new HashMap<>();
    componentsByHostgroup.put(hostGroupName, emptySet());
    List<HostgroupView> hostGroups = singletonList(hostGroup);
    when(blueprintTextProcessor.getComponentsByHostGroup()).thenReturn(componentsByHostgroup);
    when(hadoopConfigurationUtils.findHostGroupForNode(hostGroups, hostGroupName)).thenReturn(hostGroup);
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(true);
    Map<String, Map<String, String>> actual = underTest.getComponentsByHostGroup(blueprintTextProcessor, hostGroups);
    Assert.assertEquals(emptyMap(), actual);
    verify(configUtils, times(1)).isConfigUpdateNeeded(hostGroup);
    verify(blueprintTextProcessor, times(0)).getComponentsInHostGroup(hostGroupName);
}
Also used : Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) HashMap(java.util.HashMap) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Aggregations

HostgroupView (com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)16 Test (org.junit.Test)13 HashMap (java.util.HashMap)10 Map (java.util.Map)10 Collections.emptyMap (java.util.Collections.emptyMap)9 Collections.singletonMap (java.util.Collections.singletonMap)9 Set (java.util.Set)6 Collections.emptySet (java.util.Collections.emptySet)4 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonPropertyOrder (com.fasterxml.jackson.annotation.JsonPropertyOrder)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 GATEWAY (com.sequenceiq.cloudbreak.api.model.InstanceGroupType.GATEWAY)1 BlueprintComponentConfigProvider (com.sequenceiq.cloudbreak.blueprint.BlueprintComponentConfigProvider)1 BlueprintConfigurationEntry (com.sequenceiq.cloudbreak.blueprint.BlueprintConfigurationEntry)1 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 BlueprintProcessorFactory (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory)1 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)1 SmartsenseConfigurationLocator (com.sequenceiq.cloudbreak.blueprint.SmartsenseConfigurationLocator)1