Skip to content

tests: wait for the drive's reads before counting them (#3823) - #4287

Closed
gmrmad1 wants to merge 1 commit into
storytold:mainfrom
gmrmad1:fix/3823-find-similar-read-count
Closed

gmrmad1 wants to merge 1 commit into
storytold:mainfrom
gmrmad1:fix/3823-find-similar-read-count

Conversation

@gmrmad1

@gmrmad1 gmrmad1 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest counts the drive's reads right after the activity row clears, so under load the last reads land after the count and the assertion sees 10 or 11 of 12. The test now also waits, within its existing step_until(T, …) budget, for the drive to record all 12 reads before asserting; the assertions (exactly 12 reads, filter holds half the library) are unchanged.

It also clears the session's in-memory decoded sources before the second search. In the Detail view the loupe's render and neighbour prefetch decode through the same drive, so a search plan can cut a thumbnail from a source already in memory (SourceRef::Fit) without touching the drive — which is the same short count, not a stopped search. Clearing them makes the test measure the scenario it describes (the second search reads the files the stopped one had not read), and the signatures the stopped search kept stay. The same wait is added to the two neighbouring tests that count reads.

Test-only change; no production code.

Ran:

  • rustfmt --edition 2024 --check crates/ui-egui/src/tests/find_similar.rs — clean.

Not run locally: cargo test -p lightcraft-ui-egui --lib -- tests::find_similar spent the run queued behind a heavily contended shared cargo target lock (its dependency build was still in progress when this PR opened), so CI runs it.

Fixes #3823

Summary by CodeRabbit

  • Tests
    • Improved slow-drive test coverage to verify that searches complete all expected photo reads, including scenarios where cached media is reused.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Three find-similar tests now wait for expected photo reads to complete. The stopped-search test also clears cached media sources before retrying and verifies that the retry reads the remaining photos.

Changes: Find-similar test synchronization

Layer / File(s) Summary
Wait for expected photo reads
crates/ui-egui/src/tests/find_similar.rs
The menu-search and timed-out-request tests wait for all expected photo reads. The stopped-search test clears cached media sources before retrying, then waits for the remaining reads.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: eliets2, oneslips

Merge Risk: Minimal · up to 98b9c

This change makes the find-similar tests wait for all expected photo reads before asserting, which should reduce intermittent failures. It has no production-code impact and no concrete merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: tests now wait for the drive's reads before counting them. The raw summary and PR objectives both describe a wait for all 12 reads before the count assertion in find_simila…
Linked Issues check Passed [#3823] The issue asks that the test wait on the drive read count before asserting, as line 152 already does with step_until. The diff adds `assert!(h.step_until(T, |_| drive.reads.load(Ordering::Se…
Out of Scope Changes check Passed All changes are in crates/ui-egui/src/tests/find_similar.rs and are test-only. The added waits are tied to the read-count race in #3823. The h.app.session.media.clear_sources() call is in the same…
Full details: Title check

Explanation

The title names the change: tests now wait for the drive's reads before counting them. The raw summary and PR objectives both describe a wait for all 12 reads before the count assertion in find_similar tests, so the title matches the main change. It is concise and specific. It names the test area (drive reads) and the fix (waiting before counting), and it is not vague or off-topic.

Full details: Linked Issues check

Explanation

[#3823] The issue asks that the test wait on the drive read count before asserting, as line 152 already does with step_until. The diff adds assert!(h.step_until(T, |_| drive.reads.load(Ordering::SeqCst) == PHOTOS as usize), ...) after until_done in stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest before the 12-read assertion. The same wait is added to two neighbouring read-count tests. If the count never reaches 12, step_until returns false and the test fails. The exact-read and filter-size assertions are unchanged. The author did not run the targeted test locally, so the fix is confirmed by code inspection only. The issue has no non-coding requirements.

Full details: Out of Scope Changes check

Explanation

All changes are in crates/ui-egui/src/tests/find_similar.rs and are test-only. The added waits are tied to the read-count race in #3823. The h.app.session.media.clear_sources() call is in the same test and changes its precondition before the second search. The PR justifies it as making the test measure the stated scenario, and the code and diff support that the call exists in this test. That rationale is not verified by a run, and it alters the test's setup beyond what the issue requests. Reviewers should confirm it through the CI run of the targeted test. No unrelated production or other test changes are present.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fa5c438 and 98b9c19.

Files selected for processing: 1

  • crates/ui-egui/src/tests/find_similar.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@gmrmad1

gmrmad1 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Closing — the issue is fixed upstream by the merged #3824, which reworks the same find_similar read-count assertion. Thanks.

@gmrmad1 gmrmad1 closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest counts 10 or 11 reads of 12 under load

1 participant