Skip to content

Commit 78e30bd

Browse files
: python/tests/test_actors.py: fork sub-processes for some tests (#1933)
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 355aec2 commit 78e30bd

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
@@ -458,8 +458,8 @@ def _handle_undeliverable_message(
458458
return True
459459

460460

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

623623

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

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

734733

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

859858

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

897896

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

10021000

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

10431042

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

11901189

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

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 1) using pytest-forked
208+
if [[ "$GROUP" == "1" ]]; 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)