use of com.linkedin.d2.balancer.LoadBalancerTestState in project rest.li by linkedin.
the class SimpleLoadBalancerTest method testLoadBalancerWithWait.
@Test(groups = { "small", "back-end" })
public void testLoadBalancerWithWait() throws URISyntaxException, ServiceUnavailableException, InterruptedException {
URIRequest uriRequest = new URIRequest("d2://NonExistentService");
LoadBalancerTestState state = new LoadBalancerTestState();
SimpleLoadBalancer balancer = new SimpleLoadBalancer(state, 5, TimeUnit.SECONDS);
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.listenToService = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.isListeningToService = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.getServiceProperties = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.listenToCluster = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.isListeningToCluster = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.getClusterProperties = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.getUriProperties = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.getClient = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.getStrategy = true;
try {
balancer.getClient(uriRequest, new RequestContext());
fail("should have received a service unavailable exception");
} catch (ServiceUnavailableException e) {
}
state.getPartitionAccessor = true;
// victory
assertNotNull(balancer.getClient(uriRequest, new RequestContext()));
}
Aggregations