ADR-042: pytest-xdist for parallel integration tests¶
Category: development Provenance: human
Decision¶
Use pytest-xdist to run integration tests in parallel across multiple workers. Significantly reduces total test time.
Rationale¶
Integration tests are I/O bound (waiting for Kubernetes resources). Running in parallel utilizes CPU cores during wait times. pytest-xdist distributes tests across workers. 'auto' mode uses all available cores. Dramatically reduces total test time (e.g., 20 tests * 30s = 10min sequential vs 2min parallel with 10 cores). Better CI resource utilization. Tests must be designed for isolation anyway (different namespaces), making parallelization straightforward.
Agent Instructions¶
Run integration tests with 'pytest -n auto' to use all CPU cores. Design tests to be parallel-safe (isolated namespaces, no shared state). Use xdist's worker-scoped fixtures when needed. Configure in pyproject.toml or pytest.ini.
Rejected Alternatives¶
Sequential test execution¶
Wastes time and CI resources. Tests spend most time waiting for Kubernetes, not CPU bound.
Custom parallel test runner¶
Reinvents wheel. pytest-xdist is mature, well-maintained, handles edge cases.