use of com.amazonaws.services.cloudformation.model.StackSetOperationPreferences in project pipeline-aws-plugin by jenkinsci.
the class CFNUpdateStackSetStepTest method updateExistingStackStackSetWithOperationPreferences.
@Test
public void updateExistingStackStackSetWithOperationPreferences() throws Exception {
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(stackSet.exists()).thenReturn(true);
String operationId = UUID.randomUUID().toString();
Mockito.when(stackSet.update(Mockito.anyString(), Mockito.anyString(), Mockito.any(UpdateStackSetRequest.class))).thenReturn(new UpdateStackSetResult().withOperationId(operationId));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " cfnUpdateStackSet(stackSet: 'foo', operationPreferences: [failureToleranceCount: 5, regionOrder: ['us-west-2'], failureTolerancePercentage: 17, maxConcurrentCount: 18, maxConcurrentPercentage: 34])" + "}\n", true));
jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
PowerMockito.verifyNew(CloudFormationStackSet.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class), Mockito.eq(SleepStrategy.EXPONENTIAL_BACKOFF_STRATEGY));
ArgumentCaptor<UpdateStackSetRequest> requestCapture = ArgumentCaptor.forClass(UpdateStackSetRequest.class);
Mockito.verify(stackSet).update(Mockito.anyString(), Mockito.anyString(), requestCapture.capture());
Assertions.assertThat(requestCapture.getValue().getOperationPreferences()).isEqualTo(new StackSetOperationPreferences().withFailureToleranceCount(5).withRegionOrder("us-west-2").withFailureTolerancePercentage(17).withMaxConcurrentCount(18).withMaxConcurrentPercentage(34));
Mockito.verify(stackSet).waitForOperationToComplete(operationId, Duration.ofSeconds(1));
}
Aggregations