use of com.sequenceiq.cloudbreak.common.json.JsonUtil in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestEbsEncryptionWithDefaultKey.
@Test
public void buildTestEbsEncryptionWithDefaultKey() {
// GIVEN
instance.getTemplate().putParameter(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED, true);
instance.getTemplate().putParameter(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.DEFAULT.name());
// WHEN
modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(true).withExistingIGW(true).withExistingSubnetCidr(singletonList(existingSubnetCidr)).withExistinVpcCidr(List.of(existingSubnetCidr)).mapPublicIpOnLaunch(true).withEnableInstanceProfile(true).withInstanceProfileAvailable(true).withOutboundInternetTraffic(OutboundInternetTraffic.ENABLED).withTemplate(awsCloudFormationTemplate);
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("\"Encrypted\"").contains("{ \"Ref\" : \"AMI\" }").contains("SecurityGroupIngress").doesNotContain("\"KmsKeyId\"");
}
use of com.sequenceiq.cloudbreak.common.json.JsonUtil in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestEfsNullFields.
@Test
public void buildTestEfsNullFields() {
// GIVEN
AwsEfsFileSystem awsEfsFileSystem = setupEfsFileSystemNullFields();
// WHEN
modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(true).withExistingIGW(true).withExistingSubnetCidr(singletonList(existingSubnetCidr)).withExistinVpcCidr(List.of(existingSubnetCidr)).mapPublicIpOnLaunch(true).withEnableInstanceProfile(true).withInstanceProfileAvailable(true).withOutboundInternetTraffic(OutboundInternetTraffic.ENABLED).withTemplate(awsCloudFormationTemplate).withEnableEfs(true).withEfsFileSystem(awsEfsFileSystem);
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("AWS::EFS::FileSystem").contains("\"Encrypted\" : \"true\"").contains("\"PerformanceMode\": \"generalPurpose\"").contains("\"ThroughputMode\": \"bursting\"");
}
use of com.sequenceiq.cloudbreak.common.json.JsonUtil in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestWithMultipleLoadBalancers.
@Test
public void buildTestWithMultipleLoadBalancers() {
// GIVEN
List<AwsLoadBalancer> awsLoadBalancers = List.of(setupLoadBalancer(AwsLoadBalancerScheme.INTERNAL, 443, true), setupLoadBalancer(AwsLoadBalancerScheme.INTERNET_FACING, 888, true));
// WHEN
modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(true).withExistingIGW(true).withExistingSubnetCidr(singletonList(existingSubnetCidr)).withExistinVpcCidr(List.of(existingSubnetCidr)).mapPublicIpOnLaunch(true).withEnableInstanceProfile(true).withInstanceProfileAvailable(true).withOutboundInternetTraffic(OutboundInternetTraffic.ENABLED).withTemplate(awsCloudFormationTemplate).withLoadBalancers(awsLoadBalancers);
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("\"LoadBalancerInternal\" : {\"Type\" : \"AWS::ElasticLoadBalancingV2::LoadBalancer\"").contains("\"Scheme\" : \"internal\"").contains("\"TargetGroupPort443Internal\" : {\"Type\" : \"AWS::ElasticLoadBalancingV2::TargetGroup\"").contains("\"ListenerPort443Internal\" : {\"Type\" : \"AWS::ElasticLoadBalancingV2::Listener\"").contains("\"LoadBalancerExternal\" : {\"Type\" : \"AWS::ElasticLoadBalancingV2::LoadBalancer\"").contains("\"Scheme\" : \"internet-facing\"").contains("\"TargetGroupPort888External\" : {\"Type\" : \"AWS::ElasticLoadBalancingV2::TargetGroup\"").contains("\"ListenerPort888External\" : {\"Type\" : \"AWS::ElasticLoadBalancingV2::Listener\"");
assert templateString.contains("\"Targets\" : [{ \"Id\" : \"instance1-443\" },{ \"Id\" : \"instance2-443\" }]}}") || templateString.contains("\"Targets\" : [{ \"Id\" : \"instance2-443\" },{ \"Id\" : \"instance1-443\" }]}}");
assert templateString.contains("\"Targets\" : [{ \"Id\" : \"instance1-888\" },{ \"Id\" : \"instance2-888\" }]}}") || templateString.contains("\"Targets\" : [{ \"Id\" : \"instance2-888\" },{ \"Id\" : \"instance1-888\" }]}}");
}
use of com.sequenceiq.cloudbreak.common.json.JsonUtil in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestEfsSetFields.
@Test
public void buildTestEfsSetFields() {
// GIVEN
AwsEfsFileSystem awsEfsFileSystem = setupEfsFileSystemValidSet();
// WHEN
modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(true).withExistingIGW(true).withExistingSubnetCidr(singletonList(existingSubnetCidr)).withExistinVpcCidr(List.of(existingSubnetCidr)).mapPublicIpOnLaunch(true).withEnableInstanceProfile(true).withInstanceProfileAvailable(true).withOutboundInternetTraffic(OutboundInternetTraffic.ENABLED).withTemplate(awsCloudFormationTemplate).withEnableEfs(true).withEfsFileSystem(awsEfsFileSystem);
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("AWS::EFS::FileSystem").contains("\"Encrypted\" : \"false\"").contains("\"PerformanceMode\": \"maxIO\"").contains("\"ThroughputMode\": \"provisioned\"");
}
Aggregations