Fix Java MultithreadingTest (#5182)

This commit is contained in:
Hao Chen
2019-07-12 19:00:13 +08:00
committed by GitHub
parent f46c555e9e
commit 0ec3a16bbd
2 changed files with 8 additions and 2 deletions
@@ -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);