66import io .ray .api .ActorHandle ;
77import io .ray .api .ObjectRef ;
88import io .ray .api .Ray ;
9+ import io .ray .api .exception .RayException ;
910import io .ray .api .id .ObjectId ;
1011import io .ray .runtime .object .NativeObjectStore ;
1112import io .ray .runtime .object .ObjectRefImpl ;
@@ -112,9 +113,14 @@ private static void fillObjectStoreAndGet(
112113 if (succeed ) {
113114 TestUtils .getRuntime ().getObjectStore ().getRaw (ImmutableList .of (objectId ), Long .MAX_VALUE );
114115 } else {
115- List <Boolean > result =
116- TestUtils .getRuntime ().getObjectStore ().wait (ImmutableList .of (objectId ), 1 , 100 , true );
117- Assert .assertFalse (result .get (0 ));
116+ try {
117+ List <Boolean > result =
118+ TestUtils .getRuntime ().getObjectStore ().wait (ImmutableList .of (objectId ), 0 , 100 , true );
119+ Assert .fail (
120+ "Ray did not fail when waiting for an object that does not belong in this session" );
121+ } catch (RayException e ) {
122+ // This is the expected outcome for succeed=false, as we wait for non-existent objects.
123+ }
118124 }
119125 }
120126
@@ -165,27 +171,7 @@ private static void sendSignal(ActorHandle<SignalActor> signal) {
165171 }
166172
167173 /** Based on Python test case `test_dependency_refcounts`. */
168- public void testDependencyRefCounts () {
169- {
170- // Test that regular plasma dependency refcounts are decremented once the
171- // task finishes.
172- ActorHandle <SignalActor > signal = SignalActor .create ();
173- ObjectRefImpl <TestUtils .LargeObject > largeDep =
174- (ObjectRefImpl <TestUtils .LargeObject >) Ray .put (new TestUtils .LargeObject ());
175- ObjectRefImpl <Object > result =
176- (ObjectRefImpl <Object >)
177- Ray .<TestUtils .LargeObject , ActorHandle <SignalActor >, Object >task (
178- ReferenceCountingTest ::oneDep , largeDep , signal )
179- .remote ();
180- checkRefCounts (largeDep .getId (), 1 , 1 , result .getId (), 1 , 0 );
181- sendSignal (signal );
182- // Reference count should be removed once the task finishes.
183- checkRefCounts (largeDep .getId (), 1 , 0 , result .getId (), 1 , 0 );
184- del (largeDep );
185- del (result );
186- checkRefCounts (ImmutableMap .of ());
187- }
188-
174+ public void testDependencyRefCounts1 () {
189175 {
190176 // Test that inlined dependency refcounts are decremented once they are
191177 // inlined.
@@ -207,7 +193,9 @@ public void testDependencyRefCounts() {
207193 del (result );
208194 checkRefCounts (ImmutableMap .of ());
209195 }
196+ }
210197
198+ public void testDependencyRefCounts2 () {
211199 {
212200 // Test that spilled plasma dependency refcounts are decremented once
213201 // the task finishes.
@@ -236,7 +224,9 @@ public void testDependencyRefCounts() {
236224 del (result );
237225 checkRefCounts (ImmutableMap .of ());
238226 }
227+ }
239228
229+ public void testDependencyRefCounts3 () {
240230 {
241231 // Test that regular plasma dependency refcounts are decremented if a task
242232 // fails.
@@ -257,7 +247,9 @@ public void testDependencyRefCounts() {
257247 del (result );
258248 checkRefCounts (ImmutableMap .of ());
259249 }
250+ }
260251
252+ public void testDependencyRefCounts4 () {
261253 {
262254 // Test that spilled plasma dependency refcounts are decremented if a task
263255 // fails.
@@ -288,6 +280,28 @@ public void testDependencyRefCounts() {
288280 }
289281 }
290282
283+ public void testDependencyRefCounts5 () {
284+ {
285+ // Test that regular plasma dependency refcounts are decremented once the
286+ // task finishes.
287+ ActorHandle <SignalActor > signal = SignalActor .create ();
288+ ObjectRefImpl <TestUtils .LargeObject > largeDep =
289+ (ObjectRefImpl <TestUtils .LargeObject >) Ray .put (new TestUtils .LargeObject ());
290+ ObjectRefImpl <Object > result =
291+ (ObjectRefImpl <Object >)
292+ Ray .<TestUtils .LargeObject , ActorHandle <SignalActor >, Object >task (
293+ ReferenceCountingTest ::oneDep , largeDep , signal )
294+ .remote ();
295+ checkRefCounts (largeDep .getId (), 1 , 1 , result .getId (), 1 , 0 );
296+ sendSignal (signal );
297+ // Reference count should be removed once the task finishes.
298+ checkRefCounts (largeDep .getId (), 1 , 0 , result .getId (), 1 , 0 );
299+ del (largeDep );
300+ del (result );
301+ checkRefCounts (ImmutableMap .of ());
302+ }
303+ }
304+
291305 private static int fooBasicPinning (Object arg ) {
292306 return 0 ;
293307 }
0 commit comments