2,000 tests: CI from 20 to 1.5 minutes.
Set up pytest-xdist to run a large suite in parallel and gave every worker its own test tables.
The challenge
The backend test suite contained about 2,000 tests. A CI run took around 20 minutes, stretching the feedback loop for changes.
My role
I set up parallel pytest execution and organized separate PostgreSQL test tables per worker so parallel runs could operate on their own data.
Engineering approach
With pytest-xdist, tests ran across workers. For PostgreSQL data isolation, pytest fixtures used worker_id to create worker-specific ORM table mappings/metadata. Each worker used separate test tables, not a separate database or schema.
The outcome
A CI run dropped from about 20 minutes to roughly 1.5 minutes — nearly thirteen times faster.
The timing comparison is for approximately 2,000 tests in CI. It describes the test suite execution, not local workstation performance.