Deflake `TestRequestScan` with `synctest` #54700
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 432 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.363
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #54700"
general
weight: 0.35
Pierre-L42
What does this PR do?
Wrap
TestRequestScanandTestQueueDueScansinsynctest"bubbles", replacingassert.EventuallyWithT's real-clock polling withsynctest.Wait().Motivation
Stumbled upon the following flake when running tests locally through
bazelwith flake detection:It turns out the flake also triggers at times in CI (example).
scanWorkers = 2and nothing in the scan chain sleeps, so 4 queued devices need 2 waves, and a contended runner can occasionally make the second wave outlastEventuallyWithT's fixed 2 seconds.TestQueueDueScansshares the same worker pool and queuing code, hence the same theoretical exposure, though its 2 due scans against 2 workers never actually need a second wave.With
synctestfakingtime, the bubble's clock advances once every goroutine is durably blocked, so the completion check can no longer time out against wall clock.Describe how you validated your changes
40/40 tests in the package pass under
-race, both tests pass 30/30 repeated-raceruns, and timing improves as a side effect: the same passing subtest averages ~130ms before this change versus ~35ms after.