chore: remove pytest-xdist parallel test infrastructure and switch to serial execution

This commit is contained in:
2026-06-12 05:43:33 +00:00
parent 1e2f304935
commit 425e9bdca1
8 changed files with 30 additions and 45 deletions
+4 -6
View File
@@ -13,10 +13,8 @@ make install # pip install -e .
make ppy # build the single shared container image (ppy:latest); run once before launching instances
make dev # uvicorn --reload on port 10500
make prod # uvicorn 2 workers, port 10500 (backlog 8192)
make test # Playwright + unit tests, headless, parallel (pytest-xdist -n auto, distributed per file), -x fail-fast
make test-serial # same tests in a single process (no xdist) for debugging
make test-headed # same tests in visible browsers, parallel (one Chromium window per worker)
make test-headed-serial # visible browser, single process (one window) for debugging
make test # Playwright + unit tests, headless, serial (one at a time), -x fail-fast
make test-headed # same tests in a visible Chromium window (single process)
make locust # Locust load test, interactive web UI
make locust-headless # Locust CLI mode for CI
```
@@ -46,7 +44,7 @@ devplace containers prune-builds # remove legacy per-project images + clear doc
devplace containers gc-workspaces # remove workspace dirs with no instances
```
Tests run on ports 10501+ (xdist worker offset) with a per-worker tempfile SQLite DB and a per-worker `DEVPLACE_DATA_DIR` (both keyed off `_xdist_port()`), and `DEVPLACE_DISABLE_SERVICES=1` so background services don't start. `make test` runs in parallel via pytest-xdist (`-n auto --dist loadfile`): each worker is one isolated DB + data dir + uvicorn subprocess + Chromium, and `loadfile` pins all tests in a file to one worker so session fixtures (`seeded_db`) and intra-file ordering hold. Override worker count with `make test TEST_WORKERS=4` (default `auto` = one per core); use `make test-serial` for single-process debugging.
Tests run on port 10501 with a tempfile SQLite DB and a dedicated `DEVPLACE_DATA_DIR`, and `DEVPLACE_DISABLE_SERVICES=1` so background services don't start. `make test` runs **serially, one test at a time, in a single process**: one isolated DB + data dir + uvicorn subprocess + Chromium, shared across the whole session, so session fixtures (`seeded_db`) and intra-file ordering hold. Serial execution is enforced centrally in `pyproject.toml` (`[tool.pytest.ini_options]` `addopts = "--tb=line -p no:xdist"`); pytest-xdist is no longer a dependency and `-n` is rejected, so the suite can never run concurrently.
## Environment variables
@@ -206,7 +204,7 @@ Rules when touching this area:
Playwright (NOT pytest-playwright - uninstall if present, it conflicts). 849+ tests across 63 files in `tests/` (mixed Playwright UI tests and in-process `TestClient`/asyncio unit tests). The fixture stack:
- `app_server` (session-scoped): spawns uvicorn as a subprocess on `_xdist_port()` (10501 + worker index) with a tempfile DB.
- `app_server` (session-scoped): spawns uvicorn as a subprocess on port 10501 (the `PORT` constant) with a tempfile DB.
- `browser_context` (session-scoped): one Playwright context shared by all tests.
- `page` (function-scoped): `clear_cookies()` on the session context, then a fresh page.
- `alice` / `bob`: seeded users `alice_test` / `bob_test` logged in via the login form. `bob` gets its own context for multi-user tests. Returns `(page, user_dict)`.