[Java] Package native dependencies into jar (#4367)

This commit is contained in:
Hao Chen
2019-03-15 12:38:40 +08:00
committed by GitHub
parent 6b93ec3034
commit f8d12b0418
14 changed files with 126 additions and 102 deletions
@@ -1,6 +1,9 @@
package org.ray.api.test;
import com.google.common.collect.ImmutableList;
import java.io.File;
import java.lang.reflect.Method;
import java.util.List;
import org.ray.api.Ray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -11,27 +14,32 @@ public class BaseTest {
private static final Logger LOGGER = LoggerFactory.getLogger(BaseTest.class);
private List<File> filesToDelete;
@BeforeMethod
public void setUpBase(Method method) {
LOGGER.info("===== Running test: "
+ method.getDeclaringClass().getName() + "." + method.getName());
System.setProperty("ray.home", "../..");
System.setProperty("ray.resources", "CPU:4,RES-A:4");
Ray.init();
// These files need to be deleted after each test case.
filesToDelete = ImmutableList.of(
new File(Ray.getRuntimeContext().getRayletSocketName()),
new File(Ray.getRuntimeContext().getObjectStoreSocketName())
);
// Make sure the files will be deleted even if the test doesn't exit gracefully.
filesToDelete.forEach(File::deleteOnExit);
}
@AfterMethod
public void tearDownBase() {
// 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();
for (File file : filesToDelete) {
file.delete();
}
// unset system properties
System.clearProperty("ray.home");
// Unset system properties.
System.clearProperty("ray.resources");
}
@@ -66,8 +66,7 @@ public class MultiLanguageClusterTest {
// Start ray cluster.
String testDir = System.getProperty("user.dir");
String workerOptions = String.format("-Dray.home=%s/../../", testDir);
workerOptions +=
String workerOptions =
" -classpath " + String.format("%s/../../build/java/*:%s/target/*", testDir, testDir);
final List<String> startCommand = ImmutableList.of(
"ray",
@@ -85,7 +84,6 @@ public class MultiLanguageClusterTest {
}
// Connect to the cluster.
System.setProperty("ray.home", "../..");
System.setProperty("ray.redis.address", "127.0.0.1:6379");
System.setProperty("ray.object-store.socket-name", PLASMA_STORE_SOCKET_NAME);
System.setProperty("ray.raylet.socket-name", RAYLET_SOCKET_NAME);
@@ -96,7 +94,6 @@ public class MultiLanguageClusterTest {
public void tearDown() {
// Disconnect to the cluster.
Ray.shutdown();
System.clearProperty("ray.home");
System.clearProperty("ray.redis.address");
System.clearProperty("ray.object-store.socket-name");
System.clearProperty("ray.raylet.socket-name");
@@ -10,24 +10,12 @@ public class RayConfigTest {
@Test
public void testCreateRayConfig() {
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);
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("path/to/ray/driver/resource/path", rayConfig.driverResourcePath);
} finally {
//unset the system property
System.clearProperty("ray.home");
// Unset system properties.
System.clearProperty("ray.driver.resource-path");
}