use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class StackOperationServiceTest method testStop.
@ParameterizedTest(name = "{0}: With stackStatus={1}")
@MethodSource("stackStatusForStop")
public void testStop(String methodName, DetailedStackStatus stackStatus) {
Stack stack = new Stack();
stack.setId(9876L);
stack.setStackStatus(new StackStatus(stack, stackStatus));
Cluster cluster = new Cluster();
cluster.setId(1L);
stack.setCluster(cluster);
when(stackStopRestrictionService.isInfrastructureStoppable(any())).thenReturn(StopRestrictionReason.NONE);
// On demand instances
when(spotInstanceUsageCondition.isStackRunsOnSpotInstances(stack)).thenReturn(false);
when(stackService.getByIdWithLists(stack.getId())).thenReturn(stack);
when(clusterService.findOneWithLists(cluster.getId())).thenReturn(Optional.of(cluster));
underTest.updateStatus(stack.getId(), StatusRequest.STOPPED, true);
if (stackStatus == STOP_FAILED) {
verify(flowManager).triggerStackStop(stack.getId());
} else {
verify(clusterOperationService).updateStatus(stack.getId(), StatusRequest.STOPPED);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class UpdateNodeCountValidatorTest method validateClusterStatusDownscaleNodeFailureTargetedUpscaleNotSupported.
@Test
void validateClusterStatusDownscaleNodeFailureTargetedUpscaleNotSupported() {
when(targetedUpscaleSupportService.targetedUpscaleEntitlementsEnabled(any())).thenReturn(Boolean.FALSE);
Stack stack = new Stack();
stack.setName("stack");
Cluster cluster = mock(Cluster.class);
stack.setCluster(cluster);
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.NODE_FAILURE));
BadRequestException e = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateClusterStatus(stack, false));
assertEquals("Data Hub 'stack' is currently in 'NODE_FAILURE' state. Node count can only be updated if it's running.", e.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class UpdateNodeCountValidatorTest method setupMocksForStopStartInstanceGroupValidation.
private void setupMocksForStopStartInstanceGroupValidation(Stack stack) {
CmTemplateProcessor cmTemplateProcessor = mock(CmTemplateProcessor.class);
Cluster cluster = mock(Cluster.class);
Blueprint blueprint = mock(Blueprint.class);
when(stack.getCluster()).thenReturn(cluster);
when(cluster.getBlueprint()).thenReturn(blueprint);
when(blueprint.getBlueprintText()).thenReturn(TEST_BLUEPRINT_TEXT);
when(cmTemplateProcessorFactory.get(anyString())).thenReturn(cmTemplateProcessor);
when(cmTemplateProcessor.getComputeHostGroups(any())).thenReturn(Set.of(TEST_COMPUTE_GROUP));
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class UpdateNodeCountValidatorTest method validateClusterStatusDownscaleNodeFailureTargetedUpscaleSupported.
@Test
void validateClusterStatusDownscaleNodeFailureTargetedUpscaleSupported() {
when(targetedUpscaleSupportService.targetedUpscaleEntitlementsEnabled(any())).thenReturn(Boolean.TRUE);
Stack stack = new Stack();
stack.setName("stack");
Cluster cluster = mock(Cluster.class);
stack.setCluster(cluster);
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.NODE_FAILURE));
BadRequestException e = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateClusterStatus(stack, false));
assertEquals("Data Hub 'stack' is currently in 'NODE_FAILURE' state. Node count can only be updated if it's running.", e.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ParcelServiceTest method createStack.
private Stack createStack() {
Stack stack = new Stack();
Cluster cluster = new Cluster();
cluster.setId(CLUSTER_ID);
stack.setId(STACK_ID);
stack.setCluster(cluster);
return stack;
}
Aggregations