Skip to content

test: speed up pytest runs with xdist#230

Open
scotluns wants to merge 9 commits intomainfrom
codex-prepare-xdist-setup
Open

test: speed up pytest runs with xdist#230
scotluns wants to merge 9 commits intomainfrom
codex-prepare-xdist-setup

Conversation

@scotluns
Copy link
Copy Markdown
Contributor

Why

This reduces test runtime by letting pytest run safely in parallel. The STIX cache change is mostly there to make xdist practical: it avoids each worker doing the same setup work and keeps the parallel run from fighting over shared test data.

What changed

  • Added pytest-xdist and switched CI to run pytest with two workers.
  • Changed the ATT&CK STIX test fixture from an autouse session fixture to an explicit shared fixture, so tests only prepare STIX data when they need it.
  • Store downloaded STIX bundles in .pytest_cache/attack-stix instead of a per-run temp directory, which lets local and CI runs reuse the same test data.
  • Warm the shared STIX cache before xdist workers start. Workers then read from that cache instead of trying to download or prepare bundles independently.
  • Fail clearly if an xdist worker needs a STIX bundle that was not prepared up front.
  • Added just recipes for parallel test runs and coverage runs.
  • Added PyPI as the explicit uv index so lock generation is stable.

How to verify

  • uv lock --check
  • uv run ruff format --check tests/conftest.py tests/changelog/conftest.py
  • uv run --extra dev pytest -n 2 -q

Known gaps

No known follow-up work from local validation.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant