Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions python/ray/tests/test_out_of_disk_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest

import ray
from ray._common.test_utils import wait_for_condition
from ray.util.state import list_cluster_events


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

assert get_current_usage() < local_fs_capacity_threshold
time.sleep(1)
# Ideally get_current_usage() should immediately reflect the latest disk usage
# after the tmp file is deleted, but somehow there is some delays on CI machines
# so I use wait_for_condition here.
wait_for_condition(lambda: get_current_usage() < local_fs_capacity_threshold)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the CI machine, the get_current_usage() is not immediately updated after the tmp_file is deleted for some reason so I'm using wait_for_condition() here to give it some time to update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a comment on get_current_usage that it could be potentially flaky due to file size not being immediately updated + should be used with wait_for_condition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool thanks

ray.put(np.random.rand(20 * 1024 * 1024))


Expand Down