mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 01:09:50 +08:00
[Java] Single-process mode (#4245)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package org.ray.api;
|
||||
|
||||
import org.ray.runtime.AbstractRayRuntime;
|
||||
import org.ray.runtime.config.RunMode;
|
||||
import org.testng.SkipException;
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
public static void skipTestUnderSingleProcess() {
|
||||
AbstractRayRuntime runtime = (AbstractRayRuntime)Ray.internal();
|
||||
if (runtime.getRayConfig().runMode == RunMode.SINGLE_PROCESS) {
|
||||
throw new SkipException("Skip case.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.ray.api.Checkpointable;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.TestUtils;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.exception.RayActorException;
|
||||
import org.ray.api.id.UniqueId;
|
||||
@@ -33,6 +34,11 @@ public class ActorReconstructionTest extends BaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEachCase() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActorReconstruction() throws InterruptedException, IOException {
|
||||
ActorCreationOptions options = new ActorCreationOptions(new HashMap<>(), 1);
|
||||
|
||||
@@ -12,6 +12,7 @@ public class BaseTest {
|
||||
System.setProperty("ray.resources", "CPU:4,RES-A:4");
|
||||
beforeInitRay();
|
||||
Ray.init();
|
||||
beforeEachCase();
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
@@ -37,4 +38,8 @@ public class BaseTest {
|
||||
protected void afterShutdownRay() {
|
||||
|
||||
}
|
||||
|
||||
protected void beforeEachCase() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.TestUtils;
|
||||
import org.ray.api.exception.RayException;
|
||||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.RayObjectImpl;
|
||||
@@ -16,6 +17,11 @@ public class ClientExceptionTest extends BaseTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClientExceptionTest.class);
|
||||
|
||||
@Override
|
||||
public void beforeEachCase() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWaitAndCrash() {
|
||||
UniqueId randomId = UniqueId.randomId();
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.ray.api.test;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.TestUtils;
|
||||
import org.ray.api.exception.RayActorException;
|
||||
import org.ray.api.exception.RayTaskException;
|
||||
import org.ray.api.exception.RayWorkerException;
|
||||
@@ -54,6 +55,11 @@ public class FailureTest extends BaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEachCase() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNormalTaskFailure() {
|
||||
assertTaskFailedWithRayTaskException(Ray.call(FailureTest::badFunc));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.ray.api.test;
|
||||
|
||||
import org.ray.runtime.config.RayConfig;
|
||||
import org.ray.runtime.config.RunMode;
|
||||
import org.ray.runtime.config.WorkerMode;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -17,7 +16,6 @@ public class RayConfigTest {
|
||||
|
||||
Assert.assertEquals("/path/to/ray", rayConfig.rayHome);
|
||||
Assert.assertEquals(WorkerMode.DRIVER, rayConfig.workerMode);
|
||||
Assert.assertEquals(RunMode.CLUSTER, rayConfig.runMode);
|
||||
|
||||
System.setProperty("ray.home", "");
|
||||
rayConfig = RayConfig.create();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.TestUtils;
|
||||
import org.ray.api.WaitResult;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.options.ActorCreationOptions;
|
||||
@@ -29,6 +30,11 @@ public class ResourcesManagementTest extends BaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEachCase() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethods() {
|
||||
CallOptions callOptions1 = new CallOptions(ImmutableMap.of("CPU", 4.0, "GPU", 0.0));
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.TestUtils;
|
||||
import org.ray.api.id.UniqueId;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -16,6 +17,11 @@ public class StressTest extends BaseTest {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEachCase() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubmittingTasks() {
|
||||
for (int numIterations : ImmutableList.of(1, 10, 100, 1000)) {
|
||||
|
||||
Reference in New Issue
Block a user