[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:
fangfengbinand灵洵 authored and GitHub committed 2020-08-21 11:04:56 -07:00
1 parent 17f801dc69
commit 36c6c4b298
5 files changed
+177 -60

No files matched your search

@@ -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);
}
}