mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 21:46:57 +08:00
[Java] Disable the multi-worker feature by default (#10593)
This commit is contained in:
@@ -40,7 +40,7 @@ public class ClassLoaderTest extends BaseTest {
|
||||
|
||||
@Test(groups = {"cluster"})
|
||||
public void testClassLoaderInMultiThreading() throws Exception {
|
||||
Assert.assertTrue(TestUtils.getRuntime().getRayConfig().numWorkersPerProcess > 1);
|
||||
Assert.assertTrue(TestUtils.getNumWorkersPerProcess() > 1);
|
||||
|
||||
final String jobResourcePath = resourcePath + "/" + Ray.getRuntimeContext().getCurrentJobId();
|
||||
File jobResourceDir = new File(jobResourcePath);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ExitActorTest extends BaseTest {
|
||||
}
|
||||
|
||||
public void testExitActorInMultiWorker() {
|
||||
Assert.assertTrue(TestUtils.getRuntime().getRayConfig().numWorkersPerProcess > 1);
|
||||
Assert.assertTrue(TestUtils.getNumWorkersPerProcess() > 1);
|
||||
ActorHandle<ExitingActor> actor1 = Ray.actor(ExitingActor::new)
|
||||
.setMaxRestarts(10000).remote();
|
||||
int pid = actor1.task(ExitingActor::getPid).remote().get();
|
||||
|
||||
@@ -23,17 +23,20 @@ public class FailureTest extends BaseTest {
|
||||
|
||||
private static final String EXCEPTION_MESSAGE = "Oops";
|
||||
|
||||
private String oldNumWorkersPerProcess;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() {
|
||||
// This is needed by `testGetThrowsQuicklyWhenFoundException`.
|
||||
// Set one worker per process. Otherwise, if `badFunc2` and `slowFunc` run in the same
|
||||
// process, `sleep` will delay `System.exit`.
|
||||
oldNumWorkersPerProcess = System.getProperty("ray.raylet.config.num_workers_per_process_java");
|
||||
System.setProperty("ray.raylet.config.num_workers_per_process_java", "1");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void tearDown() {
|
||||
System.clearProperty("ray.raylet.config.num_workers_per_process_java");
|
||||
System.setProperty("ray.raylet.config.num_workers_per_process_java", oldNumWorkersPerProcess);
|
||||
}
|
||||
|
||||
public static int badFunc() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ray.test;
|
||||
|
||||
import io.ray.api.ActorHandle;
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
@@ -11,9 +10,12 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = {"cluster"})
|
||||
public class JobConfigTest extends BaseTest {
|
||||
|
||||
private String oldNumWorkersPerProcess;
|
||||
|
||||
@BeforeClass
|
||||
public void setupJobConfig() {
|
||||
System.setProperty("ray.raylet.config.enable_multi_tenancy", "true");
|
||||
oldNumWorkersPerProcess = System.getProperty("ray.job.num-java-workers-per-process");
|
||||
System.setProperty("ray.job.num-java-workers-per-process", "3");
|
||||
System.setProperty("ray.job.jvm-options.0", "-DX=999");
|
||||
System.setProperty("ray.job.jvm-options.1", "-DY=998");
|
||||
@@ -24,7 +26,7 @@ public class JobConfigTest extends BaseTest {
|
||||
@AfterClass
|
||||
public void tearDownJobConfig() {
|
||||
System.clearProperty("ray.raylet.config.enable_multi_tenancy");
|
||||
System.clearProperty("ray.job.num-java-workers-per-process");
|
||||
System.setProperty("ray.job.num-java-workers-per-process", oldNumWorkersPerProcess);
|
||||
System.clearProperty("ray.job.jvm-options.0");
|
||||
System.clearProperty("ray.job.jvm-options.1");
|
||||
System.clearProperty("ray.job.worker-env.foo1");
|
||||
@@ -39,16 +41,8 @@ public class JobConfigTest extends BaseTest {
|
||||
return System.getenv(key);
|
||||
}
|
||||
|
||||
public static Integer getWorkersNum() {
|
||||
return TestUtils.getRuntime().getRayConfig().numWorkersPerProcess;
|
||||
}
|
||||
|
||||
public static class MyActor {
|
||||
|
||||
public Integer getWorkersNum() {
|
||||
return TestUtils.getRuntime().getRayConfig().numWorkersPerProcess;
|
||||
}
|
||||
|
||||
public String getJvmOptions(String propertyName) {
|
||||
return System.getProperty(propertyName);
|
||||
}
|
||||
@@ -68,9 +62,8 @@ public class JobConfigTest extends BaseTest {
|
||||
Assert.assertEquals("bar2", Ray.task(JobConfigTest::getEnvVariable, "foo2").remote().get());
|
||||
}
|
||||
|
||||
public void testNumJavaWorkerPerProcess() {
|
||||
ObjectRef<Integer> obj = Ray.task(JobConfigTest::getWorkersNum).remote();
|
||||
Assert.assertEquals(3, (int) obj.get());
|
||||
public void testNumJavaWorkersPerProcess() {
|
||||
Assert.assertEquals(TestUtils.getNumWorkersPerProcess(), 3);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +77,5 @@ public class JobConfigTest extends BaseTest {
|
||||
// test worker env variables
|
||||
Assert.assertEquals("bar1", Ray.task(MyActor::getEnvVariable, "foo1").remote().get());
|
||||
Assert.assertEquals("bar2", Ray.task(MyActor::getEnvVariable, "foo2").remote().get());
|
||||
|
||||
// test workers number.
|
||||
ObjectRef<Integer> obj2 = actor.task(MyActor::getWorkersNum).remote();
|
||||
Assert.assertEquals(3, (int) obj2.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,17 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = {"cluster"})
|
||||
public class KillActorTest extends BaseTest {
|
||||
|
||||
private String oldNumWorkersPerProcess;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() {
|
||||
oldNumWorkersPerProcess = System.getProperty("ray.raylet.config.num_workers_per_process_java");
|
||||
System.setProperty("ray.raylet.config.num_workers_per_process_java", "1");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void tearDown() {
|
||||
System.clearProperty("ray.raylet.config.num_workers_per_process_java");
|
||||
System.setProperty("ray.raylet.config.num_workers_per_process_java", oldNumWorkersPerProcess);
|
||||
}
|
||||
|
||||
public static class HangActor {
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
@Test(groups = {"cluster"})
|
||||
public class MultiThreadingTest extends BaseTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MultiThreadingTest.class);
|
||||
@@ -221,11 +221,6 @@ public class MultiThreadingTest extends BaseTest {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingWrapRunnableInDriver() throws InterruptedException {
|
||||
testMissingWrapRunnable();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingWrapRunnableInWorker() {
|
||||
Ray.task(MultiThreadingTest::testMissingWrapRunnable).remote().get();
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ray.test;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.runtime.AbstractRayRuntime;
|
||||
import io.ray.runtime.RayRuntimeInternal;
|
||||
import io.ray.runtime.RayRuntimeProxy;
|
||||
import io.ray.runtime.config.RunMode;
|
||||
@@ -83,8 +84,19 @@ public class TestUtils {
|
||||
}
|
||||
|
||||
public static RayRuntimeInternal getUnderlyingRuntime() {
|
||||
if (Ray.internal() instanceof AbstractRayRuntime) {
|
||||
return (RayRuntimeInternal) Ray.internal();
|
||||
}
|
||||
RayRuntimeProxy proxy = (RayRuntimeProxy) (java.lang.reflect.Proxy
|
||||
.getInvocationHandler(Ray.internal()));
|
||||
return proxy.getRuntimeObject();
|
||||
}
|
||||
|
||||
private static int getNumWorkersPerProcessRemoteFunction() {
|
||||
return TestUtils.getRuntime().getRayConfig().numWorkersPerProcess;
|
||||
}
|
||||
|
||||
public static int getNumWorkersPerProcess() {
|
||||
return Ray.task(TestUtils::getNumWorkersPerProcessRemoteFunction).remote().get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user