mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 10:52:54 +08:00
Enable redis password in Java worker (#3943)
* Support Java redis password * Fix * Refine * Fix lint.
This commit is contained in:
@@ -11,6 +11,7 @@ public class BaseTest {
|
||||
public void setUp() {
|
||||
System.setProperty("ray.home", "../..");
|
||||
System.setProperty("ray.resources", "CPU:4,RES-A:4");
|
||||
beforeInitRay();
|
||||
Ray.init();
|
||||
}
|
||||
|
||||
@@ -20,6 +21,7 @@ public class BaseTest {
|
||||
// We could not enable this until `systemInfo` enabled.
|
||||
//File rayletSocketFIle = new File(Ray.systemInfo().rayletSocketName());
|
||||
Ray.shutdown();
|
||||
afterShutdownRay();
|
||||
|
||||
//remove raylet socket file
|
||||
//rayletSocketFIle.delete();
|
||||
@@ -29,4 +31,11 @@ public class BaseTest {
|
||||
System.clearProperty("ray.resources");
|
||||
}
|
||||
|
||||
protected void beforeInitRay() {
|
||||
|
||||
}
|
||||
|
||||
protected void afterShutdownRay() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.ray.api.test;
|
||||
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class RedisPasswordTest extends BaseTest {
|
||||
|
||||
@Override
|
||||
public void beforeInitRay() {
|
||||
System.setProperty("ray.redis.head-password", "12345678");
|
||||
System.setProperty("ray.redis.password", "12345678");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterShutdownRay() {
|
||||
System.clearProperty("ray.redis.head-password");
|
||||
System.clearProperty("ray.redis.password");
|
||||
}
|
||||
|
||||
@RayRemote
|
||||
public static String echo(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRedisPassword() {
|
||||
RayObject<String> obj = Ray.call(RedisPasswordTest::echo, "hello");
|
||||
Assert.assertEquals("hello", obj.get());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user