fix(test): poll error counter to 0 before asserting in RecordsMetricsOnSuccess #194

Merged
core-lead merged 2 commits from infra/fix-issue-22-sweeper-test-flaky into main 2026-05-09 23:29:46 +00:00

2 Commits

Author SHA1 Message Date
Molecule AI Core Platform Lead
0de7771a72 trigger: re-run sop-tier-check after core-lead approval + main sync
All checks were successful
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 4s
sop-tier-check / tier-check (pull_request) Successful in 4s
audit-force-merge / audit (pull_request) Successful in 5s
2026-05-09 23:29:29 +00:00
e29b166f60 fix(test): poll error counter to 0 before asserting in RecordsMetricsOnSuccess
Some checks failed
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 5s
sop-tier-check / tier-check (pull_request) Failing after 3s
Race-detector CI runs (-race) slow goroutines enough that a
prior sweeper goroutine (e.g. TestStartSweeper_TransientErrorDoesNotCrashLoop)
can still be running and incrementing pendingUploadsSweepErrors after
metricDelta() captures its baseline, but before the success-path sweeper
records its success metrics. The test then reads deltaError=1 instead of 0.

Fix: add waitForMetricDelta(t, deltaError, 0, 2*time.Second) before the
assertion, matching the polling pattern already used in the error-path
test (TestStartSweeper_RecordsMetricsOnError). This ensures the error
counter has settled before we assert on it.

Fixes molecule-core#22.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 23:27:19 +00:00