@Test public void testStartWhenStackStartFailed() { Stack stack = new Stack(); stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.START_FAILED)); stack.setId(1L); underTest.start(stack, null, false, new User()); verify(flowManager, times(1)).triggerStackStart(stack.getId()); verify(stackUpdater, times(1)).updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED); }
@VisibleForTesting FlowIdentifier start(Stack stack, Cluster cluster, boolean updateCluster, User user) { FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered(); environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable()); if (stack.isAvailable() && (cluster == null || cluster.isAvailable())) { eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED); } else if (isStackStartable(stack) || isClusterStartable(cluster)) { Stack startStack = stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED); flowIdentifier = flowManager.triggerStackStart(stack.getId()); if (updateCluster && cluster != null) { clusterOperationService.updateStatus(startStack, StatusRequest.STARTED); } } else { throw NotAllowedStatusUpdate .stack(stack) .to(DetailedStackStatus.START_REQUESTED) .badRequest(); } return flowIdentifier; }
StackOperationService { @VisibleForTesting FlowIdentifier start(Stack stack, Cluster cluster, boolean updateCluster, User user) { FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered(); environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable()); if (stack.isAvailable() && (cluster == null || cluster.isAvailable())) { eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED); } else if (isStackStartable(stack) || isClusterStartable(cluster)) { Stack startStack = stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED); flowIdentifier = flowManager.triggerStackStart(stack.getId()); if (updateCluster && cluster != null) { clusterOperationService.updateStatus(startStack, StatusRequest.STARTED); } } else { throw NotAllowedStatusUpdate .stack(stack) .to(DetailedStackStatus.START_REQUESTED) .badRequest(); } return flowIdentifier; } }
StackOperationService { @VisibleForTesting FlowIdentifier start(Stack stack, Cluster cluster, boolean updateCluster, User user) { FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered(); environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable()); if (stack.isAvailable() && (cluster == null || cluster.isAvailable())) { eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED); } else if (isStackStartable(stack) || isClusterStartable(cluster)) { Stack startStack = stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED); flowIdentifier = flowManager.triggerStackStart(stack.getId()); if (updateCluster && cluster != null) { clusterOperationService.updateStatus(startStack, StatusRequest.STARTED); } } else { throw NotAllowedStatusUpdate .stack(stack) .to(DetailedStackStatus.START_REQUESTED) .badRequest(); } return flowIdentifier; }  }
StackOperationService { @VisibleForTesting FlowIdentifier start(Stack stack, Cluster cluster, boolean updateCluster, User user) { FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered(); environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable()); if (stack.isAvailable() && (cluster == null || cluster.isAvailable())) { eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED); } else if (isStackStartable(stack) || isClusterStartable(cluster)) { Stack startStack = stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED); flowIdentifier = flowManager.triggerStackStart(stack.getId()); if (updateCluster && cluster != null) { clusterOperationService.updateStatus(startStack, StatusRequest.STARTED); } } else { throw NotAllowedStatusUpdate .stack(stack) .to(DetailedStackStatus.START_REQUESTED) .badRequest(); } return flowIdentifier; }  FlowIdentifier removeInstance(Stack stack, Long workspaceId, String instanceId, boolean forced, User user); FlowIdentifier removeInstances(Stack stack, Long workspaceId, Collection<String> instanceIds, boolean forced, User user); FlowIdentifier updateImage(Long stackId, Long workspaceId, String imageId, String imageCatalogName, String imageCatalogUrl, User user); FlowIdentifier updateStatus(Long stackId, StatusRequest status, boolean updateCluster, User user); FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user); void renewCertificate(String stackName); }
StackOperationService { @VisibleForTesting FlowIdentifier start(Stack stack, Cluster cluster, boolean updateCluster, User user) { FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered(); environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable()); if (stack.isAvailable() && (cluster == null || cluster.isAvailable())) { eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED); } else if (isStackStartable(stack) || isClusterStartable(cluster)) { Stack startStack = stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.START_REQUESTED); flowIdentifier = flowManager.triggerStackStart(stack.getId()); if (updateCluster && cluster != null) { clusterOperationService.updateStatus(startStack, StatusRequest.STARTED); } } else { throw NotAllowedStatusUpdate .stack(stack) .to(DetailedStackStatus.START_REQUESTED) .badRequest(); } return flowIdentifier; }  FlowIdentifier removeInstance(Stack stack, Long workspaceId, String instanceId, boolean forced, User user); FlowIdentifier removeInstances(Stack stack, Long workspaceId, Collection<String> instanceIds, boolean forced, User user); FlowIdentifier updateImage(Long stackId, Long workspaceId, String imageId, String imageCatalogName, String imageCatalogUrl, User user); FlowIdentifier updateStatus(Long stackId, StatusRequest status, boolean updateCluster, User user); FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user); void renewCertificate(String stackName);  }