|
111 | 111 | WorkerState, |
112 | 112 | StateSchema, |
113 | 113 | state_column, |
| 114 | + GetApiOptions, |
114 | 115 | ) |
115 | 116 | from ray.dashboard.utils import ray_address_to_api_server_url |
116 | 117 | from ray.util.state.exception import DataSourceUnavailable, RayStateApiException |
@@ -3800,5 +3801,40 @@ def test_hang_driver_has_no_is_running_task(monkeypatch, ray_start_cluster): |
3800 | 3801 | assert not all_job_info[my_job_id].HasField("is_running_tasks") |
3801 | 3802 |
|
3802 | 3803 |
|
| 3804 | +def test_get_actor_timeout_multiplier(shutdown_only): |
| 3805 | + """Test that GetApiOptions applies the same timeout multiplier as ListApiOptions. |
| 3806 | +
|
| 3807 | + This test reproduces the issue where get_actor with timeout=1 fails even though |
| 3808 | + the actual operation takes less than 1 second, because GetApiOptions doesn't |
| 3809 | + apply the 0.8 server timeout multiplier that ListApiOptions uses. |
| 3810 | +
|
| 3811 | + Related issue: https://github.com/ray-project/ray/issues/54153 |
| 3812 | + """ |
| 3813 | + |
| 3814 | + @ray.remote |
| 3815 | + class TestActor: |
| 3816 | + def ready(self): |
| 3817 | + pass |
| 3818 | + |
| 3819 | + actor = TestActor.remote() |
| 3820 | + ray.get(actor.ready.remote()) |
| 3821 | + |
| 3822 | + # Test that both options classes apply the same timeout multiplier |
| 3823 | + test_timeout = 1 |
| 3824 | + get_options = GetApiOptions(timeout=test_timeout) |
| 3825 | + list_options = ListApiOptions(timeout=test_timeout) |
| 3826 | + |
| 3827 | + # After __post_init__, both should have the same effective timeout |
| 3828 | + assert get_options.timeout == list_options.timeout |
| 3829 | + |
| 3830 | + # Test that get_actor works with a 1-second timeout |
| 3831 | + actors = list_actors() |
| 3832 | + actor_id = actors[0]["actor_id"] |
| 3833 | + |
| 3834 | + # This should work without timeout issues |
| 3835 | + result = get_actor(actor_id, timeout=1) |
| 3836 | + assert result["actor_id"] == actor_id |
| 3837 | + |
| 3838 | + |
3803 | 3839 | if __name__ == "__main__": |
3804 | 3840 | sys.exit(pytest.main(["-sv", __file__])) |
0 commit comments