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