use of com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackParametersFromMap.
@Test
public void createChangeSetStackParametersFromMap() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(this.stack.exists()).thenReturn(true);
Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', params: ['foo': 'bar', 'baz': 'true'])\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
this.jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.anyString(), Mockito.anyString(), Mockito.eq(Arrays.asList(new Parameter().withParameterKey("foo").withParameterValue("bar"), new Parameter().withParameterKey("baz").withParameterValue("true"))), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString(), Mockito.any());
}
use of com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetWithRawTemplate.
@Test
public void createChangeSetWithRawTemplate() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(this.stack.exists()).thenReturn(true);
Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', template: 'foobaz')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
this.jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.eq("foobaz"), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString(), Mockito.any());
}
use of com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method describeChangeSet.
@Test
public void describeChangeSet() {
TaskListener taskListener = Mockito.mock(TaskListener.class);
Mockito.when(taskListener.getLogger()).thenReturn(System.out);
AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
DescribeChangeSetResult expected = new DescribeChangeSetResult().withChanges(new Change());
Mockito.when(client.describeChangeSet(Mockito.any(DescribeChangeSetRequest.class))).thenReturn(expected);
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
DescribeChangeSetResult result = stack.describeChangeSet("bar");
Assertions.assertThat(result).isSameAs(expected);
ArgumentCaptor<DescribeChangeSetRequest> captor = ArgumentCaptor.forClass(DescribeChangeSetRequest.class);
Mockito.verify(client).describeChangeSet(captor.capture());
Assertions.assertThat(captor.getValue()).isEqualTo(new DescribeChangeSetRequest().withStackName("foo").withChangeSetName("bar"));
}
use of com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CloudformationStackTests method executeChangeSetWithChanges.
@Test
public void executeChangeSetWithChanges() throws ExecutionException {
TaskListener taskListener = Mockito.mock(TaskListener.class);
Mockito.when(taskListener.getLogger()).thenReturn(System.out);
Mockito.when(taskListener.getLogger()).thenReturn(System.out);
AmazonCloudFormation client = Mockito.mock(AmazonCloudFormation.class);
Mockito.when(client.waiters()).thenReturn(new AmazonCloudFormationWaiters(client));
CloudFormationStack stack = new CloudFormationStack(client, "foo", taskListener);
Mockito.when(client.describeChangeSet(new DescribeChangeSetRequest().withStackName("foo").withChangeSetName("bar"))).thenReturn(new DescribeChangeSetResult().withChanges(new Change()));
Mockito.when(client.describeStacks(new DescribeStacksRequest().withStackName("foo"))).thenReturn(new DescribeStacksResult().withStacks(new Stack().withStackStatus("CREATE_COMPLETE").withOutputs(new Output().withOutputKey("bar").withOutputValue("baz"))));
Map<String, String> outputs = stack.executeChangeSet("bar", PollConfiguration.DEFAULT);
Mockito.verify(client).executeChangeSet(Mockito.any(ExecuteChangeSetRequest.class));
Mockito.verify(this.eventPrinter).waitAndPrintStackEvents(Mockito.eq("foo"), Mockito.any(Waiter.class), Mockito.eq(PollConfiguration.DEFAULT));
Assertions.assertThat(outputs).containsEntry("bar", "baz").containsEntry("jenkinsStackUpdateStatus", "true");
}
use of com.amazonaws.services.cloudformation.model.Change in project pipeline-aws-plugin by jenkinsci.
the class CFNCreateChangeSetTests method createChangeSetStackExists.
@Test
public void createChangeSetStackExists() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(this.stack.exists()).thenReturn(true);
Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult().withChanges(new Change()).withStatus(ChangeSetStatus.CREATE_COMPLETE));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true));
Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
this.jenkinsRule.assertLogContains("changesCount=1", run);
PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class));
Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.anyString(), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString(), Mockito.any());
}
Aggregations