mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 18:44:07 +08:00
[PlacementGroup]Fix placement group wait api disorder bug (#12827)
* [PlacementGroup]Fix placment group wait api disorder bug * fix review comment * fix review comment * fix review comment * fix review comments * increase num_heartbeats_timeout Co-authored-by: 灵洵 <fengbin.ffb@antgroup.com>
This commit is contained in:
@@ -52,11 +52,11 @@ public class PlacementGroupImpl implements PlacementGroup {
|
||||
|
||||
/**
|
||||
* Wait for the placement group to be ready within the specified time.
|
||||
* @param timeoutMs Timeout in milliseconds.
|
||||
* @param timeoutSeconds Timeout in seconds.
|
||||
* @return True if the placement group is created. False otherwise.
|
||||
*/
|
||||
public boolean wait(int timeoutMs) {
|
||||
return Ray.internal().waitPlacementGroupReady(id, timeoutMs);
|
||||
public boolean wait(int timeoutSeconds) {
|
||||
return Ray.internal().waitPlacementGroupReady(id, timeoutSeconds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.ray.api.id.ActorId;
|
||||
import io.ray.api.placementgroup.PlacementGroup;
|
||||
import io.ray.api.placementgroup.PlacementGroupState;
|
||||
import io.ray.api.placementgroup.PlacementStrategy;
|
||||
import io.ray.runtime.exception.RayException;
|
||||
import io.ray.runtime.placementgroup.PlacementGroupImpl;
|
||||
import java.util.List;
|
||||
import org.testng.Assert;
|
||||
@@ -33,7 +34,7 @@ public class PlacementGroupTest extends BaseTest {
|
||||
public void testCreateAndCallActor() {
|
||||
PlacementGroupImpl placementGroup = (PlacementGroupImpl)PlacementGroupTestUtils
|
||||
.createSimpleGroup();
|
||||
Assert.assertTrue(placementGroup.wait(10000));
|
||||
Assert.assertTrue(placementGroup.wait(10));
|
||||
Assert.assertEquals(placementGroup.getName(),"unnamed_group");
|
||||
|
||||
// Test creating an actor from a constructor.
|
||||
@@ -42,7 +43,7 @@ public class PlacementGroupTest extends BaseTest {
|
||||
Assert.assertNotEquals(actor.getId(), ActorId.NIL);
|
||||
|
||||
// Test calling an actor.
|
||||
Assert.assertEquals(Integer.valueOf(1), actor.task(Counter::getValue).remote().get());
|
||||
Assert.assertEquals(actor.task(Counter::getValue).remote().get(), Integer.valueOf(1));
|
||||
}
|
||||
|
||||
@Test(groups = {"cluster"})
|
||||
@@ -54,8 +55,8 @@ public class PlacementGroupTest extends BaseTest {
|
||||
PlacementGroupImpl secondPlacementGroup = (PlacementGroupImpl)PlacementGroupTestUtils
|
||||
.createNameSpecifiedSimpleGroup("CPU", 1, PlacementStrategy.PACK,
|
||||
1.0, "second_placement_group");
|
||||
Assert.assertTrue(firstPlacementGroup.wait(10000));
|
||||
Assert.assertTrue(secondPlacementGroup.wait(10000));
|
||||
Assert.assertTrue(firstPlacementGroup.wait(10));
|
||||
Assert.assertTrue(secondPlacementGroup.wait(10));
|
||||
|
||||
PlacementGroupImpl firstPlacementGroupRes =
|
||||
(PlacementGroupImpl)Ray.getPlacementGroup((firstPlacementGroup).getId());
|
||||
@@ -101,6 +102,15 @@ public class PlacementGroupTest extends BaseTest {
|
||||
PlacementGroupImpl removedPlacementGroup =
|
||||
(PlacementGroupImpl)Ray.getPlacementGroup((secondPlacementGroup).getId());
|
||||
Assert.assertEquals(removedPlacementGroup.getState(), PlacementGroupState.REMOVED);
|
||||
|
||||
// Wait for placement group after it is removed.
|
||||
int exceptionCount = 0;
|
||||
try {
|
||||
removedPlacementGroup.wait(10);
|
||||
} catch (RayException e) {
|
||||
++exceptionCount;
|
||||
}
|
||||
Assert.assertEquals(exceptionCount, 1);
|
||||
}
|
||||
|
||||
public void testCheckBundleIndex() {
|
||||
@@ -112,14 +122,14 @@ public class PlacementGroupTest extends BaseTest {
|
||||
} catch (IllegalArgumentException e) {
|
||||
++exceptionCount;
|
||||
}
|
||||
Assert.assertEquals(1, exceptionCount);
|
||||
Assert.assertEquals(exceptionCount, 1);
|
||||
|
||||
try {
|
||||
Ray.actor(Counter::new, 1).setPlacementGroup(placementGroup, -1).remote();
|
||||
} catch (IllegalArgumentException e) {
|
||||
++exceptionCount;
|
||||
}
|
||||
Assert.assertEquals(2, exceptionCount);
|
||||
Assert.assertEquals(exceptionCount, 2);
|
||||
}
|
||||
|
||||
@Test (expectedExceptions = { IllegalArgumentException.class })
|
||||
|
||||
Reference in New Issue
Block a user