use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner in project rest.li by linkedin.
the class TestLoadBalancerPerformanceSimulation method buildRelativeRunnerWithDifferentLatency.
private LoadBalancerStrategyTestRunner buildRelativeRunnerWithDifferentLatency(double relativeLatencyHighThresholdFactor) {
int minBaseLatency = 100;
int baseLatencyDiff = 20;
int numHosts = 10;
double hostLinearFactor = 0.05;
List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
for (int i = 0; i < numHosts; i++) {
long baseLatency = i * baseLatencyDiff + minBaseLatency;
latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> baseLatency + (long) (hostLinearFactor * requestsPerInterval));
}
D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyHighThresholdFactor(relativeLatencyHighThresholdFactor);
return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(10000).setNumIntervals(100).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner in project rest.li by linkedin.
the class TestLoadBalancerPerformanceSimulation method testHostRecoveringToHealthyWithHigherLatency.
@Test(dataProvider = "relativeLatencyLowThresholdFactor")
public void testHostRecoveringToHealthyWithHigherLatency(double relativeLatencyLowThresholdFactor, int numHosts) {
LoadBalancerStrategyTestRunner testRunner = buildDefaultRunnerWithRecoveringBadHost(numHosts, HOST_BECOMING_HEALTHY_HIGHER_LATENCY, relativeLatencyLowThresholdFactor);
testRunner.runWait();
Map<URI, Integer> pointsMap = testRunner.getPoints();
if (relativeLatencyLowThresholdFactor <= 1.2) {
assertEquals(pointsMap.get(testRunner.getUri(0)).intValue(), UNHEALTHY_POINTS);
} else {
assertEquals(pointsMap.get(testRunner.getUri(0)).intValue(), HEALTHY_POINTS);
}
}
use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner in project rest.li by linkedin.
the class TestLoadBalancerPerformanceSimulation method buildDefaultRunnerWithRecoveringBadHost.
private LoadBalancerStrategyTestRunner buildDefaultRunnerWithRecoveringBadHost(int numHosts, LatencyCorrelation recoveringHostLatencyCorrelation, double relativeLatencyLowThresholdFactor) {
List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
latencyCorrelationList.add(recoveringHostLatencyCorrelation);
for (int i = 0; i < numHosts - 1; i++) {
latencyCorrelationList.add(HEALTHY_HOST_LATENCY_CORRELATION);
}
D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyLowThresholdFactor(relativeLatencyLowThresholdFactor).setRelativeLatencyHighThresholdFactor(1.5);
return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(DEFAULT_REQUESTS_PER_INTERVAL).setNumIntervals(200).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
use of com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner in project rest.li by linkedin.
the class TestLoadBalancerPerformanceSimulation method testOneConstantModerateBadHostInStagingCluster.
/**
* Based on this simulation, when the cluster is extremely small, highThresholdFactor = 1.4 and above may consider an unhealthy host as healthy
*/
@Test(dataProvider = "relativeLatencyHighThresholdFactor")
public void testOneConstantModerateBadHostInStagingCluster(double relativeLatencyHighThresholdFactor, int numHosts) {
LoadBalancerStrategyTestRunner testRunner = buildDefaultRunnerWithConstantBadHost(numHosts, MODERATE_BAD_LATENCY, relativeLatencyHighThresholdFactor);
testRunner.runWait();
Map<URI, Integer> pointsMap = testRunner.getPoints();
if (relativeLatencyHighThresholdFactor >= 1.4 && numHosts <= STAGING_CLUSTER_HOST_NUM) {
assertEquals(pointsMap.get(testRunner.getUri(0)).intValue(), HEALTHY_POINTS);
} else {
assertEquals(pointsMap.get(testRunner.getUri(0)).intValue(), UNHEALTHY_POINTS);
}
}
Aggregations