Fix flaky scheduler test#5030
Open
krMaynard wants to merge 2 commits into
Open
Conversation
The test's final answer schedules a learning card a 10-minute step ahead. When run shortly before the daily cutoff (3:50-4:00 GMT with the default 4am rollover), that step crosses into the next day, so the card is no longer counted as intraday learning and the expected queue counts break. Guard the test with the same near_cutoff() early-return that the sibling timing-sensitive tests (state_application, elapsed_secs) already use, and replace the FIXME with an explanation of the cause.
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.
Linked issue (required)
Fixes #5025
Summary / motivation (required)
scheduler::answering::test::new_limited_by_reviewsinrslib/src/scheduler/answering/mod.rsis time-of-day dependent and fails whenrun between roughly 3:50–4:00 GMT. The source carried a
// FIXME: This fails between 3:50-4:00 GMTcomment documenting the flakiness.The test's final
answer_good()schedules a learning card a 10-minute stepahead. Run shortly before the default 4am rollover, that step crosses into the
next day, so the card is no longer counted as intraday learning and the final
assert_counts!(col, 0, 0, 0)breaks.This guards the test with the same
if col.timing_today()?.near_cutoff() { return Ok(()); }early-return that the sibling timing-sensitive tests in this file
(
state_application,elapsed_secs) already use, and replaces the FIXME with acomment explaining the cause.
near_cutoff()'s 25-minute margin safely coversthe 10-minute step window.
Steps to reproduce (required, use N/A if not applicable)
(the default 4am rollover — i.e. ~03:50–03:59 in the collection's timezone).
cargo test -p anki --lib scheduler::answering::test::new_limited_by_reviews.assert_counts!(col, 0, 0, 0)fails because the last learningcard's 10-minute step lands after the cutoff.
How to test (required)
Checklist (minimum)
./ninja checkor an equivalent relevant check locally.Details
cargo test -p anki --lib scheduler::answering::test::new_limited_by_reviewspasses, and the full
scheduler::answeringmodule passes (5/5). The fix mirrorsthe existing
near_cutoff()guard already used by the two siblingtiming-sensitive tests in the same file.
Before / after behavior (optional)
Before: the test fails non-deterministically in the ~10-minute window before the
daily cutoff. After: it early-returns in the near-cutoff window (25-minute
margin) and runs normally the rest of the day.
Risk / compatibility / migration (optional)
N/A — test-only change, no production behavior affected.
UI evidence (required for visual changes; otherwise N/A)
N/A
Scope