use of com.linkedin.d2.DarkClusterConfig in project rest.li by linkedin.
the class DarkClustersConverterTest method testEntriesInClusterConfig.
@Test
public void testEntriesInClusterConfig() {
DarkClusterConfigMap configMap = new DarkClusterConfigMap();
DarkClusterStrategyNameArray multiplierStrategyTypeArray = new DarkClusterStrategyNameArray();
multiplierStrategyTypeArray.add(DarkClusterStrategyName.RELATIVE_TRAFFIC.RELATIVE_TRAFFIC);
D2TransportClientProperties transportClientProperties = new D2TransportClientProperties().setRequestTimeout(1000);
DarkClusterConfig config = new DarkClusterConfig().setDarkClusterStrategyPrioritizedList(multiplierStrategyTypeArray).setTransportClientProperties(transportClientProperties);
configMap.put(DARK_CLUSTER_KEY, config);
DarkClusterConfigMap expectedConfigMap = new DarkClusterConfigMap();
DarkClusterConfig expectedConfig = new DarkClusterConfig(config.data());
expectedConfig.setMultiplier(0);
expectedConfig.setDispatcherOutboundTargetRate(0);
expectedConfig.setDispatcherMaxRequestsToBuffer(1);
expectedConfig.setDispatcherBufferedRequestExpiryInSeconds(1);
expectedConfigMap.put(DARK_CLUSTER_KEY, expectedConfig);
DarkClusterConfigMap resultConfigMap = DarkClustersConverter.toConfig(DarkClustersConverter.toProperties(configMap));
Assert.assertEquals(resultConfigMap, expectedConfigMap);
// verify values are converted properly.
DarkClusterConfig darkClusterConfig = resultConfigMap.get(DARK_CLUSTER_KEY);
Assert.assertEquals(darkClusterConfig.getMultiplier(), DARK_CLUSTER_DEFAULT_MULTIPLIER, "unexpected multiplier");
Assert.assertEquals(darkClusterConfig.getDarkClusterStrategyPrioritizedList().size(), 1, "there should be one strategy");
Assert.assertEquals(darkClusterConfig.getDarkClusterStrategyPrioritizedList().get(0), DarkClusterStrategyName.RELATIVE_TRAFFIC, "expected RELATIVE_TRAFFIC strategy");
Assert.assertTrue(darkClusterConfig.hasTransportClientProperties());
D2TransportClientProperties returnedTransportClientProperties = darkClusterConfig.getTransportClientProperties();
Assert.assertNotNull(returnedTransportClientProperties);
Assert.assertTrue(returnedTransportClientProperties.hasRequestTimeout());
Assert.assertEquals(Objects.requireNonNull(returnedTransportClientProperties.getRequestTimeout()).longValue(), 1000, "expected 1000 request Timeout");
}
Aggregations