|
|
|
@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
|
|
|
|
|
import org.junit.Assert; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
public class LowerWeightRoundRobinTest { |
|
|
|
|
|
|
|
|
@ -35,20 +35,20 @@ public class LowerWeightRoundRobinTest {
|
|
|
|
|
LowerWeightRoundRobin roundRobin = new LowerWeightRoundRobin(); |
|
|
|
|
HostWeight result; |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.3", result.getHost().getIp()); |
|
|
|
|
Assert.assertEquals("192.158.2.3", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.3", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.3", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -62,15 +62,15 @@ public class LowerWeightRoundRobinTest {
|
|
|
|
|
LowerWeightRoundRobin roundRobin = new LowerWeightRoundRobin(); |
|
|
|
|
HostWeight result; |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.4", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.4", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.2", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.2", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.4", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.4", result.getHost().getIp()); |
|
|
|
|
result = roundRobin.select(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -79,12 +79,12 @@ public class LowerWeightRoundRobinTest {
|
|
|
|
|
LowerWeightRoundRobin roundRobin = new LowerWeightRoundRobin(); |
|
|
|
|
HostWeight result; |
|
|
|
|
result = roundRobin.doSelect(sources); |
|
|
|
|
Assert.assertEquals(null, result); |
|
|
|
|
Assertions.assertNull(result); |
|
|
|
|
|
|
|
|
|
sources.add(new HostWeight(HostWorker.of("192.158.2.1:11", 100, "default"), 0.06, 0.44, 3.14, 1, System.currentTimeMillis() - 60 * 8 * 1000)); |
|
|
|
|
sources.add(new HostWeight(HostWorker.of("192.158.2.2:22", 100, "default"), 0.06, 0.56, 3.24, 2, System.currentTimeMillis() - 60 * 5 * 1000)); |
|
|
|
|
sources.add(new HostWeight(HostWorker.of("192.158.2.3:33", 100, "default"), 0.06, 0.80, 3.15, 1, System.currentTimeMillis() - 60 * 2 * 1000)); |
|
|
|
|
result = roundRobin.doSelect(sources); |
|
|
|
|
Assert.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
Assertions.assertEquals("192.158.2.1", result.getHost().getIp()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|