Search in sources :

Example 31 with LoadBalancerStrategyTestRunner

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();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 32 with LoadBalancerStrategyTestRunner

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);
    }
}
Also used : LoadBalancerStrategyTestRunner(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 33 with LoadBalancerStrategyTestRunner

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();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 34 with LoadBalancerStrategyTestRunner

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);
    }
}
Also used : LoadBalancerStrategyTestRunner(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

LoadBalancerStrategyTestRunner (com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunner)27 Test (org.testng.annotations.Test)27 LoadBalancerStrategyTestRunnerBuilder (com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder)23 D2RelativeStrategyProperties (com.linkedin.d2.D2RelativeStrategyProperties)20 URI (java.net.URI)18 HashMap (java.util.HashMap)16 ArrayList (java.util.ArrayList)8 PartitionData (com.linkedin.d2.balancer.properties.PartitionData)5 LatencyCorrelation (com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation)5 D2QuarantineProperties (com.linkedin.d2.D2QuarantineProperties)4 com.linkedin.d2.loadBalancerStrategyType (com.linkedin.d2.loadBalancerStrategyType)3 List (java.util.List)3 Map (java.util.Map)3 Callback (com.linkedin.common.callback.Callback)2 None (com.linkedin.common.util.None)2 DegraderTrackerClientImpl (com.linkedin.d2.balancer.clients.DegraderTrackerClientImpl)2 TrackerClient (com.linkedin.d2.balancer.clients.TrackerClient)2 TrackerClientImpl (com.linkedin.d2.balancer.clients.TrackerClientImpl)2 RelativeStrategyPropertiesConverter (com.linkedin.d2.balancer.config.RelativeStrategyPropertiesConverter)2 PropertyKeys (com.linkedin.d2.balancer.properties.PropertyKeys)2