Fix flaky test_expiration and speed up test_persistent_cache suite - #825
Open
ptpt wants to merge 3 commits into
Open
Fix flaky test_expiration and speed up test_persistent_cache suite#825ptpt wants to merge 3 commits into
ptpt wants to merge 3 commits into
Conversation
ptpt
commented
Aug 3, 2026
Member
- Fix flaky test_expiration on loaded CI runners
- Speed up test_persistent_cache stress tests (~3.3x faster)
The test set a cache entry with expires_in=1 and immediately read it back. On heavily loaded runners (e.g. Windows under SQLite lock contention) the set->get latency could exceed 1s, so the entry expired before the immediate read and get() returned None, failing the assert. Widen the short-expiration window to 5s so the immediate read cannot lose the set->get race, while still validating real expiry.
The concurrency stress tests dominated the suite runtime (267s total), with two tests alone accounting for ~74%. Reduce iteration counts while keeping the same concurrent code paths (16-40 workers on a shared SQLite file), so lock-contention and correctness coverage stays intact: - multithread_shared_cache_comprehensive: num_keys 5000 -> 1000 - multiprocess_shared_cache_comprehensive: keys_per_process 1000 -> 250 - multiprocess_write_without_database_lock_errors: 10000 -> 2000 keys - multiprocess/multithread_sqlite_database_locking: num_items 4000 -> 1000 Suite runtime: 267s -> 81s. No production code changed.
The repo had no [tool.ruff] config, so 'ruff check mapillary_tools' relied on ruff's built-in defaults. ruff is installed unpinned in CI, and newer ruff versions expanded their default rule set (adding UP, I, BLE, SIM, PL, etc.), which flags ~240 pre-existing issues and fails the lint step. Add an explicit [tool.ruff.lint] select matching ruff's historical default (E4, E7, E9, F) so linting is deterministic regardless of the installed ruff version. No source code changed.
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.