use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverter method convert.
public LoadBalancerResponse convert(LoadBalancer source) {
LoadBalancerResponse response = new LoadBalancerResponse();
response.setIp(source.getIp());
response.setCloudDns(source.getDns());
response.setFqdn(source.getFqdn());
response.setType(source.getType());
response.setTargets(convertTargetGroups(targetGroupService.findByLoadBalancerId(source.getId())));
if (source.getProviderConfig() != null) {
response.setAwsResourceId(convertAwsLoadBalancer(source.getProviderConfig().getAwsConfig()));
response.setAzureResourceId(convertAzureLoadBalancer(source.getProviderConfig().getAzureConfig()));
response.setGcpResourceId(convertGcpLoadBalancer(source.getProviderConfig().getGcpConfig()));
}
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method testNoSavedCloudConfig.
@Test
public void testNoSavedCloudConfig() {
LoadBalancer source = getSource();
// GIVEN
given(targetGroupService.findByLoadBalancerId(any())).willReturn(createAwsTargetGroups());
// WHEN
LoadBalancerResponse response = underTest.convert(source);
// THEN
assertAllFieldsNotNull(response, List.of("awsResourceId", "azureResourceId", "gcpResourceId"));
assertNull(response.getAwsResourceId());
assertNull(response.getAzureResourceId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertAws.
@Test
public void testConvertAws() {
LoadBalancer source = getSource();
// GIVEN
getSource().setProviderConfig(createAwsLoadBalancerConfig());
given(targetGroupService.findByLoadBalancerId(any())).willReturn(createAwsTargetGroups());
// WHEN
LoadBalancerResponse response = underTest.convert(source);
// THEN
assertAllFieldsNotNull(response, List.of("azureResourceId", "gcpResourceId"));
assertEquals(LB_ARN, response.getAwsResourceId().getArn());
assertEquals(1, response.getTargets().size());
TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
assertEquals(PORT, targetGroupResponse.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
AwsTargetGroupResponse awsTargetGroupResponse = targetGroupResponse.getAwsResourceIds();
assertNotNull(awsTargetGroupResponse);
assertEquals(LISTENER_ARN, awsTargetGroupResponse.getListenerArn());
assertEquals(TG_ARN, awsTargetGroupResponse.getTargetGroupArn());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertAzure.
@Test
public void testConvertAzure() {
LoadBalancer source = getSource();
// GIVEN
getSource().setProviderConfig(createAzureLoadBalancerConfig());
given(targetGroupService.findByLoadBalancerId(any())).willReturn(createAzureTargetGroups());
// WHEN
LoadBalancerResponse response = underTest.convert(source);
// THEN
assertAllFieldsNotNull(response, List.of("awsResourceId", "gcpResourceId"));
assertEquals(AZURE_LB_NAME, response.getAzureResourceId().getName());
assertEquals(1, response.getTargets().size());
TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
assertEquals(PORT, targetGroupResponse.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
AzureTargetGroupResponse azureTargetGroupResponse = targetGroupResponse.getAzureResourceId();
assertNotNull(azureTargetGroupResponse);
assertEquals(List.of(AZURE_AS_NAME), azureTargetGroupResponse.getAvailabilitySet());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertGcp.
@Test
public void testConvertGcp() {
LoadBalancer source = getSource();
// GIVEN
getSource().setProviderConfig(createGcpLoadBalancerConfig());
given(targetGroupService.findByLoadBalancerId(any())).willReturn(creatGcpTargetGroups());
// WHEN
LoadBalancerResponse response = underTest.convert(source);
// THEN
assertAllFieldsNotNull(response, List.of("awsResourceId", "azureResourceId"));
assertEquals(GCP_LB_NAME, response.getGcpResourceId().getName());
assertEquals(1, response.getTargets().size());
TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
assertEquals(PORT, targetGroupResponse.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
GcpTargetGroupResponse gcpTargetGroupResponse = targetGroupResponse.getGcpResourceId();
assertNotNull(gcpTargetGroupResponse);
assertEquals(GCP_INSTANCE_GROUP_NAME, gcpTargetGroupResponse.getGcpInstanceGroupName());
assertEquals(GCP_BACKEND_SERVICE_NAME, gcpTargetGroupResponse.getGcpBackendServiceName());
}
Aggregations