master
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5437c73420 |
perf(test): replace per-instance _database_initialized flag with process-global cache (#1264)
CI / lint (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / build (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / quality (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / security (push) Has been cancelled
CI / helm (push) Has been cancelled
CI / unit_tests (push) Has been cancelled
CI / docker (push) Has been cancelled
CI / status-check (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
Add a process-global `_INITIALIZED_DBS: set[str]` to `features/environment.py` that caches database URLs after `_fast_init_or_upgrade` has processed them. On subsequent calls with the same URL, the function returns immediately — skipping all URL parsing, path extraction, prefix matching, and `stat()` syscalls that previously executed on every new `UnitOfWork` instance. The cache is cleared at the start of each scenario in `before_scenario` to prevent cross-scenario state leaks, since each scenario receives fresh temp-DB paths via `tempfile.mktemp()`. Four new Behave scenarios validate cache hits on repeated calls, cache clearing between scenarios, and non-caching of non-matching-prefix URLs. Estimated savings: ~65,000 unnecessary function-body executions eliminated per full test run (~7 UnitOfWork instantiations × ~10,700 scenarios). ISSUES CLOSED: #735 Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com> Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com> Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com> |
||
|
|
b21e0fedea
|
test(bdd): add direct test for _fast_init_or_upgrade early-return behavior
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 24s
CI / typecheck (pull_request) Successful in 50s
CI / security (pull_request) Successful in 1m10s
CI / lint (pull_request) Successful in 3m20s
CI / quality (pull_request) Successful in 3m45s
CI / unit_tests (pull_request) Successful in 5m53s
CI / docker (pull_request) Successful in 1m32s
CI / coverage (pull_request) Successful in 12m27s
CI / e2e_tests (pull_request) Successful in 19m48s
CI / integration_tests (pull_request) Successful in 22m24s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 16s
CI / helm (push) Successful in 22s
CI / lint (push) Successful in 3m17s
CI / quality (push) Successful in 3m39s
CI / typecheck (push) Successful in 3m53s
CI / security (push) Successful in 4m4s
CI / unit_tests (push) Successful in 9m13s
CI / docker (push) Successful in 20s
CI / coverage (push) Successful in 12m20s
CI / e2e_tests (push) Successful in 19m18s
CI / integration_tests (push) Successful in 24m36s
CI / status-check (push) Successful in 2s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-regression (pull_request) Successful in 55m5s
CI / benchmark-publish (push) Successful in 28m26s
Add 8 BDD scenarios in features/fast_init_upgrade.feature that directly exercise the _fast_init_or_upgrade closure installed by _install_template_db_patch in features/environment.py. Scenarios cover all code paths: - Non-empty DB with matching prefix → early return (original NOT invoked) - Non-existent DB with matching prefix → template copied (original NOT invoked) - Existing empty DB with matching prefix → template copied (original NOT invoked) - Non-matching prefix → delegates to original init_or_upgrade - In-memory SQLite → delegates to original init_or_upgrade - Non-SQLite URL → delegates to original init_or_upgrade - Bare sqlite:// URL → delegates to original init_or_upgrade - Delegation forwards runner instance and keyword arguments correctly Test infrastructure: - features/mocks/fast_init_test_helpers.py provides a context manager (patch_original_init_or_upgrade) that replaces the _original_init_or_upgrade reference inside the closure via cell_contents manipulation, enabling precise call-tracking without recreating the function under test. - All scenarios tagged @mock_only to skip unnecessary DB setup. - Cleanup registered via context._cleanup_handlers for temp file removal. - Works in both sequential and parallel execution modes. Review fix round: - Added bare sqlite:// URL scenario covering the second branch of the in-memory disjunction (L1). - Added scenario verifying runner instance and keyword argument forwarding through the delegation path (L2, L3). - Replaced hardcoded test credentials with clearly synthetic pattern (I4). - Fixed CHANGELOG wording that incorrectly claimed mktemp replacement (L5). ISSUES CLOSED: #733 |