mirror of
https://github.com/wassname/ray.git
synced 2026-07-06 05:16:30 +08:00
[Placement group] Check if placement group bundle index is valid (#10194)
* add part code * rebase master * add java testcase * fix review comments * fix lint error * rebase master * fix lint error Co-authored-by: 灵洵 <fengbin.ffb@antfin.com>
This commit is contained in:
@@ -47,4 +47,29 @@ public class PlacementGroupTest extends BaseTest {
|
||||
// Test calling an actor.
|
||||
Assert.assertEquals(Integer.valueOf(1), actor.task(Counter::getValue).remote().get());
|
||||
}
|
||||
|
||||
public void testCheckBundleIndex() {
|
||||
List<Map<String, Double>> bundles = new ArrayList<>();
|
||||
Map<String, Double> bundle = new HashMap<>();
|
||||
bundle.put("CPU", 1.0);
|
||||
bundles.add(bundle);
|
||||
PlacementStrategy strategy = PlacementStrategy.PACK;
|
||||
PlacementGroup placementGroup = Ray.createPlacementGroup(bundles, strategy);
|
||||
|
||||
int exceptionCount = 0;
|
||||
try {
|
||||
Ray.actor(Counter::new, 1).setPlacementGroup(placementGroup, 1).remote();
|
||||
} catch (IllegalArgumentException e) {
|
||||
++exceptionCount;
|
||||
}
|
||||
Assert.assertEquals(1, exceptionCount);
|
||||
|
||||
|
||||
try {
|
||||
Ray.actor(Counter::new, 1).setPlacementGroup(placementGroup, -1).remote();
|
||||
} catch (IllegalArgumentException e) {
|
||||
++exceptionCount;
|
||||
}
|
||||
Assert.assertEquals(2, exceptionCount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user