Making a Large-Scale Test Suite Deterministic
- Engineering Excellence
- Root Cause Analysis
- Test Infrastructure
Technology stack
- Python
- pytest
- Django
- PostgreSQL
- GitHub Actions
Challenge
A large automated test suite executed across multiple parallel CI workers exhibited recurring failures that appeared unrelated to the changes being tested.
The failures were initially treated as test flakiness, but repeated executions did not reliably resolve the problem.
My Approach
- Demonstrated that the failures were deterministic for a particular test execution order and shard composition.
- Reproduced CI test distributions locally without requiring full test execution.
- Identified several underlying problems involving database sequence behavior, transaction isolation, cached permissions and session-scoped fixtures.
- Designed a reusable mechanism to restore shared fixture state where required.
- Introduced automated checks to detect problematic fixture patterns before they could cause similar failures.
- Improved regression tests to verify actual behavior rather than relying solely on code coverage.
Outcome
Eliminated the reproduced failure pattern by addressing its underlying architectural causes rather than repeatedly fixing individual failing tests.
The solution also introduced preventive mechanisms to reduce the likelihood of similar regressions.