mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:38:18 +08:00
Fix Java MultithreadingTest (#5182)
This commit is contained in:
@@ -51,7 +51,12 @@ public class TestUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Warm up the cluster.
|
||||
* Warm up the cluster to make sure there's at least one idle worker.
|
||||
*
|
||||
* This is needed before calling `wait`. Because, in Travis CI, starting a new worker
|
||||
* process could be slower than the wait timeout.
|
||||
* TODO(hchen): We should consider supporting always reversing a certain number of
|
||||
* idle workers in Raylet's worker pool.
|
||||
*/
|
||||
public static void warmUpCluster() {
|
||||
RayObject<String> obj = Ray.call(TestUtils::hi);
|
||||
|
||||
@@ -81,10 +81,11 @@ public class MultiThreadingTest extends BaseTest {
|
||||
Assert.assertEquals(arg, (int) Ray.get(obj.getId()));
|
||||
}, LOOP_COUNTER);
|
||||
|
||||
TestUtils.warmUpCluster();
|
||||
// Test wait for one object in multi threads.
|
||||
RayObject<Integer> obj = Ray.call(MultiThreadingTest::echo, 100);
|
||||
runTestCaseInMultipleThreads(() -> {
|
||||
WaitResult<Integer> result = Ray.wait(ImmutableList.of(obj), 1, 2000);
|
||||
WaitResult<Integer> result = Ray.wait(ImmutableList.of(obj), 1, 1000);
|
||||
Assert.assertEquals(1, result.getReady().size());
|
||||
}, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user