Skip to content

Commit 3d0f004

Browse files
authored
[Core] Deflake test_put_out_of_disk (#56442)
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
1 parent b9e0eaa commit 3d0f004

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

python/ray/tests/test_out_of_disk_space.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111

1212
import ray
13+
from ray._common.test_utils import wait_for_condition
1314
from ray.util.state import list_cluster_events
1415

1516

@@ -57,14 +58,15 @@ def test_put_out_of_disk(shutdown_only):
5758
# ray.put doesn't work is that fallback allocation uses mmaped file
5859
# that doesn't neccssary allocate disk spaces.
5960
with create_tmp_file(250 * 1024 * 1024):
60-
assert get_current_usage() > local_fs_capacity_threshold
61-
time.sleep(1)
61+
wait_for_condition(lambda: get_current_usage() > local_fs_capacity_threshold)
6262
with pytest.raises(ray.exceptions.OutOfDiskError):
6363
ray.put(np.random.rand(20 * 1024 * 1024))
6464
# delete tmp file to reclaim space back.
6565

66-
assert get_current_usage() < local_fs_capacity_threshold
67-
time.sleep(1)
66+
# Ideally get_current_usage() should immediately reflect the latest disk usage
67+
# after the tmp file is deleted, but somehow there is some delays on CI machines
68+
# so I use wait_for_condition here.
69+
wait_for_condition(lambda: get_current_usage() < local_fs_capacity_threshold)
6870
ray.put(np.random.rand(20 * 1024 * 1024))
6971

7072

0 commit comments

Comments
 (0)