use of com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingAsync in project titus-control-plane by Netflix.
the class AwsLoadBalancerConnectorTest method validateExceptionsAreUnmodifiedWithMockClientTest.
@Test
public void validateExceptionsAreUnmodifiedWithMockClientTest() {
Class defaultExceptionClass = TargetGroupAssociationLimitException.class;
TestSubscriber testSubscriber = new TestSubscriber();
AmazonElasticLoadBalancingAsync albClient = mock(AmazonElasticLoadBalancingAsync.class);
when(albClient.describeTargetHealthAsync(any(), any())).thenThrow(defaultExceptionClass);
awsLoadBalancerConnector = getAwsLoadBalancerConnector(albClient);
awsLoadBalancerConnector.getLoadBalancer(targetGroupWithTargets).subscribe(testSubscriber);
testSubscriber.awaitTerminalEvent();
List<Throwable> errors = testSubscriber.getOnErrorEvents();
assertEquals(1, errors.size());
Throwable throwable = errors.get(0);
assertFalse(throwable instanceof LoadBalancerException);
assertTrue(throwable instanceof TargetGroupAssociationLimitException);
}
use of com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingAsync in project titus-control-plane by Netflix.
the class AwsLoadBalancerConnectorTest method validateTargetGroupNotFoundExceptionIsTranslatedToRemovedState.
@Test
public void validateTargetGroupNotFoundExceptionIsTranslatedToRemovedState() {
TestSubscriber testSubscriber = new TestSubscriber();
AmazonElasticLoadBalancingAsync albClient = mock(AmazonElasticLoadBalancingAsync.class);
when(albClient.describeTargetHealthAsync(any(), any())).thenThrow(TargetGroupNotFoundException.class);
awsLoadBalancerConnector = getAwsLoadBalancerConnector(albClient);
awsLoadBalancerConnector.getLoadBalancer(targetGroupWithTargets).subscribe(testSubscriber);
testSubscriber.awaitTerminalEvent();
testSubscriber.assertNoErrors();
testSubscriber.assertValueCount(1);
LoadBalancer loadBalancer = (LoadBalancer) testSubscriber.getOnNextEvents().get(0);
assertEquals(targetGroupWithTargets, loadBalancer.getId());
assertEquals(LoadBalancer.State.REMOVED, loadBalancer.getState());
}
use of com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingAsync in project titus-control-plane by Netflix.
the class AwsLoadBalancerConnectorTest method setUp.
@Before
public void setUp() {
ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider();
AmazonElasticLoadBalancingAsync albClient = AmazonElasticLoadBalancingAsyncClientBuilder.standard().withCredentials(credentialsProvider).withRegion(REGION).build();
awsLoadBalancerConnector = getAwsLoadBalancerConnector(albClient);
}
use of com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingAsync in project titus-control-plane by Netflix.
the class AmazonClientProvider method getLoadBalancingClient.
public AmazonElasticLoadBalancingAsync getLoadBalancingClient(String accountId) {
AmazonElasticLoadBalancingAsync client = loadBalancerClients.get(accountId);
if (client == null) {
synchronized (this) {
client = loadBalancerClients.get(accountId);
if (client == null) {
String region = AwsRegionConfigurationUtil.resolveDataPlaneRegion(configuration);
AWSCredentialsProvider credentialsProvider = getAwsCredentialsProvider(accountId);
client = AmazonElasticLoadBalancingAsyncClientBuilder.standard().withCredentials(credentialsProvider).withRegion(region).withMetricsCollector(new SpectatorRequestMetricCollector(registry)).build();
loadBalancerClients.put(accountId, client);
}
}
}
return client;
}
Aggregations