use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsLaunchServiceLoadBalancerTest method createSummaries.
private List<StackResourceSummary> createSummaries(Set<LoadBalancerType> types, boolean createLbAndTg, boolean creatListeners) {
List<StackResourceSummary> summaries = new ArrayList<>();
for (LoadBalancerType type : types) {
AwsLoadBalancerScheme scheme = LoadBalancerType.PRIVATE.equals(type) ? AwsLoadBalancerScheme.INTERNAL : AwsLoadBalancerScheme.INTERNET_FACING;
if (createLbAndTg) {
StackResourceSummary tgSummary = new StackResourceSummary();
tgSummary.setLogicalResourceId(AwsTargetGroup.getTargetGroupName(PORT, scheme));
tgSummary.setPhysicalResourceId(TARGET_GROUP_ARN);
tgSummary.setResourceStatus(ResourceStatus.CREATE_COMPLETE);
summaries.add(tgSummary);
StackResourceSummary lbSummary = new StackResourceSummary();
lbSummary.setLogicalResourceId(AwsLoadBalancer.getLoadBalancerName(scheme));
lbSummary.setPhysicalResourceId(LOAD_BALANCER_ARN);
lbSummary.setResourceStatus(ResourceStatus.CREATE_COMPLETE);
summaries.add(lbSummary);
}
if (creatListeners) {
StackResourceSummary lSummary = new StackResourceSummary();
lSummary.setLogicalResourceId(AwsListener.getListenerName(PORT, scheme));
lSummary.setResourceStatus(ResourceStatus.CREATE_COMPLETE);
summaries.add(lSummary);
}
}
return summaries;
}
use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorApiIntegrationTest method collectLoadBalancerMetadataWhenTheSpecifiedArnsDoNotExist.
@Test
void collectLoadBalancerMetadataWhenTheSpecifiedArnsDoNotExist() {
List<LoadBalancerType> loadbalancerTypes = List.of();
CloudResource aLoadBalancer = new CloudResource.Builder().name("aLoadBalancer").reference("arn:aws:elasticloadbalancing:eu-central-1:152813717728:loadbalancer/net/notexisting-LoadB-1MYWS0111IT2K/2e65a6e6b1a801df").type(ResourceType.ELASTIC_LOAD_BALANCER).build();
CloudResource secondLoadBalancer = new CloudResource.Builder().name("secondLoadBalancer").reference("arn:aws:elasticloadbalancing:eu-central-1:152813717728:loadbalancer/net/notexisting2-LoadB-1MYWS0111IT2K/2e65a6e6b1a801bf").type(ResourceType.ELASTIC_LOAD_BALANCER).build();
List<CloudResource> resources = List.of(aLoadBalancer, secondLoadBalancer);
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = underTest.collectLoadBalancer(authenticatedContext, loadbalancerTypes, resources);
assertTrue(cloudLoadBalancerMetadata.isEmpty());
}
use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenOneOfSpecifiedArnsDoNotExist.
@Test
void collectLoadBalancerMetadataWhenOneOfSpecifiedArnsDoNotExist() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("aCrn", "lbname", null, ELASTIC_LOAD_BALANCER);
CloudResource secondCloudResource = getCloudResource("secondCrn", "lbnamesecond", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource, secondCloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
LoadBalancerNotFoundException loadBalancerNotFoundException = new LoadBalancerNotFoundException("One or more elastic lb not found");
loadBalancerNotFoundException.setErrorCode(LOAD_BALANCER_NOT_FOUND_ERROR_CODE);
LoadBalancer loadBalancer = new LoadBalancer();
loadBalancer.setScheme(LoadBalancerSchemeEnum.Internal);
when(loadBalancingClient.describeLoadBalancers(any())).thenReturn(new DescribeLoadBalancersResult().withLoadBalancers(loadBalancer)).thenThrow(loadBalancerNotFoundException);
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources);
verify(loadBalancingClient, times(2)).describeLoadBalancers(any());
assertFalse(cloudLoadBalancerMetadata.isEmpty());
}
use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenTheSpecifiedArnsDoNotExist.
@Test
void collectLoadBalancerMetadataWhenTheSpecifiedArnsDoNotExist() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("secondCrn", "secondInstanceName", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
LoadBalancerNotFoundException loadBalancerNotFoundException = new LoadBalancerNotFoundException("One or more elastic lb not found");
loadBalancerNotFoundException.setErrorCode(LOAD_BALANCER_NOT_FOUND_ERROR_CODE);
when(loadBalancingClient.describeLoadBalancers(any())).thenThrow(loadBalancerNotFoundException);
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources);
verify(loadBalancingClient, times(1)).describeLoadBalancers(any());
Assertions.assertTrue(cloudLoadBalancerMetadata.isEmpty());
}
use of com.sequenceiq.common.api.type.LoadBalancerType in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenTheSpecifiedArnsExists.
@Test
void collectLoadBalancerMetadataWhenTheSpecifiedArnsExists() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("aCrn", "lbname", null, ELASTIC_LOAD_BALANCER);
CloudResource secondCloudResource = getCloudResource("secondCrn", "lbnamesecond", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource, secondCloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
LoadBalancer loadBalancer = new LoadBalancer();
loadBalancer.setScheme(LoadBalancerSchemeEnum.Internal);
when(loadBalancingClient.describeLoadBalancers(any())).thenReturn(new DescribeLoadBalancersResult().withLoadBalancers(loadBalancer));
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources);
verify(loadBalancingClient, times(2)).describeLoadBalancers(any());
assertFalse(cloudLoadBalancerMetadata.isEmpty());
assertEquals(cloudResources.size(), cloudLoadBalancerMetadata.size());
}
Aggregations