@Test public void testStartSomeInstancesStarted() { mockDescribeInstancesOneIsRunningLastSuccess(POLLING_LIMIT - 2); ArgumentCaptor<StartInstancesRequest> captor = ArgumentCaptor.forClass(StartInstancesRequest.class); List<CloudVmInstanceStatus> result = underTest.start(authenticatedContext, List.of(), inputList); verify(amazonEC2Client, times(1)).startInstances(captor.capture()); Assertions.assertTrue(captor.getValue().getInstanceIds().size() < inputList.size()); Assert.assertThat(result, hasItem(allOf(hasProperty("status", is(InstanceStatus.STARTED))))); }
@Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override public List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) { return setCloudVmInstanceStatuses(ac, vms, "Running", (ec2Client, instances) -> ec2Client.startInstances(new StartInstancesRequest().withInstanceIds(instances)), "Failed to send start request to AWS: "); }
AwsInstanceConnector implements InstanceConnector { @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override public List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) { return setCloudVmInstanceStatuses(ac, vms, "Running", (ec2Client, instances) -> ec2Client.startInstances(new StartInstancesRequest().withInstanceIds(instances)), "Failed to send start request to AWS: "); } }
AwsInstanceConnector implements InstanceConnector { @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override public List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) { return setCloudVmInstanceStatuses(ac, vms, "Running", (ec2Client, instances) -> ec2Client.startInstances(new StartInstancesRequest().withInstanceIds(instances)), "Failed to send start request to AWS: "); }  }
AwsInstanceConnector implements InstanceConnector { @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override public List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) { return setCloudVmInstanceStatuses(ac, vms, "Running", (ec2Client, instances) -> ec2Client.startInstances(new StartInstancesRequest().withInstanceIds(instances)), "Failed to send start request to AWS: "); }  @Override String getConsoleOutput(AuthenticatedContext authenticatedContext, CloudInstance vm); @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms); @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override List<CloudVmInstanceStatus> stop(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms); @Retryable( value = SdkClientException.class, maxAttempts = 15, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000) ) @Override List<CloudVmInstanceStatus> reboot(AuthenticatedContext ac, List<CloudInstance> vms); void logInvalidStatuses(List<CloudVmInstanceStatus> instances, InstanceStatus targetStatus); @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override List<CloudVmInstanceStatus> check(AuthenticatedContext ac, List<CloudInstance> vms); }
AwsInstanceConnector implements InstanceConnector { @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override public List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) { return setCloudVmInstanceStatuses(ac, vms, "Running", (ec2Client, instances) -> ec2Client.startInstances(new StartInstancesRequest().withInstanceIds(instances)), "Failed to send start request to AWS: "); }  @Override String getConsoleOutput(AuthenticatedContext authenticatedContext, CloudInstance vm); @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms); @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override List<CloudVmInstanceStatus> stop(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms); @Retryable( value = SdkClientException.class, maxAttempts = 15, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000) ) @Override List<CloudVmInstanceStatus> reboot(AuthenticatedContext ac, List<CloudInstance> vms); void logInvalidStatuses(List<CloudVmInstanceStatus> instances, InstanceStatus targetStatus); @Retryable( value = SdkClientException.class, maxAttemptsExpression = "#{${cb.vm.retry.attempt:15}}", backoff = @Backoff(delayExpression = "#{${cb.vm.retry.backoff.delay:1000}}", multiplierExpression = "#{${cb.vm.retry.backoff.multiplier:2}}", maxDelayExpression = "#{${cb.vm.retry.backoff.maxdelay:10000}}") ) @Override List<CloudVmInstanceStatus> check(AuthenticatedContext ac, List<CloudInstance> vms); static final String INSTANCE_NOT_FOUND_ERROR_CODE; }