From e9103eeb6dffb4a2275162bcc5e71619b8a66f6c Mon Sep 17 00:00:00 2001 From: Kai Yang Date: Mon, 25 Jan 2021 18:07:45 +0800 Subject: [PATCH] [Java] [Test] Move multi-worker config to ray.conf file (#13583) --- java/test.sh | 7 ++----- java/test/src/main/java/io/ray/test/FailureTest.java | 5 +---- java/test/src/main/java/io/ray/test/JobConfigTest.java | 5 +---- java/test/src/main/java/io/ray/test/KillActorTest.java | 5 +---- java/test/src/main/resources/ray.conf | 6 ++++++ 5 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 java/test/src/main/resources/ray.conf diff --git a/java/test.sh b/java/test.sh index f946fd91a..49a0d68bb 100755 --- a/java/test.sh +++ b/java/test.sh @@ -50,18 +50,15 @@ if ! git diff --exit-code -- java src/ray/core_worker/lib/java; then exit 1 fi -# Enable multi-worker feature in Java test -TEST_ARGS=(-Dray.job.num-java-workers-per-process=10) - echo "Running tests under cluster mode." # TODO(hchen): Ideally, we should use the following bazel command to run Java tests. However, if there're skipped tests, # TestNG will exit with code 2. And bazel treats it as test failure. # bazel test //java:all_tests --config=ci || cluster_exit_code=$? -run_testng java -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_deploy.jar "${TEST_ARGS[@]}" org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml +run_testng java -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_deploy.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml echo "Running tests under single-process mode." # bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --config=ci || single_exit_code=$? -run_testng java -Dray.run-mode="SINGLE_PROCESS" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_deploy.jar "${TEST_ARGS[@]}" org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml +run_testng java -Dray.run-mode="SINGLE_PROCESS" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_deploy.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml echo "Running connecting existing cluster tests." case "${OSTYPE}" in diff --git a/java/test/src/main/java/io/ray/test/FailureTest.java b/java/test/src/main/java/io/ray/test/FailureTest.java index 218c78271..5bfc40dd6 100644 --- a/java/test/src/main/java/io/ray/test/FailureTest.java +++ b/java/test/src/main/java/io/ray/test/FailureTest.java @@ -23,20 +23,17 @@ 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.job.num-java-workers-per-process"); System.setProperty("ray.job.num-java-workers-per-process", "1"); } @AfterClass public void tearDown() { - System.setProperty("ray.job.num-java-workers-per-process", oldNumWorkersPerProcess); + System.clearProperty("ray.job.num-java-workers-per-process"); } public static int badFunc() { diff --git a/java/test/src/main/java/io/ray/test/JobConfigTest.java b/java/test/src/main/java/io/ray/test/JobConfigTest.java index 4ba9e484d..f5efc3377 100644 --- a/java/test/src/main/java/io/ray/test/JobConfigTest.java +++ b/java/test/src/main/java/io/ray/test/JobConfigTest.java @@ -10,11 +10,8 @@ import org.testng.annotations.Test; @Test(groups = {"cluster"}) public class JobConfigTest extends BaseTest { - private String oldNumWorkersPerProcess; - @BeforeClass public void setupJobConfig() { - 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 +21,7 @@ public class JobConfigTest extends BaseTest { @AfterClass public void tearDownJobConfig() { - System.setProperty("ray.job.num-java-workers-per-process", oldNumWorkersPerProcess); + System.clearProperty("ray.job.num-java-workers-per-process"); System.clearProperty("ray.job.jvm-options.0"); System.clearProperty("ray.job.jvm-options.1"); System.clearProperty("ray.job.worker-env.foo1"); diff --git a/java/test/src/main/java/io/ray/test/KillActorTest.java b/java/test/src/main/java/io/ray/test/KillActorTest.java index d862d3e12..fd92b9711 100644 --- a/java/test/src/main/java/io/ray/test/KillActorTest.java +++ b/java/test/src/main/java/io/ray/test/KillActorTest.java @@ -14,17 +14,14 @@ import org.testng.annotations.Test; @Test(groups = {"cluster"}) public class KillActorTest extends BaseTest { - private String oldNumWorkersPerProcess; - @BeforeClass public void setUp() { - oldNumWorkersPerProcess = System.getProperty("ray.job.num-java-workers-per-process"); System.setProperty("ray.job.num-java-workers-per-process", "1"); } @AfterClass public void tearDown() { - System.setProperty("ray.job.num-java-workers-per-process", oldNumWorkersPerProcess); + System.clearProperty("ray.job.num-java-workers-per-process"); } public static class HangActor { diff --git a/java/test/src/main/resources/ray.conf b/java/test/src/main/resources/ray.conf new file mode 100644 index 000000000..b838c0075 --- /dev/null +++ b/java/test/src/main/resources/ray.conf @@ -0,0 +1,6 @@ +ray { + job { + # Enable multi-worker feature in Java test + num-java-workers-per-process: 10 + } +}