@Test public void testUpdateNodeCountWhenCheckCallEnvironmentCheck() throws TransactionService.TransactionExecutionException { Stack stack = new Stack(); stack.setId(9876L); stack.setStackStatus(new StackStatus(stack, AVAILABLE)); InstanceGroupAdjustmentV4Request adjustment = new InstanceGroupAdjustmentV4Request(); when(transactionService.required(any(Supplier.class))).thenReturn(null); underTest.updateNodeCount(stack, adjustment, false, new User()); verify(environmentService).checkEnvironmentStatus(stack, EnvironmentStatus.upscalable()); }
public FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user) { environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable()); try { return transactionService.required(() -> { Stack stackWithLists = stackService.getByIdWithLists(stack.getId()); updateNodeCountValidator.validateServiceRoles(stackWithLists, instanceGroupAdjustmentJson); updateNodeCountValidator.validateStackStatus(stackWithLists); updateNodeCountValidator.validateInstanceGroup(stackWithLists, instanceGroupAdjustmentJson.getInstanceGroup()); updateNodeCountValidator.validateScalingAdjustment(instanceGroupAdjustmentJson, stackWithLists); updateNodeCountValidator.validateInstanceStatuses(stackWithLists, instanceGroupAdjustmentJson); if (withClusterEvent) { updateNodeCountValidator.validateClusterStatus(stackWithLists); updateNodeCountValidator.validateHostGroupAdjustment(instanceGroupAdjustmentJson, stackWithLists, instanceGroupAdjustmentJson.getScalingAdjustment()); updateNodeCountValidator.validataHostMetadataStatuses(stackWithLists, instanceGroupAdjustmentJson); } if (instanceGroupAdjustmentJson.getScalingAdjustment() > 0) { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.UPSCALE_REQUESTED); return flowManager.triggerStackUpscale(stackWithLists.getId(), instanceGroupAdjustmentJson, withClusterEvent); } else { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.DOWNSCALE_REQUESTED); return flowManager.triggerStackDownscale(stackWithLists.getId(), instanceGroupAdjustmentJson); } }); } catch (TransactionExecutionException e) { if (e.getCause() instanceof BadRequestException) { throw e.getCause(); } throw new TransactionRuntimeExecutionException(e); } }
StackOperationService { public FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user) { environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable()); try { return transactionService.required(() -> { Stack stackWithLists = stackService.getByIdWithLists(stack.getId()); updateNodeCountValidator.validateServiceRoles(stackWithLists, instanceGroupAdjustmentJson); updateNodeCountValidator.validateStackStatus(stackWithLists); updateNodeCountValidator.validateInstanceGroup(stackWithLists, instanceGroupAdjustmentJson.getInstanceGroup()); updateNodeCountValidator.validateScalingAdjustment(instanceGroupAdjustmentJson, stackWithLists); updateNodeCountValidator.validateInstanceStatuses(stackWithLists, instanceGroupAdjustmentJson); if (withClusterEvent) { updateNodeCountValidator.validateClusterStatus(stackWithLists); updateNodeCountValidator.validateHostGroupAdjustment(instanceGroupAdjustmentJson, stackWithLists, instanceGroupAdjustmentJson.getScalingAdjustment()); updateNodeCountValidator.validataHostMetadataStatuses(stackWithLists, instanceGroupAdjustmentJson); } if (instanceGroupAdjustmentJson.getScalingAdjustment() > 0) { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.UPSCALE_REQUESTED); return flowManager.triggerStackUpscale(stackWithLists.getId(), instanceGroupAdjustmentJson, withClusterEvent); } else { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.DOWNSCALE_REQUESTED); return flowManager.triggerStackDownscale(stackWithLists.getId(), instanceGroupAdjustmentJson); } }); } catch (TransactionExecutionException e) { if (e.getCause() instanceof BadRequestException) { throw e.getCause(); } throw new TransactionRuntimeExecutionException(e); } } }
StackOperationService { public FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user) { environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable()); try { return transactionService.required(() -> { Stack stackWithLists = stackService.getByIdWithLists(stack.getId()); updateNodeCountValidator.validateServiceRoles(stackWithLists, instanceGroupAdjustmentJson); updateNodeCountValidator.validateStackStatus(stackWithLists); updateNodeCountValidator.validateInstanceGroup(stackWithLists, instanceGroupAdjustmentJson.getInstanceGroup()); updateNodeCountValidator.validateScalingAdjustment(instanceGroupAdjustmentJson, stackWithLists); updateNodeCountValidator.validateInstanceStatuses(stackWithLists, instanceGroupAdjustmentJson); if (withClusterEvent) { updateNodeCountValidator.validateClusterStatus(stackWithLists); updateNodeCountValidator.validateHostGroupAdjustment(instanceGroupAdjustmentJson, stackWithLists, instanceGroupAdjustmentJson.getScalingAdjustment()); updateNodeCountValidator.validataHostMetadataStatuses(stackWithLists, instanceGroupAdjustmentJson); } if (instanceGroupAdjustmentJson.getScalingAdjustment() > 0) { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.UPSCALE_REQUESTED); return flowManager.triggerStackUpscale(stackWithLists.getId(), instanceGroupAdjustmentJson, withClusterEvent); } else { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.DOWNSCALE_REQUESTED); return flowManager.triggerStackDownscale(stackWithLists.getId(), instanceGroupAdjustmentJson); } }); } catch (TransactionExecutionException e) { if (e.getCause() instanceof BadRequestException) { throw e.getCause(); } throw new TransactionRuntimeExecutionException(e); } }  }
StackOperationService { public FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user) { environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable()); try { return transactionService.required(() -> { Stack stackWithLists = stackService.getByIdWithLists(stack.getId()); updateNodeCountValidator.validateServiceRoles(stackWithLists, instanceGroupAdjustmentJson); updateNodeCountValidator.validateStackStatus(stackWithLists); updateNodeCountValidator.validateInstanceGroup(stackWithLists, instanceGroupAdjustmentJson.getInstanceGroup()); updateNodeCountValidator.validateScalingAdjustment(instanceGroupAdjustmentJson, stackWithLists); updateNodeCountValidator.validateInstanceStatuses(stackWithLists, instanceGroupAdjustmentJson); if (withClusterEvent) { updateNodeCountValidator.validateClusterStatus(stackWithLists); updateNodeCountValidator.validateHostGroupAdjustment(instanceGroupAdjustmentJson, stackWithLists, instanceGroupAdjustmentJson.getScalingAdjustment()); updateNodeCountValidator.validataHostMetadataStatuses(stackWithLists, instanceGroupAdjustmentJson); } if (instanceGroupAdjustmentJson.getScalingAdjustment() > 0) { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.UPSCALE_REQUESTED); return flowManager.triggerStackUpscale(stackWithLists.getId(), instanceGroupAdjustmentJson, withClusterEvent); } else { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.DOWNSCALE_REQUESTED); return flowManager.triggerStackDownscale(stackWithLists.getId(), instanceGroupAdjustmentJson); } }); } catch (TransactionExecutionException e) { if (e.getCause() instanceof BadRequestException) { throw e.getCause(); } throw new TransactionRuntimeExecutionException(e); } }  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 { public FlowIdentifier updateNodeCount(Stack stack, InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson, boolean withClusterEvent, User user) { environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable()); try { return transactionService.required(() -> { Stack stackWithLists = stackService.getByIdWithLists(stack.getId()); updateNodeCountValidator.validateServiceRoles(stackWithLists, instanceGroupAdjustmentJson); updateNodeCountValidator.validateStackStatus(stackWithLists); updateNodeCountValidator.validateInstanceGroup(stackWithLists, instanceGroupAdjustmentJson.getInstanceGroup()); updateNodeCountValidator.validateScalingAdjustment(instanceGroupAdjustmentJson, stackWithLists); updateNodeCountValidator.validateInstanceStatuses(stackWithLists, instanceGroupAdjustmentJson); if (withClusterEvent) { updateNodeCountValidator.validateClusterStatus(stackWithLists); updateNodeCountValidator.validateHostGroupAdjustment(instanceGroupAdjustmentJson, stackWithLists, instanceGroupAdjustmentJson.getScalingAdjustment()); updateNodeCountValidator.validataHostMetadataStatuses(stackWithLists, instanceGroupAdjustmentJson); } if (instanceGroupAdjustmentJson.getScalingAdjustment() > 0) { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.UPSCALE_REQUESTED); return flowManager.triggerStackUpscale(stackWithLists.getId(), instanceGroupAdjustmentJson, withClusterEvent); } else { stackUpdater.updateStackStatus(stackWithLists.getId(), DetailedStackStatus.DOWNSCALE_REQUESTED); return flowManager.triggerStackDownscale(stackWithLists.getId(), instanceGroupAdjustmentJson); } }); } catch (TransactionExecutionException e) { if (e.getCause() instanceof BadRequestException) { throw e.getCause(); } throw new TransactionRuntimeExecutionException(e); } }  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);  }