Skip to content

Commit 1177d33

Browse files
: python/tests/test_actors.py: fork sub-processes for some tests
Summary: see what we can do about getting the logging tests in this diff running in CI. in particular, see if process isolation helps. Differential Revision: D87451374
1 parent db4dddc commit 1177d33

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

.github/workflows/test-gpu-python.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ jobs:
6060
# Each group runs separately with process cleanup in between
6161
pip install pytest-split
6262
63+
# Install pytest-forked so we can run a few globals-heavy
64+
# tests in isolated forked subprocesses.
65+
pip install pytest-forked
66+
6367
# Run tests with test_actor_error disabled
6468
run_test_groups 0
6569

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
markers = [
44
"oss_skip: marks tests to skip in OSS CI",
5+
"forked_only: tests that must run in a forked subprocess",
56
]
67
asyncio_mode = "auto"
78
# Default timeout of 5 minutes

python/tests/test_python_actors.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ def _handle_undeliverable_message(
457457
return True
458458

459459

460-
# oss_skip: pytest keeps complaining about mocking get_ipython module
461-
@pytest.mark.oss_skip
460+
@pytest.mark.forked_only
461+
@pytest.mark.timeout(180)
462462
async def test_actor_log_streaming() -> None:
463463
config = get_configuration()
464464
enable_log_forwarding = config["enable_log_forwarding"]
@@ -620,9 +620,8 @@ async def test_actor_log_streaming() -> None:
620620
pass
621621

622622

623-
# oss_skip: pytest keeps complaining about mocking get_ipython module
624-
# oss_skip: (SF) broken in GitHub by D86994420. Passes internally.
625-
@pytest.mark.oss_skip
623+
@pytest.mark.forked_only
624+
@pytest.mark.timeout(180)
626625
async def test_alloc_based_log_streaming() -> None:
627626
"""Test both AllocHandle.stream_logs = False and True cases."""
628627

@@ -731,8 +730,8 @@ def _stream_logs(self) -> bool:
731730
await test_stream_logs_case(True, "stream_logs_true")
732731

733732

734-
# oss_skip: (SF) broken in GitHub by D86994420. Passes internally.
735-
@pytest.mark.oss_skip
733+
@pytest.mark.forked_only
734+
@pytest.mark.timeout(180)
736735
async def test_logging_option_defaults() -> None:
737736
config = get_configuration()
738737
enable_log_forwarding = config["enable_log_forwarding"]
@@ -856,8 +855,8 @@ def __init__(self):
856855
self.events = MockEvents()
857856

858857

859-
# oss_skip: pytest keeps complaining about mocking get_ipython module
860-
@pytest.mark.oss_skip
858+
@pytest.mark.forked_only
859+
@pytest.mark.timeout(180)
861860
async def test_flush_called_only_once() -> None:
862861
"""Test that flush is called only once when ending an ipython cell"""
863862
config = get_configuration()
@@ -894,8 +893,7 @@ async def test_flush_called_only_once() -> None:
894893
)
895894

896895

897-
# oss_skip: pytest keeps complaining about mocking get_ipython module
898-
@pytest.mark.oss_skip
896+
@pytest.mark.forked_only
899897
@pytest.mark.timeout(180)
900898
async def test_flush_logs_ipython() -> None:
901899
"""Test that logs are flushed when get_ipython is available and post_run_cell event is triggered."""
@@ -999,7 +997,8 @@ async def test_flush_logs_ipython() -> None:
999997
pass
1000998

1001999

1002-
# oss_skip: importlib not pulling resource correctly in git CI, needs to be revisited
1000+
# oss_skip: importlib not pulling resource correctly in git CI, needs
1001+
# to be revisited
10031002
@pytest.mark.oss_skip
10041003
async def test_flush_logs_fast_exit() -> None:
10051004
config = get_configuration()
@@ -1040,8 +1039,8 @@ async def test_flush_logs_fast_exit() -> None:
10401039
)
10411040

10421041

1043-
# oss_skip: (SF) broken in GitHub by D86994420. Passes internally.
1044-
@pytest.mark.oss_skip
1042+
@pytest.mark.forked_only
1043+
@pytest.mark.timeout(180)
10451044
async def test_flush_on_disable_aggregation() -> None:
10461045
"""Test that logs are flushed when disabling aggregation.
10471046
@@ -1187,8 +1186,8 @@ async def test_multiple_ongoing_flushes_no_deadlock() -> None:
11871186
)
11881187

11891188

1190-
# oss_skip: (SF) broken in GitHub by D86994420. Passes internally.
1191-
@pytest.mark.oss_skip
1189+
@pytest.mark.forked_only
1190+
@pytest.mark.timeout(180)
11921191
async def test_adjust_aggregation_window() -> None:
11931192
"""Test that the flush deadline is updated when the aggregation window is adjusted.
11941193

scripts/common-setup.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,30 @@ run_test_groups() {
188188
pkill -9 pytest || true
189189
sleep 2
190190
if [[ "$enable_actor_error_test" == "1" ]]; then
191-
LC_ALL=C pytest python/tests/ -s -v -m "not oss_skip" \
191+
LC_ALL=C pytest python/tests/ -s -v -m "not oss_skip and not forked_only" \
192192
--ignore-glob="**/meta/**" \
193193
--dist=no \
194194
--group="$GROUP" \
195195
--junit-xml="$test_results_dir/test-results-$GROUP.xml" \
196196
--splits=10
197197
else
198-
LC_ALL=C pytest python/tests/ -s -v -m "not oss_skip" \
198+
LC_ALL=C pytest python/tests/ -s -v -m "not oss_skip and not forked_only" \
199199
--ignore-glob="**/meta/**" \
200200
--dist=no \
201201
--ignore=python/tests/test_actor_error.py \
202202
--group="$GROUP" \
203203
--junit-xml="$test_results_dir/test-results-$GROUP.xml" \
204204
--splits=10
205205
fi
206+
207+
# Run forked-only tests once (e.g. in group 0) using pytest-forked
208+
if [[ "$GROUP" == "0" ]]; then
209+
LC_ALL=C pytest python/tests/ -s -v -m "not oss_skip and forked_only" \
210+
--ignore-glob="**/meta/**" \
211+
--dist=no \
212+
--junit-xml="$test_results_dir/test-results-forked.xml" \
213+
--forked
214+
fi
206215
# Check result and record failures
207216
if [[ $? -eq 0 ]]; then
208217
echo "✓ Test group $GROUP completed successfully"

0 commit comments

Comments
 (0)