test(discovery): fix second-boundary race in refresh error timestamp check - #4497
Merged
Conversation
…check LastOccurrence is stored as whole seconds. The assertion compared it with "now minus one second", also truncated, using strict greater-than. When the store happens at the end of a second and the check runs in the next one, both truncate to the same value and the assertion fails. Compare against a timestamp taken before the call instead. Assisted-by: AI
stevenvegt
requested review from
Dirklectisch,
JorisHeadease,
gerardsn,
reinkrul and
woutslakhorst
as code owners
September 9, 2026 09:00
Contributor
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
reinkrul
approved these changes
Sep 9, 2026
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.

Fixes a flaky assertion in
Test_sqlStore_setPresentationRefreshError/store, seen on the CI run of #4492 (a PR that changes only shell scripts).LastOccurrenceis stored astime.Now().Unix(), whole seconds. The test asserted it is strictly greater thantime.Now().Add(-1*time.Second).Unix(), also whole seconds. If the store lands at the end of second S and the assertion runs a few milliseconds later in second S+1, both sides truncate to S andS > Sfails. The window is a few milliseconds per second, hence the low failure rate.The test now captures
time.Now().Unix()before the call and assertsLastOccurrence >= before, which holds regardless of where the second boundary falls. Verified with-count=20. The other twoAdd(-time.Second).Unix()uses in the repo construct expired credentials on purpose and are not affected.Backport to V6.2 follows; V5.4 does not have this test.