[Java] ID length fix (#6454)

This commit is contained in:
Kai Yang
2019-12-15 16:01:05 +08:00
committed by Hao Chen
parent f5d10eea0b
commit cd250ba0bc
5 changed files with 28 additions and 14 deletions
@@ -42,11 +42,11 @@ public class GcsClientTest extends BaseTest {
public void testNextJob() {
TestUtils.skipTestUnderSingleProcess();
RayConfig config = TestUtils.getRuntime().getRayConfig();
// The value of job id of this driver in cluster should be `1L`.
// The value of job id of this driver in cluster should be 1.
Assert.assertEquals(config.getJobId(), JobId.fromInt(1));
GcsClient gcsClient = TestUtils.getRuntime().getGcsClient();
for (int i = 2; i < 100; ++i) {
for (int i = 2; i < 100; ++i) {
Assert.assertEquals(gcsClient.nextJobId(), JobId.fromInt(i));
}
@@ -1,11 +1,12 @@
package org.ray.api.test;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.annotation.RayRemote;
import org.ray.api.id.ActorId;
import org.ray.api.id.JobId;
import org.ray.api.id.UniqueId;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -13,10 +14,17 @@ import org.testng.annotations.Test;
public class RuntimeContextTest extends BaseTest {
private static JobId JOB_ID = JobId.fromHexString("00112233");
private static JobId JOB_ID = getJobId();
private static String RAYLET_SOCKET_NAME = "/tmp/ray/test/raylet_socket";
private static String OBJECT_STORE_SOCKET_NAME = "/tmp/ray/test/object_store_socket";
private static JobId getJobId() {
// Must be stable across different processes.
byte[] bytes = new byte[JobId.LENGTH];
Arrays.fill(bytes, (byte) 127);
return JobId.fromByteBuffer(ByteBuffer.wrap(bytes));
}
@BeforeClass
public void setUp() {
System.setProperty("ray.job.id", JOB_ID.toString());