mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 18:44:07 +08:00
[Java] fix actor restart failure when multi-worker is turned on (#13793)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user