Repository navigation
test: run the Python suite in parallel and cut per-app setup (#524) - #550
Merged
Merged
Conversation
`make test-py` drops from ~24 min serial to ~5.5 min on 4 cores.
- Add pytest-xdist; `make test-py` passes `-n $(PYTEST_WORKERS)` (default
auto). Kept out of addopts so a single-test run stays in-process.
- Fix the two things that broke under xdist:
- test_negative_authz built parametrize ids from `uuid4()`, so workers
collected differently-named tests and xdist refused to run.
- test_bg_invalidation_redis used a fixed pub/sub channel on a Redis that
CI shares between workers; the channel is now per process.
- The test plugin lowers PasswordHelper's Argon2/bcrypt work factor: hashing
the seeded admin was ~90ms of every `app` fixture.
- The plugin refuses `-n` on Postgres, where every test drops the shared
`public` schema; `make test-py-pg` stays serial.
- CI writes the pytest totals line (count + wall time) to the job summary.
Claude-Session: https://claude.ai/code/session_01LWvhqY9o3KhSo2iAg19cCi
Deploying simple-module-python with
|
| Latest commit: |
1458223
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2141e778.simple-module-python.pages.dev |
| Branch Preview URL: | https://ccr-7c264cfe-blzbew.simple-module-python.pages.dev |
antosubash
marked this pull request as ready for review
October 18, 2026 16:03
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Review follow-ups on the xdist change (#524): - test_module_css_build: both tests rewrite the shared tree (generated manifests, host/static/dist, an audit_log probe page), so they raced when two workers ran them with node_modules present. Grouped with xdist_group("repo-build"); `make test-py` now uses --dist loadgroup. - test_invalidation_cross_process: grouped so the module-scoped subprocess stack is built once, not once per worker that draws one of its tests. - SM_TEST_REAL_PASSWORD_HASHING opts a consumer suite out of the plugin's cheap-hashing patch. - The Postgres + -n UsageError names `make test-py-pg` / PYTEST_WORKERS=0. Claude-Session: https://claude.ai/code/session_01LWvhqY9o3KhSo2iAg19cCi
antosubash
pushed a commit
that referenced
this pull request
Oct 19, 2026
Resolve the CLAUDE.md conflict by keeping the rewrite and folding in main's additions from #550 and #525: pytest-xdist parallel runs (`-n auto --dist loadgroup`, `PYTEST_WORKERS=0`), the serial Postgres suite, single tests running in-process, the test plugin's reduced password-hash work factor and `SM_TEST_REAL_PASSWORD_HASHING`, and the xdist collection rules (deterministic parametrize ids, per-worker names). Claude-Session: https://claude.ai/code/session_01TJ3Gy55Ngyuj5o4UakoF2v
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #524 (items 1 and 3; item 2 partially, see below).
Result (4-core cloud container)
main, serial (from the issue)-n autoonly-n auto+ cheap password hashing (make test-py)4468 passed in both parallel runs. All 13 skips are environmental (no
node_modules, Postgres or MinIO); none come from parallelism.Changes
make test-pyrunspytest -n $(PYTEST_WORKERS)(defaultauto). It isn't inaddopts, souv run pytest path::teststill runs in-process without worker start-up cost.test_negative_authz.pyuseduuid4()in parametrize ids. Each worker collected differently-named tests, and xdist refuses to run in that case. It now uses a fixed UUID; the request must be refused before any lookup, so the id doesn't matter.test_bg_invalidation_redis.pyused a fixed pub/sub channel. CI points every worker at one Redis service, so one worker's publish could reach another worker's subscriber and break the delivery and subscriber counts. The channel is now per process.appfixture, from hashing the seeded admin at production cost.PasswordHelper()now defaults to minimal Argon2/bcrypt parameters under the plugin. Hashes stay real$argon2/$2b, so the legacy-bcrypt upgrade test still means what it says. This is patched at import because test modules buildPasswordHelper()at collection time.publicschema, so the plugin raisesUsageErrorwhen-nis combined with a PostgresSM_TEST_DATABASE_URL.make test-py-pgstays serial.Not done, and why
In the profile, about 75% of the remaining
appsetup is FastAPI building dependants for every route, increate_appand in the route-guard prewarm at lifespan start. Removing that cost means sharing an app between tests. Many tests overridesettings/env per test, so that trade costs isolation and needs a dedicated design. It doesn't belong in this PR. The route-guard prewarm only moves FastAPI's lazy first-request cost earlier, so removing it would save nothing for tests that make a request.https://claude.ai/code/session_01LWvhqY9o3KhSo2iAg19cCi
Generated by Claude Code