Search in sources :

Example 1 with WaiterUnrecoverableException

use of com.amazonaws.waiters.WaiterUnrecoverableException in project pipeline-aws-plugin by jenkinsci.

the class CloudformationStackTests method createNewStackChangeSet_NoSubmittedChanges.

@Test
public void createNewStackChangeSet_NoSubmittedChanges() throws ExecutionException {
    TaskListener taskListener = Mockito.mock(TaskListener.class);
    Mockito.when(taskListener.getLogger()).thenReturn(System.out);
    AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
    Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
    Mockito.when(client.describeStacks(Mockito.any())).thenReturn(new DescribeStacksResult());
    Mockito.when(client.describeChangeSet(Mockito.any())).thenReturn(new DescribeChangeSetResult().withStatus(ChangeSetStatus.FAILED).withStatusReason("The submitted information didn't contain changes"));
    Mockito.doThrow(new ExecutionException(new WaiterUnrecoverableException("foo"))).when(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
    CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
    stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.CREATE, "myarn", null);
    Mockito.verify(this.eventPrinter, Mockito.atLeastOnce()).waitAndPrintChangeSetEvents(Mockito.any(), Mockito.any(), Mockito.any(Waiter.class), Mockito.any());
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) TaskListener(hudson.model.TaskListener) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) WaiterUnrecoverableException(com.amazonaws.waiters.WaiterUnrecoverableException) DescribeChangeSetResult(com.amazonaws.services.cloudformation.model.DescribeChangeSetResult) ExecutionException(java.util.concurrent.ExecutionException) Waiter(com.amazonaws.waiters.Waiter) DescribeStacksResult(com.amazonaws.services.cloudformation.model.DescribeStacksResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with WaiterUnrecoverableException

use of com.amazonaws.waiters.WaiterUnrecoverableException in project pipeline-aws-plugin by jenkinsci.

the class CloudformationStackTests method createNewStackChangeSet_NoUpdatesToBePerformed.

@Test
public void createNewStackChangeSet_NoUpdatesToBePerformed() throws ExecutionException {
    TaskListener taskListener = Mockito.mock(TaskListener.class);
    Mockito.when(taskListener.getLogger()).thenReturn(System.out);
    AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
    Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
    Mockito.when(client.describeStacks(Mockito.any())).thenReturn(new DescribeStacksResult());
    Mockito.when(client.describeChangeSet(Mockito.any())).thenReturn(new DescribeChangeSetResult().withStatus(ChangeSetStatus.FAILED).withStatusReason("No updates are to be performed"));
    Mockito.doThrow(new ExecutionException(new WaiterUnrecoverableException("foo"))).when(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
    CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
    stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.CREATE, "myarn", null);
    Mockito.verify(this.eventPrinter, Mockito.atLeastOnce()).waitAndPrintChangeSetEvents(Mockito.any(), Mockito.any(), Mockito.any(Waiter.class), Mockito.any());
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) TaskListener(hudson.model.TaskListener) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) WaiterUnrecoverableException(com.amazonaws.waiters.WaiterUnrecoverableException) DescribeChangeSetResult(com.amazonaws.services.cloudformation.model.DescribeChangeSetResult) ExecutionException(java.util.concurrent.ExecutionException) Waiter(com.amazonaws.waiters.Waiter) DescribeStacksResult(com.amazonaws.services.cloudformation.model.DescribeStacksResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with WaiterUnrecoverableException

use of com.amazonaws.waiters.WaiterUnrecoverableException in project pipeline-aws-plugin by jenkinsci.

the class CloudformationStackTests method createNewStackChangeSet_UnknownWaiterError.

@Test(expected = ExecutionException.class)
public void createNewStackChangeSet_UnknownWaiterError() throws ExecutionException {
    TaskListener taskListener = Mockito.mock(TaskListener.class);
    Mockito.when(taskListener.getLogger()).thenReturn(System.out);
    AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
    Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
    Mockito.when(client.describeStacks(Mockito.any())).thenReturn(new DescribeStacksResult());
    Mockito.when(client.describeChangeSet(Mockito.any())).thenReturn(new DescribeChangeSetResult().withStatus(ChangeSetStatus.FAILED).withStatusReason("someother failure"));
    Mockito.doThrow(new ExecutionException(new WaiterUnrecoverableException("foo"))).when(this.eventPrinter).waitAndPrintChangeSetEvents(Mockito.eq("foo"), Mockito.eq("c1"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
    CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
    try {
        stack.createChangeSet("c1", "templateBody", null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), PollConfiguration.DEFAULT, ChangeSetType.CREATE, "myarn", null);
    } finally {
        Mockito.verify(this.eventPrinter, Mockito.atLeastOnce()).waitAndPrintChangeSetEvents(Mockito.any(), Mockito.any(), Mockito.any(Waiter.class), Mockito.any());
    }
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) TaskListener(hudson.model.TaskListener) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) WaiterUnrecoverableException(com.amazonaws.waiters.WaiterUnrecoverableException) DescribeChangeSetResult(com.amazonaws.services.cloudformation.model.DescribeChangeSetResult) ExecutionException(java.util.concurrent.ExecutionException) Waiter(com.amazonaws.waiters.Waiter) DescribeStacksResult(com.amazonaws.services.cloudformation.model.DescribeStacksResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AmazonCloudFormation (com.amazonaws.services.cloudformation.AmazonCloudFormation)3 DescribeChangeSetResult (com.amazonaws.services.cloudformation.model.DescribeChangeSetResult)3 DescribeStacksResult (com.amazonaws.services.cloudformation.model.DescribeStacksResult)3 AmazonCloudFormationWaiters (com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters)3 Waiter (com.amazonaws.waiters.Waiter)3 WaiterUnrecoverableException (com.amazonaws.waiters.WaiterUnrecoverableException)3 TaskListener (hudson.model.TaskListener)3 ExecutionException (java.util.concurrent.ExecutionException)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3