Speed up workspace tests and parallelize make test
make test was dominated by teardown-heavy workspace integration tests, not by coverage overhead. Service shutdown was treating zombie processes as live, which forced repeated timeout waits, and one shell test was leaving killpg monkeypatched during cleanup, which made shell close paths burn the full wait budget.\n\nTreat Linux zombie pids as stopped in the workspace manager so service teardown completes promptly. Restore the real killpg implementation before shell test cleanup so the shell close path no longer pays the artificial timeout. Also isolate sys.argv in the runtime-network-check main() test so parallel pytest flags do not leak into argparse-based tests.\n\nAdd pytest-xdist to the dev environment and run make test with pytest -n auto by default so available cores are used automatically during local iteration.\n\nValidation:\n- uv lock\n- targeted hot-spot pytest rerun after the fix dropped the worst tests from roughly 10-21s each to sub-second timings\n- UV_CACHE_DIR=.uv-cache make check\n- UV_CACHE_DIR=.uv-cache make dist-check
This commit is contained in:
parent
d05fba6c15
commit
cc5f566bcc
7 changed files with 60 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
import pyro_mcp.runtime_network_check as runtime_network_check
|
||||
|
|
@ -43,6 +45,7 @@ def test_network_check_uses_network_enabled_manager(monkeypatch: pytest.MonkeyPa
|
|||
def test_network_check_main_fails_on_unsuccessful_command(
|
||||
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
|
||||
) -> None:
|
||||
monkeypatch.setattr(sys, "argv", ["runtime-network-check"])
|
||||
monkeypatch.setattr(
|
||||
runtime_network_check,
|
||||
"run_network_check",
|
||||
|
|
|
|||
|
|
@ -2937,6 +2937,11 @@ def test_workspace_service_process_group_helpers(monkeypatch: pytest.MonkeyPatch
|
|||
assert kill_calls == [signal.SIGTERM, signal.SIGKILL]
|
||||
|
||||
|
||||
def test_pid_is_running_treats_zombies_as_stopped(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(vm_manager_module, "_linux_process_state", lambda _pid: "Z")
|
||||
assert vm_manager_module._pid_is_running(123) is False # noqa: SLF001
|
||||
|
||||
|
||||
def test_workspace_service_probe_and_refresh_helpers(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ def test_workspace_shells_write_and_signal_runtime_errors(
|
|||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
real_killpg = os.killpg
|
||||
session = create_local_shell(
|
||||
workspace_id="workspace-6",
|
||||
shell_id="shell-6",
|
||||
|
|
@ -189,6 +190,7 @@ def test_workspace_shells_write_and_signal_runtime_errors(
|
|||
monkeypatch.setattr("pyro_mcp.workspace_shells.os.killpg", _raise_killpg)
|
||||
with pytest.raises(RuntimeError, match="not running"):
|
||||
session.send_signal("INT")
|
||||
monkeypatch.setattr("pyro_mcp.workspace_shells.os.killpg", real_killpg)
|
||||
finally:
|
||||
try:
|
||||
session.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue