Search in sources :

Example 1 with StackSetOperationPreferences

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));
}
Also used : UpdateStackSetResult(com.amazonaws.services.cloudformation.model.UpdateStackSetResult) AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) TaskListener(hudson.model.TaskListener) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) UpdateStackSetRequest(com.amazonaws.services.cloudformation.model.UpdateStackSetRequest) StackSetOperationPreferences(com.amazonaws.services.cloudformation.model.StackSetOperationPreferences) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AmazonCloudFormation (com.amazonaws.services.cloudformation.AmazonCloudFormation)1 StackSetOperationPreferences (com.amazonaws.services.cloudformation.model.StackSetOperationPreferences)1 UpdateStackSetRequest (com.amazonaws.services.cloudformation.model.UpdateStackSetRequest)1 UpdateStackSetResult (com.amazonaws.services.cloudformation.model.UpdateStackSetResult)1 TaskListener (hudson.model.TaskListener)1 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1