Skip to content

Speed up test suite and remove unused backfill command - #609

Merged
bpepple merged 2 commits into
masterfrom
speedup-tests
Aug 21, 2026
Merged

Speed up test suite and remove unused backfill command#609
bpepple merged 2 commits into
masterfrom
speedup-tests

Conversation

@bpepple

@bpepple bpepple commented Aug 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Test suite was paying the full production-strength PBKDF2 cost (~0.5s/hash) on every user creation, and fixture chains often create several users per test (metadata fixtures each create their own created_by/edited_by user), making this the dominant cost by far. Switch to MD5PasswordHasher under pytest only — verified the override is inert outside pytest and that pytest isn't installed in a production (--no-dev) sync, so production hashing is unaffected.
  • Add --reuse-db to skip rebuilding the test database from ~103 migrations on every invocation; safe in CI since each job starts from a fresh Postgres container. Documented the --create-db escape hatch for local migration changes.
  • Remove issue_ratings.backfill_issue_ratings, a one-time management command that already did its job, along with its tests and an unused other_rating_user test fixture.

Together the two speed changes cut the full suite from ~13m40s to ~51s locally (same 1780 passed / 2 skipped).

Test plan

  • Verified production isn't affected: PASSWORD_HASHERS is only set when "pytest" in sys.modules, and confirmed pytest is excluded from a uv sync --no-dev install

Tests were paying full PBKDF2 cost (~0.5s/hash) on every user creation, and fixture chains often create several users per test, making this the dominant cost by far. Switch to MD5PasswordHasher under pytest, and add --reuse-db to skip rebuilding the test database from migrations on every invocation. Together these cut the full suite from ~13m40s to ~51s.
@bpepple bpepple self-assigned this Aug 21, 2026
@bpepple bpepple added enhancement New feature or request chore Miscellaneous drudgery labels Aug 21, 2026
@bpepple
bpepple merged commit 36cf673 into master Aug 21, 2026
2 checks passed
@bpepple
bpepple deleted the speedup-tests branch August 21, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Miscellaneous drudgery enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant