[core] Java worker should respect the user provided node_ip_address (#13732)

This commit is contained in:
Xianyang Liu
2021-02-08 11:59:06 +08:00
committed by GitHub
parent 7231b6b91c
commit 918ad84f08
2 changed files with 53 additions and 1 deletions
@@ -0,0 +1,46 @@
package io.ray.test;
import io.ray.api.Ray;
import org.apache.commons.lang3.SystemUtils;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = {"cluster"})
public class NodeIpTest extends BaseTest {
private static final String NODE_IP = "127.0.0.2";
@BeforeClass
public void setUp() {
if (SystemUtils.IS_OS_MAC) {
throw new SkipException("Skip NodeIpTest on Mac OS");
}
System.setProperty("ray.head-args.0", "--node-ip-address=127.0.0.2");
System.setProperty("ray.node-ip", "127.0.0.2");
}
@AfterClass
public void tearDown() {
if (!SystemUtils.IS_OS_MAC) {
System.clearProperty("ray.head-args.0");
System.clearProperty("ray.node-ip");
}
}
static String getNodeIp() {
return TestUtils.getRuntime().getRayConfig().nodeIp;
}
public void testNodeIp() {
// this is on the driver node, and it should be equal with ray.node-ip
String nodeIP = TestUtils.getRuntime().getRayConfig().nodeIp;
Assert.assertEquals(nodeIP, NODE_IP);
// this is on the worker node, and it should be equal with node-ip-address
nodeIP = Ray.task(NodeIpTest::getNodeIp).remote().get();
Assert.assertEquals(nodeIP, NODE_IP);
}
}