File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1010import pytest
1111
1212import ray
13+ from ray ._common .test_utils import wait_for_condition
1314from 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
You can’t perform that action at this time.
0 commit comments