use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class InstanceGroupV4RequestToHostGroupConverterTest method testConvertWhenHostNameUpperCase.
@Test
public void testConvertWhenHostNameUpperCase() {
InstanceGroupV4Request source = new InstanceGroupV4Request();
source.setName("MixEdName");
source.setTemplate(new InstanceTemplateV4Request());
HostGroup actual = underTest.convert(source);
assertEquals(actual.getName(), "mixedname");
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesWithoutRepairAndServiceRestart.
@Test
public void testInstallServicesWithoutRepairAndServiceRestart() throws CloudbreakException {
HostGroup hostGroup = newHostGroup("master", newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.DELETED_BY_PROVIDER));
stack.setInstanceGroups(Set.of(hostGroup.getInstanceGroup()));
when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
when(hostGroupService.getByCluster(any())).thenReturn(Set.of(hostGroup));
when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Map.of(), Map.of()));
when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
underTest.installServicesOnNewHosts(1L, Set.of("master"), false, false, Map.of("master", Set.of("master-1", "master-2", "master-3")));
inOrder.verify(parcelService).removeUnusedParcelComponents(stack);
inOrder.verify(recipeEngine, times(1)).executePostAmbariStartRecipes(stack, Set.of(hostGroup));
inOrder.verify(clusterApi, times(1)).upscaleCluster(any());
inOrder.verify(clusterApi, times(0)).restartAll(false);
inOrder.verify(clusterStatusService, times(0)).getDecommissionedHostsFromCM();
inOrder.verify(clusterCommissionService, times(0)).recommissionHosts(any());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method newHostGroup.
private HostGroup newHostGroup(String name, InstanceMetaData... instances) {
HostGroup hostGroup = new HostGroup();
hostGroup.setName(name);
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceMetaData(Set.of(instances));
hostGroup.setInstanceGroup(instanceGroup);
return hostGroup;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesWithRepairAndServiceRestartWhenOneHostIsUnhealthy.
@Test
public void testInstallServicesWithRepairAndServiceRestartWhenOneHostIsUnhealthy() throws CloudbreakException {
HostGroup hostGroup = newHostGroup("master", newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.SERVICES_HEALTHY), newInstance(InstanceStatus.DELETED_BY_PROVIDER));
stack.setInstanceGroups(Set.of(hostGroup.getInstanceGroup()));
when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
when(hostGroupService.getByCluster(any())).thenReturn(Set.of(hostGroup));
when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Map.of(), Map.of()));
when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterStatusService.getDecommissionedHostsFromCM()).thenReturn(List.of());
underTest.installServicesOnNewHosts(1L, Set.of("master"), true, true, Map.of("master", Set.of("master-1", "master-2", "master-3")));
inOrder.verify(parcelService).removeUnusedParcelComponents(stack);
inOrder.verify(recipeEngine, times(1)).executePostAmbariStartRecipes(stack, Set.of(hostGroup));
inOrder.verify(clusterApi, times(1)).upscaleCluster(any());
inOrder.verify(clusterApi, times(0)).restartAll(false);
inOrder.verify(clusterCommissionService, times(0)).recommissionHosts(any());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.
the class StopStartDownscaleDecommissionViaCMHandlerTest method testErrorFromCmHostCollection.
@Test
void testErrorFromCmHostCollection() {
int instancesToDecommissionCount = 5;
int expcetedInstanceToCollectCount = 5;
int expectedInstancesDecommissionedCount = 5;
List<InstanceMetaData> instancesToDecommission = getInstancesToDecommission(instancesToDecommissionCount);
HostGroup hostGroup = createHostGroup(instancesToDecommission);
Map<String, InstanceMetaData> collected = instancesToDecommission.stream().limit(expcetedInstanceToCollectCount).collect(Collectors.toMap(i -> i.getDiscoveryFQDN(), i -> i));
List<InstanceMetaData> decommissionedMetadataList = collected.values().stream().limit(expectedInstancesDecommissionedCount).collect(Collectors.toList());
Set<String> fqdnsDecommissioned = decommissionedMetadataList.stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toUnmodifiableSet());
Set<Long> instanceIdsToDecommission = instancesToDecommission.stream().map(InstanceMetaData::getPrivateId).collect(Collectors.toUnmodifiableSet());
Set<String> hostnamesToDecommission = instancesToDecommission.stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toUnmodifiableSet());
setupAdditionalMocks(hostGroup, instancesToDecommission, collected, fqdnsDecommissioned);
when(clusterDecomissionService.collectHostsToRemove(eq(hostGroup), eq(hostnamesToDecommission))).thenThrow(new RuntimeException("collectHostsToDecommissionError"));
StopStartDownscaleDecommissionViaCMRequest request = new StopStartDownscaleDecommissionViaCMRequest(1L, INSTANCE_GROUP_NAME, instanceIdsToDecommission);
HandlerEvent handlerEvent = new HandlerEvent(Event.wrap(request));
Selectable selectable = underTest.doAccept(handlerEvent);
verify(clusterDecomissionService).collectHostsToRemove(eq(hostGroup), eq(hostnamesToDecommission));
assertThat(selectable).isInstanceOf(StopStartDownscaleDecommissionViaCMResult.class);
StopStartDownscaleDecommissionViaCMResult result = (StopStartDownscaleDecommissionViaCMResult) selectable;
assertThat(result.getNotDecommissionedHostFqdns()).hasSize(0);
assertThat(result.getDecommissionedHostFqdns()).hasSize(0);
assertThat(result.getErrorDetails().getMessage()).isEqualTo("collectHostsToDecommissionError");
assertThat(result.getStatus()).isEqualTo(EventStatus.FAILED);
assertThat(result.selector()).isEqualTo("STOPSTARTDOWNSCALEDECOMMISSIONVIACMRESULT_ERROR");
verifyNoMoreInteractions(instanceMetaDataService);
verifyNoMoreInteractions(flowMessageService);
verifyNoMoreInteractions(clusterDecomissionService);
}
Aggregations