mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 20:06:31 +08:00
Fix Java CI failure (#4995)
This commit is contained in:
@@ -48,7 +48,7 @@ public abstract class BaseId implements Serializable {
|
||||
break;
|
||||
}
|
||||
}
|
||||
isNilCache = localIsNil;
|
||||
isNilCache = localIsNil;
|
||||
}
|
||||
return isNilCache;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.ray.api;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.runtime.AbstractRayRuntime;
|
||||
import org.ray.runtime.config.RunMode;
|
||||
import org.testng.Assert;
|
||||
import org.testng.SkipException;
|
||||
|
||||
public class TestUtils {
|
||||
@@ -42,4 +44,17 @@ public class TestUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@RayRemote
|
||||
private static String hi() {
|
||||
return "hi";
|
||||
}
|
||||
|
||||
/**
|
||||
* Warm up the cluster.
|
||||
*/
|
||||
public static void warmUpCluster() {
|
||||
RayObject<String> obj = Ray.call(TestUtils::hi);
|
||||
Assert.assertEquals(obj.get(), "hi");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ public class DynamicResourceTest extends BaseTest {
|
||||
@Test
|
||||
public void testSetResource() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
|
||||
// Call a task in advance to warm up the cluster to avoid being too slow to start workers.
|
||||
TestUtils.warmUpCluster();
|
||||
|
||||
CallOptions op1 =
|
||||
new CallOptions.Builder().setResources(ImmutableMap.of("A", 10.0)).createCallOptions();
|
||||
RayObject<String> obj = Ray.call(DynamicResourceTest::sayHi, op1);
|
||||
@@ -30,16 +34,21 @@ public class DynamicResourceTest extends BaseTest {
|
||||
Assert.assertEquals(result.getReady().size(), 0);
|
||||
|
||||
Ray.setResource("A", 10.0);
|
||||
boolean resourceReady = TestUtils.waitForCondition(() -> {
|
||||
List<NodeInfo> nodes = Ray.getRuntimeContext().getAllNodeInfo();
|
||||
if (nodes.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
return (0 == Double.compare(10.0, nodes.get(0).resources.get("A")));
|
||||
}, 2000);
|
||||
|
||||
// Assert node info.
|
||||
List<NodeInfo> nodes = Ray.getRuntimeContext().getAllNodeInfo();
|
||||
Assert.assertEquals(nodes.size(), 1);
|
||||
Assert.assertEquals(nodes.get(0).resources.get("A"), 10.0);
|
||||
Assert.assertTrue(resourceReady);
|
||||
|
||||
// Assert ray call result.
|
||||
result = Ray.wait(ImmutableList.of(obj), 1, 1000);
|
||||
Assert.assertEquals(result.getReady().size(), 1);
|
||||
Assert.assertEquals(Ray.get(obj.getId()), "hi");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.TestUtils;
|
||||
import org.ray.api.WaitResult;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.testng.Assert;
|
||||
@@ -28,6 +29,9 @@ public class WaitTest extends BaseTest {
|
||||
}
|
||||
|
||||
private static void testWait() {
|
||||
// Call a task in advance to warm up the cluster to avoid being too slow to start workers.
|
||||
TestUtils.warmUpCluster();
|
||||
|
||||
RayObject<String> obj1 = Ray.call(WaitTest::hi);
|
||||
RayObject<String> obj2 = Ray.call(WaitTest::delayedHi);
|
||||
|
||||
@@ -71,4 +75,5 @@ public class WaitTest extends BaseTest {
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user