Repository navigation
perf(testing): copy a per-process SQLite schema into test databases; cache the Alembic revision map - #866
Merged
Conversation
…tabases; cache the Alembic revision map and task-package scan Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
…in cache test Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
The schema build always creates alembic_version, so a template built while no Alembic heads resolved cannot reach a test that stamps it. Template key uses column and index names; template tests close their connections. Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Revision-file scan tolerates a file removed mid-scan and keys on size too. Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Deploying simple-module-python with
|
| Latest commit: |
af085c0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8f9b49ca.simple-module-python.pages.dev |
| Branch Preview URL: | https://perf-test-app-fixture.simple-module-python.pages.dev |
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. |
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.
Summary
make test-pyspent most of its time building the per-testappfixture, not running tests. In a profiled run, fixture setup was 1,796 s of the 2,372 s of worker time (76%). A warmappbuild took 0.32 s:create_all0.115 s, lifespan startup 0.13 s,create_app0.05 s, admin seed 0.025 s.This PR removes the avoidable parts. Each test still gets its own database.
SQLite schema template (
simple_module_test._sqlite_template)sqlite3connection.CREATE TABLEruns once per worker instead of once per test. This applies to theappanddb_sessionfixtures.create_all, so its rows are untouched.alembic_version. A template built while no Alembic heads resolved therefore can't reach a test that stamps it. That case was found in review; the regression test fails without the fix.Alembic revision map cache (
simple_module_hosting.migrations.script_directory)resolve_head_revisionsand thenmigration_status.ScriptDirectoryis now reused per resolved ini path while the revision files' paths, mtimes and sizes are unchanged. An added, removed or edited file rebuilds it.Celery task packages (
background_tasks.worker.celery_app)_discover_task_packageskeeps its signature, so the tests that monkeypatch it are unaffected.Numbers
Same machine, 8 workers,
pytest -n 8 --dist loadgroup.appbuild (idle)create_allin that buildTest bodies are unchanged (563 → 566 s worker-time).
Verification
make lintgreen.make test-py: 8,172 passed, 47 skipped, in 249 s.make test-js: 900 passed./ship: an optimize pass, then two reviewers over 3 passes. The last pass was clean. Triage notes are kept locally.framework/testing/tests/test_sqlite_schema_template.py: the build runs once, indexes are copied, databases are isolated, a database that already has tables keeps its rows, a changed table set rebuilds, and the stamp table survives a build with no heads.framework/hosting/tests/test_migration_script_cache.py: the cache is reused, and a new, edited or removed revision is seen.https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4