use of com.linkedin.d2.balancer.clients.TestClient in project rest.li by linkedin.
the class DegraderTrackerClientTest method testDoNotSlowStartWhenTrue.
@Test
public void testDoNotSlowStartWhenTrue() {
Map<Integer, PartitionData> partitionDataMap = createDefaultPartitionData(1d);
DegraderImpl.Config config = new DegraderImpl.Config();
double initialDropRate = 0.99d;
config.setInitialDropRate(initialDropRate);
DegraderTrackerClient client = new DegraderTrackerClientImpl(URI.create("http://test.qa.com:1234/foo"), partitionDataMap, new TestClient(), new SettableClock(), config, DegraderLoadBalancerStrategyConfig.DEFAULT_UPDATE_INTERVAL_MS, TrackerClientImpl.DEFAULT_ERROR_STATUS_PATTERN, true);
DegraderControl degraderControl = client.getDegraderControl(DefaultPartitionAccessor.DEFAULT_PARTITION_ID);
Assert.assertEquals(degraderControl.getInitialDropRate(), DegraderImpl.DEFAULT_DO_NOT_SLOW_START_INITIAL_DROP_RATE, "Initial drop rate in config should have been overridden by doNotSlowStart uri property.");
}
use of com.linkedin.d2.balancer.clients.TestClient in project rest.li by linkedin.
the class DynamicClientTest method testClient.
@Test(groups = { "small", "back-end" }, dataProvider = "restOverStreamSwitch")
@SuppressWarnings("deprecation")
public void testClient(boolean restOverStream) throws URISyntaxException {
LoadBalancerMock balancer = new LoadBalancerMock(false);
DirectoryProvider dirProvider = new DirectoryProviderMock();
KeyMapperProvider keyMapperProvider = new KeyMapperProviderMock();
ClientFactoryProvider clientFactoryProvider = Mockito.mock(ClientFactoryProvider.class);
Facilities facilities = new DelegatingFacilities(dirProvider, keyMapperProvider, clientFactoryProvider);
DynamicClient client = new DynamicClient(balancer, facilities, restOverStream);
URI uri = URI.create("d2://test");
RestRequest restRequest = new RestRequestBuilder(uri).build();
TestCallback<RestResponse> restCallback = new TestCallback<>();
client.restRequest(restRequest, restCallback);
assertNull(restCallback.e);
assertNotNull(restCallback.t);
Facilities myFacilities = client.getFacilities();
assertNotNull(facilities, "facilities should not be null");
}
use of com.linkedin.d2.balancer.clients.TestClient in project rest.li by linkedin.
the class RewriteLoadBalancerClientTestStreamRequest method testPathAppend.
@Test
public void testPathAppend() {
URI uri = URI.create("http://test.linkedin.com:9876/test");
String serviceName = "HistoryService";
TestClient wrappedClient = new TestClient();
RewriteLoadBalancerClient client = new RewriteLoadBalancerClient(serviceName, uri, wrappedClient);
assertEquals(client.getUri(), uri);
assertEquals(client.getServiceName(), serviceName);
StreamRequest streamRequest;
Map<String, String> restWireAttrs = new HashMap<>();
TestTransportCallback<StreamResponse> restCallback = new TestTransportCallback<>();
streamRequest = getRequest("d2://HistoryService");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test");
streamRequest = getRequest("d2://HistoryService/");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/");
streamRequest = getRequest("d2://HistoryService//");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test//");
streamRequest = getRequest("d2://HistoryService/foo");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/foo");
streamRequest = getRequest("d2://HistoryService/foo/");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/foo/");
}
Aggregations