use of com.sequenceiq.cloudbreak.cloud.aws.common.loadbalancer.AwsLoadBalancer in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method testConvertLoadBalancerNewPrivate.
@Test
public void testConvertLoadBalancerNewPrivate() {
when(loadBalancerTypeConverter.convert(eq(LoadBalancerType.PRIVATE))).thenReturn(AwsLoadBalancerScheme.INTERNAL);
AwsLoadBalancer awsLoadBalancer = setupAndRunConvertLoadBalancer(List.of(), LoadBalancerType.PRIVATE, PRIVATE_ID_1);
assertNotNull(awsLoadBalancer);
assertEquals(AwsLoadBalancerScheme.INTERNAL, awsLoadBalancer.getScheme());
assertEquals(Set.of(PRIVATE_ID_1), awsLoadBalancer.getSubnetIds());
assertEquals(1, awsLoadBalancer.getListeners().size());
AwsListener listener = awsLoadBalancer.getListeners().get(0);
assertEquals(PORT, listener.getPort());
assertNotNull(listener.getTargetGroup());
AwsTargetGroup targetGroup = listener.getTargetGroup();
assertEquals(PORT, targetGroup.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroup.getInstanceIds());
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.loadbalancer.AwsLoadBalancer in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method testConvertLoadBalancerNewPublic.
@Test
public void testConvertLoadBalancerNewPublic() {
when(loadBalancerTypeConverter.convert(eq(LoadBalancerType.PUBLIC))).thenReturn(AwsLoadBalancerScheme.INTERNET_FACING);
AwsLoadBalancer awsLoadBalancer = setupAndRunConvertLoadBalancer(List.of(), LoadBalancerType.PUBLIC, PUBLIC_ID_1);
assertNotNull(awsLoadBalancer);
assertEquals(AwsLoadBalancerScheme.INTERNET_FACING, awsLoadBalancer.getScheme());
assertEquals(Set.of(PUBLIC_ID_1), awsLoadBalancer.getSubnetIds());
assertEquals(1, awsLoadBalancer.getListeners().size());
AwsListener listener = awsLoadBalancer.getListeners().get(0);
assertEquals(PORT, listener.getPort());
assertNotNull(listener.getTargetGroup());
AwsTargetGroup targetGroup = listener.getTargetGroup();
assertEquals(PORT, targetGroup.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroup.getInstanceIds());
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.loadbalancer.AwsLoadBalancer in project cloudbreak by hortonworks.
the class AwsLoadBalancerCommonServiceTest method testConvertLoadBalancerExistingPublic.
@Test
public void testConvertLoadBalancerExistingPublic() {
AwsLoadBalancer existingLoadBalancer = new AwsLoadBalancer(AwsLoadBalancerScheme.INTERNET_FACING);
when(loadBalancerTypeConverter.convert(eq(LoadBalancerType.PUBLIC))).thenReturn(AwsLoadBalancerScheme.INTERNET_FACING);
AwsLoadBalancer awsLoadBalancer = setupAndRunConvertLoadBalancer(List.of(existingLoadBalancer), LoadBalancerType.PUBLIC, PUBLIC_ID_1);
assertNotNull(awsLoadBalancer);
assertEquals(existingLoadBalancer, awsLoadBalancer);
assertEquals(AwsLoadBalancerScheme.INTERNET_FACING, awsLoadBalancer.getScheme());
assertEquals(Set.of(PUBLIC_ID_1), awsLoadBalancer.getSubnetIds());
assertEquals(1, awsLoadBalancer.getListeners().size());
AwsListener listener = awsLoadBalancer.getListeners().get(0);
assertEquals(PORT, listener.getPort());
assertNotNull(listener.getTargetGroup());
AwsTargetGroup targetGroup = listener.getTargetGroup();
assertEquals(PORT, targetGroup.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroup.getInstanceIds());
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.loadbalancer.AwsLoadBalancer in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestHealthCheckPortDifferentFromTrafficPort.
public void buildTestHealthCheckPortDifferentFromTrafficPort() {
// GIVEN
AwsLoadBalancer awsLoadBalancer = setupLoadBalancer(AwsLoadBalancerScheme.INTERNAL, 443, 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(List.of(awsLoadBalancer));
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("\"Port\" : 443").contains("\"HealthCheckPort\" : \"8443\"");
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.loadbalancer.AwsLoadBalancer in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestWithSingleLoadBalancerAfterUpdate.
@Test
public void buildTestWithSingleLoadBalancerAfterUpdate() {
// GIVEN
AwsLoadBalancer awsLoadBalancer = setupLoadBalancer(AwsLoadBalancerScheme.INTERNAL, 443, 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(List.of(awsLoadBalancer));
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\"");
assert templateString.contains("\"Targets\" : [{ \"Id\" : \"instance1-443\" },{ \"Id\" : \"instance2-443\" }]}}") || templateString.contains("\"Targets\" : [{ \"Id\" : \"instance2-443\" },{ \"Id\" : \"instance1-443\" }]}}");
}
Aggregations