Skip to content

test(discovery): fix second-boundary race in refresh error timestamp check - #4497

Merged
stevenvegt merged 1 commit into
masterfrom
fix/refresh-error-timestamp-assert
Sep 9, 2026
Merged

test(discovery): fix second-boundary race in refresh error timestamp check#4497
stevenvegt merged 1 commit into
masterfrom
fix/refresh-error-timestamp-assert

Conversation

@stevenvegt

Copy link
Copy Markdown
Member

Fixes a flaky assertion in Test_sqlStore_setPresentationRefreshError/store, seen on the CI run of #4492 (a PR that changes only shell scripts).

LastOccurrence is stored as time.Now().Unix(), whole seconds. The test asserted it is strictly greater than time.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 and S > S fails. The window is a few milliseconds per second, hence the low failure rate.

The test now captures time.Now().Unix() before the call and asserts LastOccurrence >= before, which holds regardless of where the second boundary falls. Verified with -count=20. The other two Add(-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.

…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
@qltysh

qltysh Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

This PR will not change total coverage.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@stevenvegt
stevenvegt merged commit c07c3a1 into master Sep 9, 2026
14 checks passed
@stevenvegt
stevenvegt deleted the fix/refresh-error-timestamp-assert branch September 9, 2026 09:40
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.

2 participants