Search in sources :

Example 6 with DescribeChangeSetResult

use of com.amazonaws.services.cloudformation.model.DescribeChangeSetResult in project pipeline-aws-plugin by jenkinsci.

the class CFNCreateChangeSetTests method createChangeSetStackDoesNotExist.

@Test
public void createChangeSetStackDoesNotExist() throws Exception {
    WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    Mockito.when(stack.exists()).thenReturn(false);
    Mockito.when(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 = jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    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.anyInt(), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString());
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) TaskListener(hudson.model.TaskListener) Parameter(com.amazonaws.services.cloudformation.model.Parameter) Run(hudson.model.Run) DescribeChangeSetResult(com.amazonaws.services.cloudformation.model.DescribeChangeSetResult) Change(com.amazonaws.services.cloudformation.model.Change) Tag(com.amazonaws.services.cloudformation.model.Tag) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with DescribeChangeSetResult

use of com.amazonaws.services.cloudformation.model.DescribeChangeSetResult in project pipeline-aws-plugin by jenkinsci.

the class CFNCreateChangeSetTests method updateChangeSetWithRawTemplate.

@Test
public void updateChangeSetWithRawTemplate() throws Exception {
    WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
    Mockito.when(stack.exists()).thenReturn(false);
    Mockito.when(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 = jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
    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.anyInt(), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString());
}
Also used : AmazonCloudFormation(com.amazonaws.services.cloudformation.AmazonCloudFormation) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) TaskListener(hudson.model.TaskListener) Parameter(com.amazonaws.services.cloudformation.model.Parameter) Run(hudson.model.Run) DescribeChangeSetResult(com.amazonaws.services.cloudformation.model.DescribeChangeSetResult) Change(com.amazonaws.services.cloudformation.model.Change) Tag(com.amazonaws.services.cloudformation.model.Tag) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DescribeChangeSetResult (com.amazonaws.services.cloudformation.model.DescribeChangeSetResult)7 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)7 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 Run (hudson.model.Run)6 AmazonCloudFormation (com.amazonaws.services.cloudformation.AmazonCloudFormation)5 Change (com.amazonaws.services.cloudformation.model.Change)5 Parameter (com.amazonaws.services.cloudformation.model.Parameter)5 Tag (com.amazonaws.services.cloudformation.model.Tag)5 TaskListener (hudson.model.TaskListener)5