Skip to content

Speed up the integration suite (5.5 min in CI) #38

Closed

Description

@wadewilliams

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

  1. 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.
  2. Fixed sleeps sized for safety rather than need:
    • test_signal_mid_drain_reverts: the stub ignores SIGTERM for STUB_SIGTERM_DELAY=10s, and the test then sleeps time.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:4 with start_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).
  3. 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

  1. Shard across CI jobs. Use a matrix of 3–4 integration jobs, each running a slice (pytest-split with --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.
  2. Run in parallel on one runner with pytest-xdist (-n auto). The registry fixture 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 on PYTEST_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.
  3. Shrink the fixed sleeps:
    • STUB_SIGTERM_DELAY 10 → 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.
  4. Run integration only when it matters. A paths filter (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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions