mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:38:18 +08:00
Updating zero capacity resource semantics (#4555)
This commit is contained in:
committed by
Robert Nishihara
parent
bb207a205b
commit
0f42f87ebc
@@ -46,22 +46,30 @@ public class ResourcesManagementTest extends BaseTest {
|
||||
@Test
|
||||
public void testMethods() {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
CallOptions callOptions1 = new CallOptions(ImmutableMap.of("CPU", 4.0, "GPU", 0.0));
|
||||
CallOptions callOptions1 = new CallOptions(ImmutableMap.of("CPU", 4.0));
|
||||
|
||||
// This is a case that can satisfy required resources.
|
||||
// The static resources for test are "CPU:4,RES-A:4".
|
||||
RayObject<Integer> result1 = Ray.call(ResourcesManagementTest::echo, 100, callOptions1);
|
||||
Assert.assertEquals(100, (int) result1.get());
|
||||
|
||||
CallOptions callOptions2 = new CallOptions(ImmutableMap.of("CPU", 4.0, "GPU", 2.0));
|
||||
CallOptions callOptions2 = new CallOptions(ImmutableMap.of("CPU", 4.0));
|
||||
|
||||
// This is a case that can't satisfy required resources.
|
||||
// The static resources for test are "CPU:4,RES-A:4".
|
||||
final RayObject<Integer> result2 = Ray.call(ResourcesManagementTest::echo, 200, callOptions2);
|
||||
WaitResult<Integer> waitResult = Ray.wait(ImmutableList.of(result2), 1, 1000);
|
||||
|
||||
Assert.assertEquals(0, waitResult.getReady().size());
|
||||
Assert.assertEquals(1, waitResult.getUnready().size());
|
||||
Assert.assertEquals(1, waitResult.getReady().size());
|
||||
Assert.assertEquals(0, waitResult.getUnready().size());
|
||||
|
||||
try {
|
||||
CallOptions callOptions3 = new CallOptions(ImmutableMap.of("CPU", 0.0));
|
||||
Assert.fail();
|
||||
} catch (RuntimeException e) {
|
||||
// We should receive a RuntimeException indicates that we should not
|
||||
// pass a zero capacity resource.
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,7 +77,7 @@ public class ResourcesManagementTest extends BaseTest {
|
||||
TestUtils.skipTestUnderSingleProcess();
|
||||
|
||||
ActorCreationOptions actorCreationOptions1 =
|
||||
new ActorCreationOptions(ImmutableMap.of("CPU", 2.0, "GPU", 0.0));
|
||||
new ActorCreationOptions(ImmutableMap.of("CPU", 2.0));
|
||||
|
||||
// This is a case that can satisfy required resources.
|
||||
// The static resources for test are "CPU:4,RES-A:4".
|
||||
@@ -80,7 +88,7 @@ public class ResourcesManagementTest extends BaseTest {
|
||||
// This is a case that can't satisfy required resources.
|
||||
// The static resources for test are "CPU:4,RES-A:4".
|
||||
ActorCreationOptions actorCreationOptions2 =
|
||||
new ActorCreationOptions(ImmutableMap.of("CPU", 8.0, "GPU", 0.0));
|
||||
new ActorCreationOptions(ImmutableMap.of("CPU", 8.0));
|
||||
|
||||
RayActor<ResourcesManagementTest.Echo> echo2 =
|
||||
Ray.createActor(Echo::new, actorCreationOptions2);
|
||||
|
||||
Reference in New Issue
Block a user