Skip to content

tests: fix flaky test_conflict_resolution.cpp fixed-sleep race - #83

Merged
Yaraslaut merged 1 commit into
masterfrom
fix/conflict-resolution-flaky-sleep
Aug 13, 2026
Merged

tests: fix flaky test_conflict_resolution.cpp fixed-sleep race#83
Yaraslaut merged 1 commit into
masterfrom
fix/conflict-resolution-flaky-sleep

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

Summary

Pre-existing flaky test, unrelated to any currently-open PR (present since #17). Every test in test_conflict_resolution.cpp called bridge.switchBackend() then slept a fixed 80ms hoping onBackendChanged() (which asynchronously drains the offline queue on the new backend's thread pool) had finished by then, before asserting on the queue/notifyCount. Under contention — a coverage-instrumented build, a busy CI runner, Valgrind's own overhead — 80ms isn't always enough.

Confirmed reproducing on 3 independent CI jobs while investigating an unrelated PR's CI (Linux clang-debug, Linux Qt6-WebSockets, Valgrind memcheck), and separately in a local WSL coverage build.

Fix

Replaces all 5 fixed sleep_for(80ms) sites with waitForBackendChanged(), which polls the model's own notifyCount (via the existing read-only OrderQueryAction, already used by these tests) until it reaches the expected value — the real signal that onBackendChanged has run, and therefore that its queue drain has too — instead of guessing a fixed delay. Bounded at 2 seconds, matching the existing waitInt helper's own budget, so a genuine regression still fails fast rather than hanging.

Verification

  • Local build: [conflict] tests run 5x back-to-back, all green.
  • Full suite: 987/987 passed (excluding one known-flaky local-only QML test-runner artifact, confirmed unrelated by reproducing it identically on unmodified master).

🤖 Generated with Claude Code

…a poll on notifyCount

Pre-existing, unrelated to any open PR (present since #17): each test
called bridge.switchBackend() then slept a fixed 80ms hoping
onBackendChanged() (which drains the offline queue on the new
backend's thread pool) had finished by then, before asserting on the
queue/notifyCount. Under contention -- a coverage-instrumented build,
a busy CI runner, Valgrind's own overhead -- 80ms isn't always enough,
so REQUIRE(queue.drain().empty()) intermittently sees a queue that
hasn't drained yet. Confirmed reproducing on 3 independent CI jobs
(Linux clang-debug, Linux Qt6-WebSockets, Valgrind memcheck) and,
separately, in a local WSL coverage build.

Adds waitForBackendChanged(), which polls the model's own notifyCount
(via the existing read-only OrderQueryAction, already used by these
tests) until it reaches 1 -- the real signal that onBackendChanged has
run, and therefore that its queue drain has too -- instead of guessing
a fixed delay. Bounded at 2 seconds, matching waitInt's own budget.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Yaraslaut
Yaraslaut merged commit 5101e36 into master Aug 13, 2026
21 checks passed
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.

1 participant