use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StopStartDownscaleDecommissionViaCMHandlerTest method testNoNodesInInitialDecommissionRequest.
@Test
void testNoNodesInInitialDecommissionRequest() {
int instancesToDecommissionCount = 0;
int expcetedInstanceToCollectCount = 0;
int expectedInstancesDecommissionedCount = 0;
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());
setupAdditionalMocks(hostGroup, instancesToDecommission, collected, fqdnsDecommissioned);
Set<Long> instanceIdsToDecommission = instancesToDecommission.stream().map(InstanceMetaData::getPrivateId).collect(Collectors.toUnmodifiableSet());
Set<String> hostnamesToDecommission = instancesToDecommission.stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toUnmodifiableSet());
StopStartDownscaleDecommissionViaCMRequest request = new StopStartDownscaleDecommissionViaCMRequest(1L, INSTANCE_GROUP_NAME, instanceIdsToDecommission);
HandlerEvent handlerEvent = new HandlerEvent(Event.wrap(request));
Selectable selectable = underTest.doAccept(handlerEvent);
assertThat(selectable).isInstanceOf(StopStartDownscaleDecommissionViaCMResult.class);
StopStartDownscaleDecommissionViaCMResult result = (StopStartDownscaleDecommissionViaCMResult) selectable;
assertThat(result.getDecommissionedHostFqdns()).hasSize(expectedInstancesDecommissionedCount);
assertThat(result.getNotDecommissionedHostFqdns()).hasSize(instancesToDecommissionCount - expectedInstancesDecommissionedCount);
verify(clusterDecomissionService).collectHostsToRemove(eq(hostGroup), eq(hostnamesToDecommission));
verifyNoMoreInteractions(instanceMetaDataService);
verifyNoMoreInteractions(flowMessageService);
verifyNoMoreInteractions(clusterDecomissionService);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StopStartUpscaleCommissionViaCMHandlerTest method testAllCommissioned.
@Test
void testAllCommissioned() throws ClusterClientInitException {
int commissionInstanceCount = 5;
List<InstanceMetaData> instancesToCommission = createInstancesToCommission(commissionInstanceCount);
HostGroup hostGroup = createHostGroup(instancesToCommission);
Set<String> hostNames = instancesToCommission.stream().map(i -> i.getDiscoveryFQDN()).collect(Collectors.toSet());
Map<String, InstanceMetaData> cmAvailableHosts = instancesToCommission.stream().collect(Collectors.toMap(i -> i.getDiscoveryFQDN(), i -> i));
Set<String> recommissionedFqdns = cmAvailableHosts.keySet().stream().collect(Collectors.toUnmodifiableSet());
setupPerTestMocks(hostGroup, hostNames, cmAvailableHosts, recommissionedFqdns);
StopStartUpscaleCommissionViaCMRequest request = new StopStartUpscaleCommissionViaCMRequest(1L, INSTANCE_GROUP_NAME, instancesToCommission, Collections.emptyList());
HandlerEvent handlerEvent = new HandlerEvent(Event.wrap(request));
Selectable selectable = underTest.doAccept(handlerEvent);
assertThat(selectable).isInstanceOf(StopStartUpscaleCommissionViaCMResult.class);
StopStartUpscaleCommissionViaCMResult result = (StopStartUpscaleCommissionViaCMResult) selectable;
assertThat(result.getNotRecommissionedFqdns()).hasSize(0);
assertThat(result.getSuccessfullyCommissionedFqdns()).hasSize(commissionInstanceCount);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StopStartUpscaleCommissionViaCMHandlerTest method testFewerNodesOnBothCmInvocations.
@Test
void testFewerNodesOnBothCmInvocations() throws ClusterClientInitException {
int commissionInstanceCount = 5;
List<InstanceMetaData> instancesToCommission = createInstancesToCommission(commissionInstanceCount);
HostGroup hostGroup = createHostGroup(instancesToCommission);
Set<String> hostNames = instancesToCommission.stream().map(i -> i.getDiscoveryFQDN()).collect(Collectors.toSet());
Map<String, InstanceMetaData> cmAvailableHosts = instancesToCommission.stream().limit(commissionInstanceCount - 1).collect(Collectors.toMap(i -> i.getDiscoveryFQDN(), i -> i));
Set<String> recommissionedFqdns = cmAvailableHosts.keySet().stream().limit(commissionInstanceCount - 2).collect(Collectors.toUnmodifiableSet());
setupPerTestMocks(hostGroup, hostNames, cmAvailableHosts, recommissionedFqdns);
StopStartUpscaleCommissionViaCMRequest request = new StopStartUpscaleCommissionViaCMRequest(1L, INSTANCE_GROUP_NAME, instancesToCommission, Collections.emptyList());
HandlerEvent handlerEvent = new HandlerEvent(Event.wrap(request));
Selectable selectable = underTest.doAccept(handlerEvent);
assertThat(selectable).isInstanceOf(StopStartUpscaleCommissionViaCMResult.class);
StopStartUpscaleCommissionViaCMResult result = (StopStartUpscaleCommissionViaCMResult) selectable;
assertThat(result.getNotRecommissionedFqdns()).hasSize(2);
assertThat(result.getSuccessfullyCommissionedFqdns()).hasSize(commissionInstanceCount - 2);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StopStartUpscaleCommissionViaCMHandlerTest method testErrorFromCmHostCollection.
@Test
void testErrorFromCmHostCollection() throws ClusterClientInitException {
int commissionInstanceCount = 5;
List<InstanceMetaData> instancesToCommission = createInstancesToCommission(commissionInstanceCount);
HostGroup hostGroup = createHostGroup(instancesToCommission);
Set<String> hostNames = instancesToCommission.stream().map(i -> i.getDiscoveryFQDN()).collect(Collectors.toSet());
Map<String, InstanceMetaData> cmAvailableHosts = instancesToCommission.stream().collect(Collectors.toMap(i -> i.getDiscoveryFQDN(), i -> i));
Set<String> recommissionedFqdns = cmAvailableHosts.keySet().stream().collect(Collectors.toUnmodifiableSet());
setupPerTestMocks(hostGroup, hostNames, cmAvailableHosts, recommissionedFqdns);
when(clusterCommissionService.collectHostsToCommission(eq(hostGroup), eq(hostNames))).thenThrow(new RuntimeException("collectHostsToCommissionError"));
StopStartUpscaleCommissionViaCMRequest request = new StopStartUpscaleCommissionViaCMRequest(1L, INSTANCE_GROUP_NAME, instancesToCommission, Collections.emptyList());
HandlerEvent handlerEvent = new HandlerEvent(Event.wrap(request));
Selectable selectable = underTest.doAccept(handlerEvent);
assertThat(selectable).isInstanceOf(StopStartUpscaleCommissionViaCMResult.class);
StopStartUpscaleCommissionViaCMResult result = (StopStartUpscaleCommissionViaCMResult) selectable;
assertThat(result.getSuccessfullyCommissionedFqdns()).hasSize(0);
assertThat(result.getNotRecommissionedFqdns()).hasSize(0);
assertThat(result.getErrorDetails().getMessage()).isEqualTo("collectHostsToCommissionError");
assertThat(result.getStatus()).isEqualTo(EventStatus.FAILED);
assertThat(result.selector()).isEqualTo("STOPSTARTUPSCALECOMMISSIONVIACMRESULT_ERROR");
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StackScalabilityConditionTest method testIsScalableShouldReturnTrueWhenThereAreNoPendingInstances.
@Test
public void testIsScalableShouldReturnTrueWhenThereAreNoPendingInstances() {
Set<InstanceMetaData> instanceMetaData = createInstanceMetadataWithRegisteredInstances();
Stack stack = createStac(instanceMetaData);
boolean actual = underTest.isScalable(stack, GROUP_NAME);
assertTrue(actual);
}
Aggregations