diff --git a/python/ray/tests/test_state_api.py b/python/ray/tests/test_state_api.py index f8962ce20dd27..9c46e04975c1a 100644 --- a/python/ray/tests/test_state_api.py +++ b/python/ray/tests/test_state_api.py @@ -20,6 +20,7 @@ import ray._private.state as global_state import ray._private.ray_constants as ray_constants from ray._private.test_utils import ( + run_string_as_driver, wait_for_condition, async_wait_for_condition_async_predicate, ) @@ -1946,6 +1947,33 @@ class A: assert x_actors[0]["ray_namespace"] == "x" +def test_list_all_actors_from_dead_jobs(ray_start_regular): + script = """ +import ray +import time + +ray.init("auto") + +@ray.remote +class Actor(): + def ready(self): + pass + +a = Actor.remote() +ray.get(a.ready.remote()) +""" + run_string_as_driver(script) + + def verify(): + actors_with_dead_jobs = list_actors() + assert len(actors_with_dead_jobs) == 1 + assert actors_with_dead_jobs[0]["state"] == "DEAD" + + return True + + wait_for_condition(verify) + + @pytest.mark.skipif( sys.platform == "win32", reason="Failed on Windows",