mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 06:30:33 +08:00
[Java] Generate head redis port randomly (#6879)
* Random head port * address comments.
This commit is contained in:
@@ -7,6 +7,8 @@ import org.testng.annotations.Test;
|
||||
|
||||
public class RayConfigTest {
|
||||
|
||||
public final static int NUM_RETRIES = 5;
|
||||
|
||||
@Test
|
||||
public void testCreateRayConfig() {
|
||||
try {
|
||||
@@ -18,6 +20,27 @@ public class RayConfigTest {
|
||||
// Unset system properties.
|
||||
System.clearProperty("ray.job.resource-path");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateHeadPortRandomly() {
|
||||
boolean isSame = true;
|
||||
final int port1 = RayConfig.create().headRedisPort;
|
||||
// If we the 2 ports are the same, let's retry.
|
||||
// This is used to avoid any flaky chance.
|
||||
for (int i = 0; i < NUM_RETRIES; ++i) {
|
||||
final int port2 = RayConfig.create().headRedisPort;
|
||||
if (port1 != port2) {
|
||||
isSame = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertFalse(isSame);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecifyHeadPort() {
|
||||
System.setProperty("ray.redis.head-port", "11111");
|
||||
Assert.assertEquals(RayConfig.create().headRedisPort, 11111);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user