mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 13:54:27 +08:00
Use BaseTest to instead of TestListener. (#3577)
This commit is contained in:
committed by
Robert Nishihara
parent
ddc97864df
commit
8393df2516
@@ -1,14 +1,11 @@
|
||||
package org.ray.api.benchmark;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.test.MyRunner;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class ActorPressTest extends RayBenchmarkTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package org.ray.api.benchmark;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.test.MyRunner;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class MaxPressureTest extends RayBenchmarkTest {
|
||||
|
||||
public static final int clientNum = 2;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package org.ray.api.benchmark;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.test.MyRunner;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class RateLimiterPressureTest extends RayBenchmarkTest {
|
||||
|
||||
public static final int clientNum = 2;
|
||||
|
||||
@@ -11,10 +11,12 @@ import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.test.BaseTest;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class RayBenchmarkTest<T> implements Serializable {
|
||||
public abstract class RayBenchmarkTest<T> extends BaseTest implements Serializable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RayBenchmarkTest.class);
|
||||
//not thread safe ,but we only have one thread here
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package org.ray.api.benchmark;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.test.MyRunner;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class SingleLatencyTest extends RayBenchmarkTest {
|
||||
|
||||
public static final int totalNum = 10;
|
||||
|
||||
@@ -7,14 +7,12 @@ import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.options.ActorCreationOptions;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class ActorReconstructionTest {
|
||||
public class ActorReconstructionTest extends BaseTest {
|
||||
|
||||
@RayRemote()
|
||||
public static class Counter {
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.ray.api.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
@@ -10,8 +9,7 @@ import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.function.RayFunc2;
|
||||
import org.ray.api.id.UniqueId;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class ActorTest {
|
||||
public class ActorTest extends BaseTest {
|
||||
|
||||
@RayRemote
|
||||
public static class Counter {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.ray.api.test;
|
||||
|
||||
import java.io.File;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.ray.api.Ray;
|
||||
|
||||
public class BaseTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
System.setProperty("ray.home", "../..");
|
||||
System.setProperty("ray.resources", "CPU:4,RES-A:4");
|
||||
Ray.init();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
// TODO(qwang): This is double check to check that the socket file is removed actually.
|
||||
// We could not enable this until `systemInfo` enabled.
|
||||
//File rayletSocketFIle = new File(Ray.systemInfo().rayletSocketName());
|
||||
Ray.shutdown();
|
||||
|
||||
//remove raylet socket file
|
||||
//rayletSocketFIle.delete();
|
||||
|
||||
// unset system properties
|
||||
System.clearProperty("ray.home");
|
||||
System.clearProperty("ray.resources");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package org.ray.api.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
@@ -10,8 +9,7 @@ import org.ray.api.annotation.RayRemote;
|
||||
/**
|
||||
* Hello world.
|
||||
*/
|
||||
@RunWith(MyRunner.class)
|
||||
public class HelloWorldTest {
|
||||
public class HelloWorldTest extends BaseTest {
|
||||
|
||||
@RayRemote
|
||||
private static String hello() {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.ray.api.test;
|
||||
|
||||
import org.junit.runner.notification.RunNotifier;
|
||||
import org.junit.runners.BlockJUnit4ClassRunner;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
|
||||
public class MyRunner extends BlockJUnit4ClassRunner {
|
||||
|
||||
public MyRunner(Class<?> klass) throws InitializationError {
|
||||
super(klass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(RunNotifier notifier) {
|
||||
notifier.addListener(new TestListener());
|
||||
notifier.fireTestRunStarted(getDescription());
|
||||
super.run(notifier);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,7 @@ import org.ray.api.id.UniqueId;
|
||||
/**
|
||||
* Test putting and getting objects.
|
||||
*/
|
||||
@RunWith(MyRunner.class)
|
||||
public class ObjectStoreTest {
|
||||
public class ObjectStoreTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testPutAndGet() {
|
||||
|
||||
@@ -13,8 +13,7 @@ import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.api.id.UniqueId;
|
||||
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class PlasmaFreeTest {
|
||||
public class PlasmaFreeTest extends BaseTest {
|
||||
|
||||
@RayRemote
|
||||
private static String hello() {
|
||||
|
||||
@@ -15,8 +15,7 @@ import org.ray.api.annotation.RayRemote;
|
||||
/**
|
||||
* Test Ray.call API
|
||||
*/
|
||||
@RunWith(MyRunner.class)
|
||||
public class RayCallTest {
|
||||
public class RayCallTest extends BaseTest {
|
||||
|
||||
@RayRemote
|
||||
private static int testInt(int val) {
|
||||
|
||||
@@ -10,22 +10,28 @@ public class RayConfigTest {
|
||||
|
||||
@Test
|
||||
public void testCreateRayConfig() {
|
||||
System.setProperty("ray.home", "/path/to/ray");
|
||||
System.setProperty("ray.driver.resource-path", "path/to/ray/driver/resource/path");
|
||||
RayConfig rayConfig = RayConfig.create();
|
||||
try {
|
||||
System.setProperty("ray.home", "/path/to/ray");
|
||||
System.setProperty("ray.driver.resource-path", "path/to/ray/driver/resource/path");
|
||||
RayConfig rayConfig = RayConfig.create();
|
||||
|
||||
Assert.assertEquals("/path/to/ray", rayConfig.rayHome);
|
||||
Assert.assertEquals(WorkerMode.DRIVER, rayConfig.workerMode);
|
||||
Assert.assertEquals(RunMode.CLUSTER, rayConfig.runMode);
|
||||
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();
|
||||
System.setProperty("ray.home", "");
|
||||
rayConfig = RayConfig.create();
|
||||
|
||||
Assert.assertEquals(System.getProperty("user.dir"), rayConfig.rayHome);
|
||||
Assert.assertEquals(System.getProperty("user.dir") +
|
||||
"/build/src/ray/thirdparty/redis/src/redis-server", rayConfig.redisServerExecutablePath);
|
||||
Assert.assertEquals(System.getProperty("user.dir"), rayConfig.rayHome);
|
||||
Assert.assertEquals(System.getProperty("user.dir") +
|
||||
"/build/src/ray/thirdparty/redis/src/redis-server", rayConfig.redisServerExecutablePath);
|
||||
|
||||
Assert.assertEquals("path/to/ray/driver/resource/path", rayConfig.driverResourcePath);
|
||||
Assert.assertEquals("path/to/ray/driver/resource/path", rayConfig.driverResourcePath);
|
||||
} finally {
|
||||
//unset the system property
|
||||
System.clearProperty("ray.home");
|
||||
System.clearProperty("ray.driver.resource-path");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.WaitResult;
|
||||
@@ -14,8 +13,7 @@ import org.ray.runtime.util.logger.RayLog;
|
||||
/**
|
||||
* Integration test for Ray.*
|
||||
*/
|
||||
@RunWith(MyRunner.class)
|
||||
public class RayMethodsTest {
|
||||
public class RayMethodsTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
@@ -2,10 +2,8 @@ package org.ray.api.test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
@@ -17,8 +15,7 @@ import org.ray.api.options.CallOptions;
|
||||
/**
|
||||
* Resources Management Test.
|
||||
*/
|
||||
@RunWith(MyRunner.class)
|
||||
public class ResourcesManagementTest {
|
||||
public class ResourcesManagementTest extends BaseTest {
|
||||
|
||||
@RayRemote
|
||||
public static Integer echo(Integer number) {
|
||||
|
||||
@@ -5,14 +5,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.id.UniqueId;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class StressTest {
|
||||
public class StressTest extends BaseTest {
|
||||
|
||||
public static int echo(int x) {
|
||||
return x;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.ray.api.test;
|
||||
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.Result;
|
||||
import org.junit.runner.notification.RunListener;
|
||||
import org.ray.api.Ray;
|
||||
|
||||
public class TestListener extends RunListener {
|
||||
|
||||
@Override
|
||||
public void testRunStarted(Description description) {
|
||||
System.setProperty("ray.home", "../..");
|
||||
System.setProperty("ray.resources", "CPU:4,RES-A:4");
|
||||
Ray.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testRunFinished(Result result) {
|
||||
Ray.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,12 @@ import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.WaitResult;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
|
||||
@RunWith(MyRunner.class)
|
||||
public class WaitTest {
|
||||
public class WaitTest extends BaseTest {
|
||||
|
||||
@RayRemote
|
||||
private static String hi() {
|
||||
|
||||
Reference in New Issue
Block a user