Skip to content

Commit 1a37dc1

Browse files
authored
[core] Deflake test_runtime_env_3 (#52553)
The test is bumping up against the timeout which is causing flakes on macos builds. Rather than increase the timeout or split the test, I opted to refactor it a bit to reduce the runtime by combining the logic in the tests to avoid "source" and "option" parametrization. Also reduced to a single worker node for each test to reduce overhead in CI. I've also deleted some tests that have been dead code for a long time (those testing the logic to disable GC, which hasn't existed for years). --------- Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
1 parent 158b901 commit 1a37dc1

File tree

3 files changed

+75
-226
lines changed

3 files changed

+75
-226
lines changed

python/ray/_private/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,7 @@ def check_local_files_gced(cluster, whitelist=None):
17141714
if whitelist and set(items).issubset(whitelist):
17151715
continue
17161716
if len(items) > 0:
1717+
print(f"runtime_env files not GC'd from subdir '{subdir}': {items}")
17171718
return False
17181719
return True
17191720

python/ray/tests/test_runtime_env_conda_and_pip_3.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import pytest
33
import sys
4-
import time
54

65
from ray._private.test_utils import (
76
wait_for_condition,
@@ -10,7 +9,6 @@
109
)
1110
import ray
1211

13-
from unittest import mock
1412

1513
if not os.environ.get("CI"):
1614
# This flags turns on the local development that link against current ray
@@ -145,48 +143,6 @@ def test_import(self):
145143
assert not check_local_files_gced(cluster)
146144

147145

148-
# Set scope to "class" to force this to run before start_cluster, whose scope
149-
# is "function". We need these env vars to be set before Ray is started.
150-
@pytest.fixture(scope="class")
151-
def skip_local_gc():
152-
with mock.patch.dict(
153-
os.environ,
154-
{
155-
"RAY_RUNTIME_ENV_SKIP_LOCAL_GC": "1",
156-
},
157-
):
158-
print("RAY_RUNTIME_ENV_SKIP_LOCAL_GC enabled.")
159-
yield
160-
161-
162-
class TestSkipLocalGC:
163-
@pytest.mark.skipif(
164-
os.environ.get("CI") and sys.platform != "linux",
165-
reason="Requires PR wheels built in CI, so only run on linux CI machines.",
166-
)
167-
@pytest.mark.parametrize("field", ["conda", "pip"])
168-
def test_skip_local_gc_env_var(self, skip_local_gc, start_cluster, field, tmp_path):
169-
cluster, address = start_cluster
170-
runtime_env = generate_runtime_env_dict(field, "python_object", tmp_path)
171-
ray.init(address, namespace="test", runtime_env=runtime_env)
172-
173-
@ray.remote
174-
def f():
175-
import pip_install_test # noqa: F401
176-
177-
return True
178-
179-
assert ray.get(f.remote())
180-
181-
ray.shutdown()
182-
183-
# Give enough time for potentially uninstalling a conda env
184-
time.sleep(10)
185-
186-
# Check nothing was GC'ed
187-
assert not check_local_files_gced(cluster)
188-
189-
190146
if __name__ == "__main__":
191147
if os.environ.get("PARALLEL_CI"):
192148
sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__]))

0 commit comments

Comments
 (0)