use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackOperationServiceTest method testUpdateNodeCountStartInstances.
@ParameterizedTest(name = "{0}: With stackStatus={1}")
@MethodSource("stackStatusForUpdateNodeCount")
public void testUpdateNodeCountStartInstances(String methodName, DetailedStackStatus stackStatus) throws TransactionService.TransactionExecutionException {
Stack stack = new Stack();
stack.setId(9876L);
stack.setStackStatus(new StackStatus(stack, stackStatus));
Cluster cluster = new Cluster();
cluster.setStatus(Status.AVAILABLE);
stack.setCluster(cluster);
when(stackService.getByIdWithLists(stack.getId())).thenReturn(stack);
InstanceGroupAdjustmentV4Request upscaleAdjustment = new InstanceGroupAdjustmentV4Request();
upscaleAdjustment.setScalingAdjustment(5);
when(transactionService.required(any(Supplier.class))).thenAnswer(ans -> ((Supplier) ans.getArgument(0)).get());
doNothing().when(updateNodeCountValidator).validateServiceRoles(any(), any(InstanceGroupAdjustmentV4Request.class));
if (stackStatus != CLUSTER_UPGRADE_FAILED) {
doNothing().when(updateNodeCountValidator).validateInstanceGroup(any(), any());
doNothing().when(updateNodeCountValidator).validateScalabilityOfInstanceGroup(any(), any(InstanceGroupAdjustmentV4Request.class));
doNothing().when(updateNodeCountValidator).validateScalingAdjustment(any(InstanceGroupAdjustmentV4Request.class), any());
doNothing().when(updateNodeCountValidator).validateHostGroupIsPresent(any(InstanceGroupAdjustmentV4Request.class), any());
doNothing().when(updateNodeCountValidator).validateInstanceGroupForStopStart(any(), any(), anyInt());
}
// Regular
try {
underTest.updateNodeCountStartInstances(stack, upscaleAdjustment, true, ScalingStrategy.STOPSTART);
String expectedStatusReason = "Requested node count for upscaling (stopstart): " + upscaleAdjustment.getScalingAdjustment();
verify(stackUpdater).updateStackStatus(stack.getId(), DetailedStackStatus.UPSCALE_BY_START_REQUESTED, expectedStatusReason);
verify(flowManager).triggerStopStartStackUpscale(stack.getId(), upscaleAdjustment, true);
} catch (Exception e) {
assertSame(CLUSTER_UPGRADE_FAILED, stackStatus);
assertSame(BadRequestException.class, e.getClass());
}
// Somehow invoked with a negative value
upscaleAdjustment.setScalingAdjustment(-1);
assertThrows(BadRequestException.class, () -> underTest.updateNodeCountStartInstances(stack, upscaleAdjustment, true, ScalingStrategy.STOPSTART));
upscaleAdjustment.setScalingAdjustment(0);
assertThrows(BadRequestException.class, () -> underTest.updateNodeCountStartInstances(stack, upscaleAdjustment, true, ScalingStrategy.STOPSTART));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class RecoveryTeardownService method handleRecoveryTeardownError.
public void handleRecoveryTeardownError(StackView stack, Exception errorDetails) {
Long stackId = stack.getId();
String stackUpdateMessage = "Recovery failed: " + errorDetails.getMessage();
DetailedStackStatus status = DetailedStackStatus.CLUSTER_RECOVERY_FAILED;
stackUpdater.updateStackStatus(stackId, status, stackUpdateMessage);
LOGGER.info("Error during stack recovery flow: ", errorDetails);
metricService.incrementMetricCounter(MetricType.STACK_RECOVERY_TEARDOWN_FAILED, stack, errorDetails);
flowMessageService.fireEventAndLog(stackId, status.name(), DATALAKE_RECOVERY_FAILED, stackUpdateMessage);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackImageFilterServiceTest method getStack.
private Stack getStack(DetailedStackStatus detailedStackStatus) {
Stack stack = new Stack();
stack.setId(STACK_ID);
stack.setCloudPlatform(PROVIDER_AWS);
stack.setPlatformVariant(PROVIDER_AWS);
stack.setName(STACK_NAME);
stack.setStackStatus(new StackStatus(stack, detailedStackStatus.getStatus(), "", detailedStackStatus));
Cluster cluster = new Cluster();
stack.setCluster(cluster);
return stack;
}
Aggregations