feat: enable parallel pytest-xdist test execution with isolated per-worker databases and data directories

This commit is contained in:
2026-06-09 21:11:37 +00:00
parent a3f9b949ca
commit 49d4f50f32
6 changed files with 35 additions and 15 deletions
+5 -3
View File
@@ -13,8 +13,10 @@ 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, -x fail-fast
make test-headed # same tests in visible browser
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 locust # Locust load test, interactive web UI
make locust-headless # Locust CLI mode for CI
```
@@ -44,7 +46,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 tempfile SQLite DB and `DEVPLACE_DISABLE_SERVICES=1` so background services don't start.
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.
## Environment variables