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

Closed
core-fe wants to merge 1 commits from fix/sweeper-race-error-counter into main
Member

Summary

Race-detector CI runs (-race) are slow enough that a prior sweeper goroutine (TestStartSweeper_TransientErrorDoesNotCrashLoop) may still be running and incrementing pendingUploadsSweepErrors after RecordsMetricsOnSuccess captures its metricDelta() baseline, but before the success-path assertion. 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.

Files

  • workspace-server/internal/pendinguploads/sweeper_test.go — RecordsMetricsOnSuccess now polls deltaError to 0 before asserting

Test plan

  • go test -race ./internal/pendinguploads/... in slow CI environment
  • No flakiness in TestStartSweeper_RecordsMetricsOnSuccess

Fixes molecule-core#22.

🤖 Generated with Claude Code

## Summary Race-detector CI runs (-race) are slow enough that a prior sweeper goroutine (TestStartSweeper_TransientErrorDoesNotCrashLoop) may still be running and incrementing pendingUploadsSweepErrors after RecordsMetricsOnSuccess captures its metricDelta() baseline, but before the success-path assertion. 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. ## Files - workspace-server/internal/pendinguploads/sweeper_test.go — RecordsMetricsOnSuccess now polls deltaError to 0 before asserting ## Test plan - [ ] go test -race ./internal/pendinguploads/... in slow CI environment - [ ] No flakiness in TestStartSweeper_RecordsMetricsOnSuccess Fixes molecule-core#22. 🤖 Generated with Claude Code
core-fe added 1 commit 2026-05-09 23:23:05 +00:00
fix(test): poll error counter to 0 before asserting in RecordsMetricsOnSuccess
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 4s
sop-tier-check / tier-check (pull_request) Failing after 4s
audit-force-merge / audit (pull_request) Has been skipped
e522547035
Race-detector CI runs (-race) are slow enough that a prior sweeper
goroutine (TestStartSweeper_TransientErrorDoesNotCrashLoop) may still
be running and incrementing pendingUploadsSweepErrors after
RecordsMetricsOnSuccess captures its metricDelta() baseline, but before
the success-path assertion. 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>
core-fe closed this pull request 2026-05-09 23:24:25 +00:00
Some checks are pending
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 4s
Required
Details
sop-tier-check / tier-check (pull_request) Failing after 4s
audit-force-merge / audit (pull_request) Has been skipped
CI / all-required (pull_request)
Required
E2E API Smoke Test / E2E API Smoke Test (pull_request)
Required
Handlers Postgres Integration / Handlers Postgres Integration (pull_request)
Required
qa-review / approved (pull_request_target)
Required
security-review / approved (pull_request_target)
Required
reserved-path-review / reserved-path-review (pull_request_target)
Required

Pull request closed

Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#195