Search in sources :

Example 1 with LoadBalancerNotFoundException

use of com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException in project cloudbreak by hortonworks.

the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenWhenNotExpectedAmazonServiceExceptionOccurs.

@Test
void collectLoadBalancerMetadataWhenWhenNotExpectedAmazonServiceExceptionOccurs() {
    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");
    when(loadBalancingClient.describeLoadBalancers(any())).thenThrow(loadBalancerNotFoundException);
    CloudConnectorException cloudConnectorException = assertThrows(CloudConnectorException.class, () -> underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources));
    assertThat(cloudConnectorException).hasMessage("Metadata collection of load balancers failed");
    assertThat(cloudConnectorException).hasCauseReference(loadBalancerNotFoundException);
    verify(loadBalancingClient, times(1)).describeLoadBalancers(any());
}
Also used : LoadBalancerNotFoundException(com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Test(org.junit.jupiter.api.Test)

Example 2 with LoadBalancerNotFoundException

use of com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException 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());
}
Also used : DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersResult) LoadBalancerNotFoundException(com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException) LoadBalancer(com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancer) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.jupiter.api.Test)

Example 3 with LoadBalancerNotFoundException

use of com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException 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());
}
Also used : LoadBalancerNotFoundException(com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.jupiter.api.Test)

Aggregations

LoadBalancerNotFoundException (com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 LoadBalancerType (com.sequenceiq.common.api.type.LoadBalancerType)3 Test (org.junit.jupiter.api.Test)3 CloudLoadBalancerMetadata (com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata)2 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancingv2.model.DescribeLoadBalancersResult)1 LoadBalancer (com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancer)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1