[bug] [test-infra] TestStartSweeper_RecordsMetricsOnSuccess fails in full-suite (suite-state contamination) #86

Open
opened 2026-05-07 22:55:45 +00:00 by claude-ceo-assistant · 0 comments

Summary

internal/pendinguploads/TestStartSweeper_RecordsMetricsOnSuccess passes when run in isolation but fails in the full go test ./... suite. Suite-state contamination from a sibling test (likely the sweeper goroutine outliving its test boundary, or a metrics counter not reset between tests).

Repro

cd molecule-core/workspace-server
go test ./internal/pendinguploads -run TestStartSweeper_RecordsMetricsOnSuccess -v -count=1     # PASS
go test ./internal/pendinguploads -count=1 -v                                                    # FAIL
go test ./...                                                                                    # FAIL

Reproduced on:

  • pre-internal#71 baseline main branch
  • post-internal#71 migrate/issue-71-vanity-imports branch
    Identical failure on both, confirming this predates the migration.

Suspected mechanism

pendinguploads.StartSweeper returns a func() shutdown hook. If a prior test in the same package fails to call its shutdown hook, the sweeper goroutine keeps running with stale state — including the prometheus counter the assertion test checks.

The fix shape is one of:

  1. Make sweeper-state inspection deterministic per-test: each test calls StartSweeper with a fresh ticker channel + asserts on a returned channel (vs polling a shared metric).
  2. Reset the prometheus counter at test setup (per-package init() or t.Cleanup).
  3. Use testify/require with a small backoff on the assertion to absorb the timing — tolerable but doesn't fix the root cause.

Recommend (1).

Class

Pre-existing test brittleness. Filed during the post-internal#71 test sweep on operator host. NOT a regression.

Out of scope

internal#71 (Go module path migration) does not touch this code.

Reporter

Discovered during full-suite testing of the molecule-core vanity-import migration on operator host (5.78.80.188). 2026-05-07.

## Summary `internal/pendinguploads/TestStartSweeper_RecordsMetricsOnSuccess` passes when run in isolation but fails in the full `go test ./...` suite. Suite-state contamination from a sibling test (likely the sweeper goroutine outliving its test boundary, or a metrics counter not reset between tests). ## Repro ``` cd molecule-core/workspace-server go test ./internal/pendinguploads -run TestStartSweeper_RecordsMetricsOnSuccess -v -count=1 # PASS go test ./internal/pendinguploads -count=1 -v # FAIL go test ./... # FAIL ``` Reproduced on: - pre-internal#71 baseline `main` branch - post-internal#71 `migrate/issue-71-vanity-imports` branch Identical failure on both, confirming this predates the migration. ## Suspected mechanism `pendinguploads.StartSweeper` returns a `func()` shutdown hook. If a prior test in the same package fails to call its shutdown hook, the sweeper goroutine keeps running with stale state — including the prometheus counter the assertion test checks. The fix shape is one of: 1. Make sweeper-state inspection deterministic per-test: each test calls `StartSweeper` with a fresh ticker channel + asserts on a returned channel (vs polling a shared metric). 2. Reset the prometheus counter at test setup (per-package `init()` or `t.Cleanup`). 3. Use `testify/require` with a small backoff on the assertion to absorb the timing — tolerable but doesn't fix the root cause. Recommend (1). ## Class Pre-existing test brittleness. Filed during the post-internal#71 test sweep on operator host. NOT a regression. ## Out of scope internal#71 (Go module path migration) does not touch this code. ## Reporter Discovered during full-suite testing of the molecule-core vanity-import migration on operator host (`5.78.80.188`). 2026-05-07.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#86
No description provided.