use of com.linkedin.test.util.ClockedExecutor in project rest.li by linkedin.
the class RetryClientTest method testRestRetryUnlimitedClientRetryRatio.
@Test
public void testRestRetryUnlimitedClientRetryRatio() throws Exception {
SimpleLoadBalancer balancer = prepareLoadBalancer(Arrays.asList("http://test.linkedin.com/retry1", "http://test.linkedin.com/good"), HttpClientFactory.UNLIMITED_CLIENT_REQUEST_RETRY_RATIO);
ClockedExecutor clock = new ClockedExecutor();
DynamicClient dynamicClient = new DynamicClient(balancer, null);
RetryClient client = new RetryClient(dynamicClient, balancer, D2ClientConfig.DEFAULT_RETRY_LIMIT, RetryClient.DEFAULT_UPDATE_INTERVAL_MS, RetryClient.DEFAULT_AGGREGATED_INTERVAL_NUM, clock, true, false);
URI uri = URI.create("d2://retryService?arg1=empty&arg2=empty");
RestRequest restRequest = new RestRequestBuilder(uri).build();
clock.scheduleWithFixedDelay(() -> {
DegraderTrackerClientTest.TestCallback<RestResponse> restCallback = new DegraderTrackerClientTest.TestCallback<>();
client.restRequest(restRequest, restCallback);
// This request will be retried and route to the good host
assertNull(restCallback.e);
assertNotNull(restCallback.t);
}, 0, 100, TimeUnit.MILLISECONDS);
clock.runFor(RetryClient.DEFAULT_UPDATE_INTERVAL_MS * 2);
}
Aggregations