use of com.netflix.titus.api.loadbalancer.service.LoadBalancerException 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.netflix.titus.api.loadbalancer.service.LoadBalancerException in project titus-control-plane by Netflix.
the class DefaultLoadBalancerJobValidatorTest method testValidateMaxLoadBalancers.
@Test
public void testValidateMaxLoadBalancers() throws Exception {
when(jobOperations.getJob(JOB_ID)).thenReturn(Optional.of(Job.<ServiceJobExt>newBuilder().withId(JOB_ID).withStatus(JobStatus.newBuilder().withState(JobState.Accepted).build()).withJobDescriptor(JobDescriptor.<ServiceJobExt>newBuilder().withExtensions(ServiceJobExt.newBuilder().build()).withContainer(Container.newBuilder().withImage(Image.newBuilder().build()).withContainerResources(ContainerResources.newBuilder().withAllocateIP(true).build()).build()).build()).build()));
when(loadBalancerValidationConfiguration.getMaxLoadBalancersPerJob()).thenReturn(30);
for (int i = 0; i < loadBalancerValidationConfiguration.getMaxLoadBalancersPerJob() + 1; i++) {
loadBalancerStore.addOrUpdateLoadBalancer(new JobLoadBalancer(JOB_ID, "LoadBalancer-" + i), JobLoadBalancer.State.ASSOCIATED).await(TIMEOUT_MS, TimeUnit.MILLISECONDS);
}
Throwable thrown = catchThrowable(() -> loadBalancerValidator.validateJobId(JOB_ID));
assertThat(thrown).isInstanceOf(LoadBalancerException.class);
assertThat(((LoadBalancerException) thrown).getErrorCode()).isEqualTo(LoadBalancerException.ErrorCode.JobMaxLoadBalancers);
}
Aggregations