use of com.amazonaws.services.cloudformation.model.StackResourceSummary in project cloudbreak by hortonworks.
the class AwsLaunchServiceLoadBalancerTest method testUpdateCloudformationSuccess.
@Test
public void testUpdateCloudformationSuccess() {
List<CloudResource> instances = createInstances();
AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, null);
Network network = createNetwork(PRIVATE_ID_1, null);
Set<LoadBalancerType> types = Set.of(LoadBalancerType.PRIVATE);
List<StackResourceSummary> firstUpdateSummaries = createFirstUpdateSummaries(types);
List<StackResourceSummary> secondUpdateSummaries = createFullSummaries(types);
setupMocksForUpdate(awsNetworkView, network, instances, types);
when(result.getStackResourceSummaries()).thenReturn(List.of()).thenReturn(firstUpdateSummaries).thenReturn(firstUpdateSummaries).thenReturn(secondUpdateSummaries);
when(ac.getCloudContext()).thenReturn(cloudContext);
when(cloudContext.getLocation()).thenReturn(location);
when(location.getAvailabilityZone()).thenReturn(availabilityZone("az1"));
List<CloudResourceStatus> statuses = underTest.updateCloudformationWithLoadBalancers(ac, cloudStack, null, null);
assertEquals(1, statuses.size());
assertEquals(com.sequenceiq.cloudbreak.cloud.model.ResourceStatus.CREATED, statuses.get(0).getStatus());
assertEquals(CREATED, statuses.get(0).getCloudResource().getStatus());
assertEquals(ELASTIC_LOAD_BALANCER, statuses.get(0).getCloudResource().getType());
}
use of com.amazonaws.services.cloudformation.model.StackResourceSummary in project cloudbreak by hortonworks.
the class AwsLaunchServiceLoadBalancerTest method testUpdateCloudformationWithEndpointGatewayAndPrivateSubnet.
@Test
public void testUpdateCloudformationWithEndpointGatewayAndPrivateSubnet() {
List<CloudResource> instances = createInstances();
AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, PUBLIC_ID_1);
Network network = createNetwork(PRIVATE_ID_1, PUBLIC_ID_1);
Set<LoadBalancerType> types = Set.of(LoadBalancerType.PUBLIC, LoadBalancerType.PRIVATE);
List<StackResourceSummary> firstUpdateSummaries = createFirstUpdateSummaries(types);
List<StackResourceSummary> secondUpdateSummaries = createFullSummaries(types);
setupMocksForUpdate(awsNetworkView, network, instances, Set.of(LoadBalancerType.PUBLIC, LoadBalancerType.PRIVATE));
when(result.getStackResourceSummaries()).thenReturn(List.of()).thenReturn(firstUpdateSummaries).thenReturn(firstUpdateSummaries).thenReturn(secondUpdateSummaries);
when(ac.getCloudContext()).thenReturn(cloudContext);
when(cloudContext.getLocation()).thenReturn(location);
when(location.getAvailabilityZone()).thenReturn(availabilityZone("az1"));
underTest.updateCloudformationWithLoadBalancers(ac, cloudStack, null, null);
verify(cfClient, times(2)).updateStack(any());
verify(result, times(5)).getStackResourceSummaries();
}
use of com.amazonaws.services.cloudformation.model.StackResourceSummary in project cloudbreak by hortonworks.
the class AwsLaunchServiceLoadBalancerTest method testUpdateCloudformationWithLoadBalancerMissingTargetGroupArn.
@Test
public void testUpdateCloudformationWithLoadBalancerMissingTargetGroupArn() {
List<CloudResource> instances = createInstances();
AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, null);
Network network = createNetwork(PRIVATE_ID_1, null);
String expectedError = String.format("Could not create load balancer listeners: target group %s arn not found.", AwsTargetGroup.getTargetGroupName(PORT, AwsLoadBalancerScheme.INTERNAL));
Set<LoadBalancerType> types = Set.of(LoadBalancerType.PRIVATE);
List<StackResourceSummary> firstUpdateSummaries = createFirstUpdateSummaries(types);
StackResourceSummary tgSummary = firstUpdateSummaries.get(TG_INDEX);
tgSummary.setPhysicalResourceId(null);
List<StackResourceSummary> secondUpdateSummaries = createFullSummaries(types);
setupMocksForUpdate(awsNetworkView, network, instances, types);
when(result.getStackResourceSummaries()).thenReturn(List.of()).thenReturn(firstUpdateSummaries).thenReturn(firstUpdateSummaries).thenReturn(secondUpdateSummaries);
CloudConnectorException exception = assertThrows(CloudConnectorException.class, () -> underTest.updateCloudformationWithLoadBalancers(ac, cloudStack, null, null));
verify(cfClient, times(1)).updateStack(any());
verify(result, times(2)).getStackResourceSummaries();
assertEquals(expectedError, exception.getMessage());
}
use of com.amazonaws.services.cloudformation.model.StackResourceSummary in project pipeline-aws-plugin by jenkinsci.
the class LambdaVersionCleanupStepTest method deleteCloudFormationStack.
@Test
public void deleteCloudFormationStack() throws Exception {
WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest");
Mockito.when(this.awsLambda.listAliases(Mockito.eq(new ListAliasesRequest().withFunctionName("foo")))).thenReturn(new ListAliasesResult());
Mockito.when(this.awsLambda.listVersionsByFunction(Mockito.eq(new ListVersionsByFunctionRequest().withFunctionName("foo")))).thenReturn(new ListVersionsByFunctionResult().withVersions(Arrays.asList(new FunctionConfiguration().withVersion("v1").withLastModified(ZonedDateTime.now().format(DateTimeFormatter.ISO_ZONED_DATE_TIME)), new FunctionConfiguration().withVersion("v2").withLastModified("2018-02-05T11:15:12Z"))));
Mockito.when(this.awsLambda.listAliases(Mockito.eq(new ListAliasesRequest().withFunctionName("foo2")))).thenReturn(new ListAliasesResult());
Mockito.when(this.awsLambda.listVersionsByFunction(Mockito.eq(new ListVersionsByFunctionRequest().withFunctionName("foo2")))).thenReturn(new ListVersionsByFunctionResult().withVersions(Arrays.asList(new FunctionConfiguration().withVersion("v1").withLastModified(ZonedDateTime.now().format(DateTimeFormatter.ISO_ZONED_DATE_TIME)), new FunctionConfiguration().withVersion("v2").withLastModified("2018-02-05T11:15:12Z"))));
Mockito.when(this.cloudformation.listStackResources(new ListStackResourcesRequest().withStackName("baz"))).thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary().withResourceType("AWS::Lambda::Function").withPhysicalResourceId("foo"), new StackResourceSummary().withResourceType("AWS::Baz::Function").withPhysicalResourceId("bar")).withNextToken("foo"));
Mockito.when(this.cloudformation.listStackResources(new ListStackResourcesRequest().withStackName("baz").withNextToken("foo"))).thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary().withResourceType("AWS::Lambda::Function").withPhysicalResourceId("foo2"), new StackResourceSummary().withResourceType("AWS::Baz::Function").withPhysicalResourceId("bar")));
job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " lambdaVersionCleanup(stackName: 'baz', daysAgo: 5)\n" + "}\n", true));
this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0));
Mockito.verify(this.awsLambda).deleteFunction(new DeleteFunctionRequest().withQualifier("v2").withFunctionName("foo"));
Mockito.verify(this.awsLambda).deleteFunction(new DeleteFunctionRequest().withQualifier("v2").withFunctionName("foo2"));
Mockito.verify(this.awsLambda, Mockito.times(2)).listVersionsByFunction(Mockito.any());
Mockito.verify(this.awsLambda, Mockito.times(2)).listAliases(Mockito.any());
Mockito.verifyNoMoreInteractions(this.awsLambda);
}
use of com.amazonaws.services.cloudformation.model.StackResourceSummary in project cloudbreak by hortonworks.
the class AwsLaunchServiceLoadBalancerTest method testUpdateCloudformationWithLoadBalancerMissingTargetGroup.
@Test
public void testUpdateCloudformationWithLoadBalancerMissingTargetGroup() {
List<CloudResource> instances = createInstances();
AwsNetworkView awsNetworkView = createNetworkView(PRIVATE_ID_1, null);
Network network = createNetwork(PRIVATE_ID_1, null);
String expectedError = String.format("Could not create load balancer listeners: target group %s not found.", AwsTargetGroup.getTargetGroupName(PORT, AwsLoadBalancerScheme.INTERNAL));
Set<LoadBalancerType> types = Set.of(LoadBalancerType.PRIVATE);
List<StackResourceSummary> firstUpdateSummaries = createFirstUpdateSummaries(types);
firstUpdateSummaries.remove(TG_INDEX);
List<StackResourceSummary> secondUpdateSummaries = createFullSummaries(types);
setupMocksForUpdate(awsNetworkView, network, instances, types);
when(result.getStackResourceSummaries()).thenReturn(List.of()).thenReturn(firstUpdateSummaries).thenReturn(firstUpdateSummaries).thenReturn(secondUpdateSummaries);
CloudConnectorException exception = assertThrows(CloudConnectorException.class, () -> underTest.updateCloudformationWithLoadBalancers(ac, cloudStack, null, null));
verify(cfClient, times(1)).updateStack(any());
verify(result, times(2)).getStackResourceSummaries();
assertEquals(expectedError, exception.getMessage());
}
Aggregations