Search in sources :

Example 6 with DefaultDarkClusterDispatcher

use of com.linkedin.darkcluster.impl.DefaultDarkClusterDispatcher in project rest.li by linkedin.

the class TestBaseDarkClusterDispatcher method testBaseDispatcher.

@Test(dataProvider = "provideKeys")
public void testBaseDispatcher(int numDuplicates, boolean failRequests, boolean requestSent, int expectedSuccessCount, int expectedRequestCount, int expectedExceptionCount) {
    DarkClusterDispatcher darkClusterDispatcher = new DefaultDarkClusterDispatcher(new MockClient(failRequests));
    BaseDarkClusterDispatcherImpl baseDispatcher = new BaseDarkClusterDispatcherImpl(DARK_CLUSTER_NAME, darkClusterDispatcher, new DoNothingNotifier(), new CountingVerifierManager());
    RestRequest dummyRestRequest = new RestRequestBuilder(URI.create("foo")).build();
    boolean result = baseDispatcher.sendRequest(dummyRestRequest, dummyRestRequest, new RequestContext(), numDuplicates);
    Assert.assertEquals(result, requestSent, "expected: " + requestSent);
    Assert.assertEquals(baseDispatcher.getSuccessCount(), expectedSuccessCount, "unexpected successCount");
    Assert.assertEquals(baseDispatcher.getRequestCount(), expectedRequestCount, "unexpected requestCount");
    Assert.assertEquals(baseDispatcher.getExceptionCount(), expectedExceptionCount, "unexpected exceptionCount");
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) DefaultDarkClusterDispatcher(com.linkedin.darkcluster.impl.DefaultDarkClusterDispatcher) DarkClusterDispatcher(com.linkedin.darkcluster.api.DarkClusterDispatcher) DefaultDarkClusterDispatcher(com.linkedin.darkcluster.impl.DefaultDarkClusterDispatcher) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) RequestContext(com.linkedin.r2.message.RequestContext) BaseDarkClusterDispatcherImpl(com.linkedin.darkcluster.impl.BaseDarkClusterDispatcherImpl) Test(org.testng.annotations.Test)

Aggregations

DefaultDarkClusterDispatcher (com.linkedin.darkcluster.impl.DefaultDarkClusterDispatcher)6 DarkClusterDispatcher (com.linkedin.darkcluster.api.DarkClusterDispatcher)5 BaseDarkClusterDispatcherImpl (com.linkedin.darkcluster.impl.BaseDarkClusterDispatcherImpl)4 RequestContext (com.linkedin.r2.message.RequestContext)4 RestRequest (com.linkedin.r2.message.rest.RestRequest)4 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)4 Test (org.testng.annotations.Test)4 Random (java.util.Random)3 DarkClusterStrategyFactoryImpl (com.linkedin.darkcluster.impl.DarkClusterStrategyFactoryImpl)2 ConstantQpsRateLimiter (com.linkedin.r2.transport.http.client.ConstantQpsRateLimiter)2 ClockedExecutor (com.linkedin.test.util.ClockedExecutor)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 DarkClusterConfig (com.linkedin.d2.DarkClusterConfig)1 Facilities (com.linkedin.d2.balancer.Facilities)1 LoadBalancerTestState (com.linkedin.d2.balancer.LoadBalancerTestState)1 SimpleLoadBalancer (com.linkedin.d2.balancer.simple.SimpleLoadBalancer)1 DarkClusterManager (com.linkedin.darkcluster.api.DarkClusterManager)1 DarkClusterStrategy (com.linkedin.darkcluster.api.DarkClusterStrategy)1 DarkClusterFilter (com.linkedin.darkcluster.filter.DarkClusterFilter)1 ConstantQpsDarkClusterStrategy (com.linkedin.darkcluster.impl.ConstantQpsDarkClusterStrategy)1