mirror of
https://github.com/wassname/ray.git
synced 2026-07-06 05:16:30 +08:00
[core] Java worker should respect the user provided node_ip_address (#13732)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user