Repository navigation
Closed
Description
Problem
The integration suite (tests/integration, real Docker) takes about 5.5 minutes in CI: 32 tests, 321s of test time. Job setup (checkout, Python, poetry install) is only about 9s, so nearly all of it is the tests themselves, run one at a time.
Per-test times from the CI run for #31's final commit, taken from timestamp deltas in the -v log:
| Test | Time |
|---|---|
test_signal_mid_drain_reverts ×3 (SIGTERM, SIGINT, SIGINT-to-process-group) |
27s each, 81s total |
test_without_a_pty_…[SIGKILL] (includes session setup: registry + stub image builds) |
19s |
test_failed_deploy_restores_the_version_that_was_running |
18s |
test_every_deploy_leaves_a_host_side_log |
17s |
| 8 tests between 9s and 12.5s | ~90s |
| the remaining 18 tests | 0.2–8s each |
Where the time goes
- Serial execution. Each test already has its own git repo, bare origin and compose project (unique
fdit…project names), so the tests are independent. Only the session-scoped local registry and stub images are shared. - Fixed sleeps sized for safety rather than need:
test_signal_mid_drain_reverts: the stub ignores SIGTERM forSTUB_SIGTERM_DELAY=10s, and the test then sleepstime.sleep(12)to outlast it (tests/integration/test_deploys.py:149,:166). That's about 22s of each 27s, three times over.test_rolling_healthcheck_that_passes_late_still_deploys:STUB_HEALTH=after:4withstart_period=15s.test_crash_looping_drain_first_worker_is_drained:time.sleep(3)to let it start crash-looping.test_ci_cancel.py: probe waits (PROBE_SECONDS + 2).
- Every test brings a full stack up with
compose up --wait, then deploys one or more times. Health checks poll at 1s intervals with 2 retries, so each healthy/unhealthy decision costs a few seconds.
Options, roughly in order of payoff
- Shard across CI jobs. Use a matrix of 3–4 integration jobs, each running a slice (
pytest-splitwith--splits N --group i, or explicit-k/file groups). Each job builds its own registry, which is cheap (about 10s). Wall time drops to roughly 1.5–2 minutes and nothing in the tests changes. Small: workflow YAML plus a dev dependency. - Run in parallel on one runner with
pytest-xdist(-n auto). Theregistryfixture is session-scoped, so each xdist worker would build its own unless it's shared (for example, the first worker creates it behind a file lock, keyed onPYTEST_XDIST_TESTRUNUID). GitHub runners have 4 vCPUs, so maybe 2–3× before Docker contention. Small to medium: fixture work, then check for flakiness under load, especially the signal and timing tests. Also speeds up local runs. - Shrink the fixed sleeps:
STUB_SIGTERM_DELAY10 → 3 with a matching sleep (about 45s saved across the three signal tests). The test only needs the drain to outlast the signal, so a few seconds is enough.after:4/start_period=15s→after:2/5s.- Keep each test's intent: the drain still has to be in progress when the signal lands.
- Small; low risk, but rerun the suite several times to make sure it's not flaky.
- Run integration only when it matters. A
pathsfilter (src/**,tests/**,pyproject.toml,poetry.lock, the workflow) skips it for docs-only changes. Trivial, but check required-status-check settings first, because a skipped required check can block merges.
Options 1 and 3 together probably get CI under 2 minutes with the least risk. Option 2 is worth it mainly for local runs.
Constraints
- Keep every scenario. The suite is what proves drain-first ordering, revert on failure and on signal, surviving a dropped ssh session, and tag-based reverts against real Docker.
- No timing flakiness: any shortened sleep needs a margin that holds on a loaded runner.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Speed up the integration suite: parallel locally, sharded in CI