Enable redis password in Java worker (#3943)

* Support Java redis password

* Fix

* Refine

* Fix lint.
This commit is contained in:
Wang Qing
2019-02-12 13:11:25 +08:00
committed by Yuhong Guo
parent 9797028a91
commit c523bc04ad
8 changed files with 116 additions and 12 deletions
@@ -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());
}
}