[Java] fix actor restart failure when multi-worker is turned on (#13793)

This commit is contained in:
Kai Yang
2021-02-07 21:12:54 +08:00
committed by GitHub
parent 1412f3c546
commit 4b4941435d
5 changed files with 88 additions and 10 deletions
@@ -3,15 +3,14 @@ package io.ray.test;
import io.ray.api.ActorHandle;
import io.ray.api.Ray;
import io.ray.runtime.exception.RayActorException;
import io.ray.runtime.exception.RayException;
import io.ray.runtime.util.SystemUtil;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.testng.Assert;
import org.testng.annotations.Test;
@Test(
groups = {"cluster"},
enabled = false)
@Test(groups = {"cluster"})
public class ActorRestartTest extends BaseTest {
public static class Counter {
@@ -58,6 +57,7 @@ public class ActorRestartTest extends BaseTest {
// Kill the actor process.
killActorProcess(actor);
waitForActorAlive(actor);
int value = actor.task(Counter::increase).remote().get();
Assert.assertEquals(value, 1);
@@ -83,4 +83,18 @@ public class ActorRestartTest extends BaseTest {
// Wait for the actor to be killed.
TimeUnit.SECONDS.sleep(1);
}
private static void waitForActorAlive(ActorHandle<Counter> actor) {
Assert.assertTrue(
TestUtils.waitForCondition(
() -> {
try {
actor.task(Counter::getPid).remote().get();
return true;
} catch (RayException e) {
return false;
}
},
10000));
}
}