Search in sources :

Example 6 with ModelContext

use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext in project cloudbreak by hortonworks.

the class CloudFormationTemplateBuilderTest method buildTestWithRoleWithoutVPCAndIGWAndPublicIpOnLaunchAndInstanceProfile.

@Test
public void buildTestWithRoleWithoutVPCAndIGWAndPublicIpOnLaunchAndInstanceProfile() throws Exception {
    // GIVEN
    boolean existingVPC = false;
    boolean existingIGW = false;
    boolean mapPublicIpOnLaunch = false;
    boolean enableInstanceProfile = false;
    boolean instanceProfileAvailable = true;
    // WHEN
    modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(existingVPC).withExistingIGW(existingIGW).withExistingSubnetCidr(Lists.newArrayList(existingSubnetCidr)).mapPublicIpOnLaunch(mapPublicIpOnLaunch).withEnableInstanceProfile(enableInstanceProfile).withInstanceProfileAvailable(instanceProfileAvailable).withTemplate(awsCloudFormationTemplate);
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    String templateString = cloudFormationTemplateBuilder.build(modelContext);
    // THEN
    assertThat(templateString, containsString("InstanceProfile"));
    assertThat(templateString, not(containsString("VPCId")));
    assertThat(templateString, not(containsString("SubnetCIDR")));
    assertThat(templateString, containsString("SubnetId"));
    assertThat(templateString, containsString("SubnetConfig"));
    assertThat(templateString, containsString("\"AttachGateway\""));
    assertThat(templateString, containsString("\"InternetGateway\""));
    assertThat(templateString, containsString("AvailabilitySet"));
    assertThat(templateString, not(containsString("EIP")));
}
Also used : ModelContext(com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 7 with ModelContext

use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext in project cloudbreak by hortonworks.

the class CloudFormationTemplateBuilderTest method buildTestWithVPCAndIGWAndInstanceProfileWithoutPublicIpOnLaunchAndRole.

@Test
public void buildTestWithVPCAndIGWAndInstanceProfileWithoutPublicIpOnLaunchAndRole() throws Exception {
    // GIVEN
    boolean existingVPC = true;
    boolean existingIGW = true;
    boolean mapPublicIpOnLaunch = false;
    boolean enableInstanceProfile = true;
    boolean instanceProfileAvailable = false;
    // WHEN
    modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(existingVPC).withExistingIGW(existingIGW).withExistingSubnetCidr(Lists.newArrayList(existingSubnetCidr)).mapPublicIpOnLaunch(mapPublicIpOnLaunch).withEnableInstanceProfile(enableInstanceProfile).withInstanceProfileAvailable(instanceProfileAvailable).withTemplate(awsCloudFormationTemplate);
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    String templateString = cloudFormationTemplateBuilder.build(modelContext);
    // THEN
    assertThat(templateString, containsString("InstanceProfile"));
    assertThat(templateString, containsString("VPCId"));
    assertThat(templateString, not(containsString("SubnetCIDR")));
    assertThat(templateString, containsString("SubnetId"));
    assertThat(templateString, not(containsString("SubnetConfig")));
    assertThat(templateString, not(containsString("\"AttachGateway\"")));
    assertThat(templateString, not(containsString("\"InternetGateway\"")));
    assertThat(templateString, containsString("AvailabilitySet"));
    assertThat(templateString, not(containsString("EIP")));
}
Also used : ModelContext(com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 8 with ModelContext

use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext in project cloudbreak by hortonworks.

the class CloudFormationTemplateBuilderTest method buildTestWithVPCAndIGWAndPublicIpOnLaunchAndInstanceProfileWithoutRole.

@Test
public void buildTestWithVPCAndIGWAndPublicIpOnLaunchAndInstanceProfileWithoutRole() throws Exception {
    // GIVEN
    boolean existingVPC = true;
    boolean existingIGW = true;
    boolean mapPublicIpOnLaunch = true;
    boolean enableInstanceProfile = true;
    boolean instanceProfileAvailable = false;
    // WHEN
    modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(existingVPC).withExistingIGW(existingIGW).withExistingSubnetCidr(Lists.newArrayList(existingSubnetCidr)).mapPublicIpOnLaunch(mapPublicIpOnLaunch).withEnableInstanceProfile(enableInstanceProfile).withInstanceProfileAvailable(instanceProfileAvailable).withTemplate(awsCloudFormationTemplate);
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    String templateString = cloudFormationTemplateBuilder.build(modelContext);
    // THEN
    assertThat(templateString, containsString("InstanceProfile"));
    assertThat(templateString, containsString("VPCId"));
    assertThat(templateString, not(containsString("SubnetCIDR")));
    assertThat(templateString, containsString("SubnetId"));
    assertThat(templateString, not(containsString("SubnetConfig")));
    assertThat(templateString, not(containsString("\"AttachGateway\"")));
    assertThat(templateString, not(containsString("\"InternetGateway\"")));
    assertThat(templateString, containsString("AvailabilitySet"));
    assertThat(templateString, containsString("EIP"));
}
Also used : ModelContext(com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 9 with ModelContext

use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext in project cloudbreak by hortonworks.

the class CloudFormationTemplateBuilderTest method buildTestWithVPCAndIGWAndPublicIpOnLaunchWithoutInstanceProfileAndRole.

@Test
public void buildTestWithVPCAndIGWAndPublicIpOnLaunchWithoutInstanceProfileAndRole() throws Exception {
    // GIVEN
    boolean existingVPC = true;
    boolean existingIGW = true;
    boolean mapPublicIpOnLaunch = true;
    boolean enableInstanceProfile = false;
    boolean instanceProfileAvailable = false;
    // WHEN
    modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(existingVPC).withExistingIGW(existingIGW).withExistingSubnetCidr(Lists.newArrayList(existingSubnetCidr)).mapPublicIpOnLaunch(mapPublicIpOnLaunch).withEnableInstanceProfile(enableInstanceProfile).withInstanceProfileAvailable(instanceProfileAvailable).withTemplate(awsCloudFormationTemplate);
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    String templateString = cloudFormationTemplateBuilder.build(modelContext);
    // THEN
    assertThat(templateString, not(containsString("InstanceProfile")));
    assertThat(templateString, containsString("VPCId"));
    assertThat(templateString, not(containsString("SubnetCIDR")));
    assertThat(templateString, containsString("SubnetId"));
    assertThat(templateString, not(containsString("SubnetConfig")));
    assertThat(templateString, not(containsString("\"AttachGateway\"")));
    assertThat(templateString, not(containsString("\"InternetGateway\"")));
    assertThat(templateString, containsString("AvailabilitySet"));
    assertThat(templateString, containsString("EIP"));
}
Also used : ModelContext(com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 10 with ModelContext

use of com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext in project cloudbreak by hortonworks.

the class CloudFormationTemplateBuilderTest method buildTestWithVPCAndInstanceProfileAndRoleWithoutIGWAndPublicIpOnLaunch.

@Test
public void buildTestWithVPCAndInstanceProfileAndRoleWithoutIGWAndPublicIpOnLaunch() throws Exception {
    // GIVEN
    boolean existingVPC = true;
    boolean existingIGW = false;
    boolean mapPublicIpOnLaunch = false;
    boolean enableInstanceProfile = true;
    boolean instanceProfileAvailable = true;
    // WHEN
    modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(existingVPC).withExistingIGW(existingIGW).withExistingSubnetCidr(Lists.newArrayList(existingSubnetCidr)).mapPublicIpOnLaunch(mapPublicIpOnLaunch).withEnableInstanceProfile(enableInstanceProfile).withInstanceProfileAvailable(instanceProfileAvailable).withTemplate(awsCloudFormationTemplate);
    when(defaultCostTaggingService.prepareAllTagsForTemplate()).thenReturn(defaultTags);
    String templateString = cloudFormationTemplateBuilder.build(modelContext);
    // THEN
    assertThat(templateString, containsString("InstanceProfile"));
    assertThat(templateString, containsString("VPCId"));
    assertThat(templateString, not(containsString("SubnetCIDR")));
    assertThat(templateString, containsString("SubnetId"));
    assertThat(templateString, not(containsString("SubnetConfig")));
    assertThat(templateString, not(containsString("\"AttachGateway\"")));
    assertThat(templateString, not(containsString("\"InternetGateway\"")));
    assertThat(templateString, containsString("AvailabilitySet"));
    assertThat(templateString, not(containsString("EIP")));
}
Also used : ModelContext(com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

ModelContext (com.sequenceiq.cloudbreak.cloud.aws.CloudFormationTemplateBuilder.ModelContext)18 Matchers.containsString (org.hamcrest.Matchers.containsString)17 Test (org.junit.Test)17 AmazonServiceException (com.amazonaws.AmazonServiceException)1 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)1 AmazonCloudFormationClient (com.amazonaws.services.cloudformation.AmazonCloudFormationClient)1 DescribeStacksRequest (com.amazonaws.services.cloudformation.model.DescribeStacksRequest)1 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)1 AwsInstanceProfileView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsInstanceProfileView)1 AwsNetworkView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsNetworkView)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 Builder (com.sequenceiq.cloudbreak.cloud.model.CloudResource.Builder)1