Commit cf2f1de
daemon-test-suite: parallelize tox env with -n 4 --dist loadgroup (#23512)
## Cause
The `daemon-test-suite` `py312` tox env runs ~527s on CI for 38 tests, all serial. `pytest-xdist` 3.6.1 is loaded transitively via `dagster[test]`, but the tox `commands = pytest -s -vv {posargs}` line has no `-n` flag, so xdist never gets used.
The 3 tests in `monitoring_daemon_tests/test_monitoring.py` share a session-scoped `hostnames` fixture wrapping `docker_compose_cm` — the same anti-pattern that broke PR #23506 (4 xdist workers each tried to bring up the same compose stack; 3 failed). This needs handling specifically; the remaining 35 tests don't share a docker compose stack and parallelize freely.
## Fix
- Change tox `commands =` to `pytest -s -vv -n 4 --dist loadgroup {posargs}`.
- Mark the 3 monitoring tests with `@pytest.mark.xdist_group(name="monitoring_compose")` so loadgroup co-locates them on a single worker (one compose stack per group, never racing).
`--dist loadgroup` (rather than `worksteal`) is the right scheduler when some tests *must* go to the same worker; pytest-xdist guarantees same-group tests share a worker. Worker count is fixed at 4 because `os.cpu_count()` inside K8s pod runners returns 1, defeating `-n auto`.
## Before / after
CI baseline: ~527s pytest serial (38 tests).
Estimated CI: ~3 minutes saved per run. The 3 monitoring tests stay on one worker (their docker compose runtime is the floor); the remaining 35 spread across the other three workers, so wall-clock goes from `serial(38)` to roughly `max(serial(3 monitoring), serial(35) / 3)`.
**Observed (job wall-clock, including tox setup):**
| Build | Branch | daemon-test-suite-3-12 |
|---|---|---|
| [155030](https://buildkite.com/dagster/internal/builds/155030) | master | 417s (6m 57s) |
| [155046](https://buildkite.com/dagster/internal/builds/155046) | this PR | **237s (3m 57s)** |
**−180s, 1.76× speedup.** Lands at the optimistic end of the predicted floor (`max(monitoring_compose ≈ 240s, test_memory ≈ 150s)`) — the `monitoring_compose` group is now the bottleneck as designed.
Local validation skipped — daemon-test-suite needs docker compose plus many dagster packages installed, so CI is the first real signal. Verified the Python `pytest.mark.xdist_group` decoration parses, and `tox.ini` parses as INI.
## Same assertions
No tests added, removed, skipped, marked `xfail`, or modified. The decorator only affects worker assignment; xdist scheduling is the only behavior change.
## Notes
`pytest-xdist` is already in the resolved deps via `dagster[test]` — no lockfile change required.
This PR explicitly avoids the trap that bit PR #23506: marking the docker-compose-bound tests with an `xdist_group` is the simple alternative to making the underlying fixture xdist-safe. PR #23507 takes the deeper-fix approach for the dagster-cloud-e2e suite where many more tests share the same compose stack.
Internal-RevId: 9974bcec3953a3c567ff2c23db405100ea16e3ec1 parent f459954 commit cf2f1de
2 files changed
Lines changed: 4 additions & 1 deletion
File tree
- integration_tests/test_suites/daemon-test-suite
- monitoring_daemon_tests
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| 199 | + | |
197 | 200 | | |
198 | 201 | | |
199 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
0 commit comments