Repository navigation
test: t.Parallel across seventeen files, and one test that passed by luck (#179) - #374
Merged
Merged
Conversation
…luck (#179) 278 of the paralleltest/tparallel backlog cleared: 570 lint findings to 299. t.Parallel() on every test and subtest in pkg/errors, pkg/status, pkg/health, pkg/recovery, pkg/retry, pkg/api, pkg/utils, pkg/types, internal/cache and internal/metrics. CLAUDE.md already required this; the finding count was the gap between the requirement and the tree. Each package ran under -race -count=2 after the change with its coverage checked against its floor, because parallelizing a test that shares state is a way to make it pass less often rather than a way to make it faster. Two packages resisted, and both are why this was worth doing rather than suppressing. pkg/health's TestTracker_CanRead had a real order dependency. It wrote a component's State directly and asserted what CanRead answered, but State alone does not decide that: admissionState admits one probe against a refusing component once nextProbe has elapsed, and reports StateDegraded to get that probe past the gate. So State=StateUnavailable with a zero-value nextProbe — always in the past — reads as readable, a combination the tracker never produces, since RecordError sets both fields and the test set one. One tracker shared across the table concealed it. The first subtest to reach a refusing state took the probe path, pushing nextProbe ProbeAfter into the future, and every later subtest then read raw state and agreed with the table. Giving each subtest its own tracker — the isolation t.Parallel requires — removed the accident and the unavailable case failed with CanRead() = true, want false. Fixed by setting nextProbe alongside State in the shape RecordError leaves it, and verified by deleting that line and watching the case fail. No production defect: the tracker's own path sets both fields together. What was broken is a test that could not have caught it if they came apart. pkg/utils/debug_mode_test.go's 19 findings cannot be fixed by a t.Parallel at all. DebugManager is a sync.Once singleton with no exported constructor, and RecordEvent fans every event out to all open sessions, so a session's event count depends on what every concurrently-open session recorded. Measured: "Expected 1 event, got 17", and five other counts inflated by siblings' traffic, with no data race — the locking is correct and the broadcast does what it is written to do. Excluded in .golangci.yml with that reasoning and filed as #373, rather than silenced with a t.Parallel that would leave the tests sequential in effect and the lint green.
This was referenced Aug 6, 2026
…ndown-179 # Conflicts: # CHANGELOG.md
Runs 31126521849 (CI) and 31126521846 (Security) were created at 18:57Z during the incident and never materialized as jobs: both report status=queued with zero jobs and run_attempt=1, despite a `gh run rerun --failed` being accepted at 20:25Z. Their three cancelled checks — Security Scan, docs-site, and fuzz-smoke (./internal/storage/s3, FuzzRoundTrip) — each recorded steps=0 after sitting queued 77-87 minutes, which is the queue timeout GitHub's incident warned about rather than any finding. The other 27 checks on this PR passed. Nothing about the tree changed. The incident was mitigated at 00:06Z and the same approach on #379 dispatched immediately, so this is a clean re-dispatch rather than a fix.
scttfrdmn
added a commit
that referenced
this pull request
Aug 7, 2026
Four conflicts, all in tests both sides had independently improved, and
three of the four would not compile if resolved to main's side:
- internal/cache/persistent_test.go — main added an outer tmpDir that the
body never uses (each subtest makes its own), so it would be an unused
variable. Kept this branch's plain t.Parallel().
- pkg/api/server_test.go (x2) — kept NewRequestWithContext(t.Context(), …)
over plain NewRequest, so the request dies with the test.
- pkg/health/health_test.go — both sides fix the same bug. Kept the side
that drives the component through transitionState, which already arms
nextProbe (health.go:469-474); main's side hand-assigns State and
nextProbe and can therefore drift from production.
- pkg/recovery/recovery_test.go — main's DegradedState literal leaves
`config` undefined and mismatches every assertion below it
("test-component", "read-object: boom", AttemptCount, RecoveryBackoff).
Kept markDegraded through the production path.
Also deletes .golangci.yml's paralleltest exclusion for
pkg/utils/debug_mode_test.go, which arrived from main via #374. Its
rationale said "#373 tracks giving the manager a constructor … which is
the fix that makes the exclusion removable" — this branch is that fix:
NewDebugManager exists (debug_mode.go:60) and the file now has 19
t.Parallel() calls. Leaving the exclusion would suppress a linter that
has nothing left to report.
scttfrdmn
added a commit
that referenced
this pull request
Aug 7, 2026
Second sync: #374 and #375 both landed after this branch's last merge. - go.mod / go.sum — kept substrate v0.93.0 over main's v0.92.0. Same bump, this branch is one release ahead; `go mod tidy` is clean at v0.93.0. - CHANGELOG.md, three regions — two were both-sides additions to the same section, kept in full. The third is the substrate entry both sides wrote: kept the v0.93.0 text, which also carries the v0.93.0-only finding that If-None-Match and If-Match sent together answer 412. Also corrects a paragraph #375 left true-when-written and false-on-merge. It said "#373's fix plan also called for deleting a .golangci.yml exclusion for debug_mode_test.go. There is no such exclusion" — accurate when #375 was cut, but #374 added that exclusion, and merging main into #375 deleted it. Rewritten to say what actually happened, since the interesting fact is that merge order decided whether a dead suppression survived.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #179. Does not close it — the remaining 299 findings are other linters plus 141
paralleltest/tparallelin packages not touched here.The number
paralleltesttparallelt.Parallel()on every test and subtest in seventeen files acrosspkg/errors,pkg/status,pkg/health,pkg/recovery,pkg/retry,pkg/api,pkg/utils,pkg/types,internal/cacheandinternal/metrics. CLAUDE.md already requires this; the finding count was the gap between the requirement and the tree.Every package was run under
-race -count=2after the change and its coverage checked against its floor. That matters more than it sounds: parallelizing a test that shares state is a way to make it pass less often, not a way to make it faster, so a green single run proves nothing.Two packages resisted, and that is the point
pkg/health— a test that was passing on subtest orderingTestTracker_CanReadwrote a component'sStatedirectly and asserted whatCanRead/CanWriteanswered. ButStatealone does not decide that.admissionStateadmits one probe against a refusing component oncenextProbehas elapsed, and reportsStateDegradedto get that probe past the gate:So
State=StateUnavailablewith a zero-valuenextProbe— always in the past — reads as readable. That is not a combination the tracker ever produces:RecordErrorsets both fields, and the test set one.One tracker shared across the table concealed it. The first subtest to reach a refusing state took the probe path, which pushed
nextProbeProbeAfterinto the future, and every later subtest then read raw state and agreed with the table. The assertion held on the order its siblings happened to run in.Giving each subtest its own tracker — the isolation
t.Parallel()requires anyway — removed the accident, and the unavailable case failed immediately:Fixed by setting
nextProbealongsideState, in the shapeRecordErrorleaves it. Verified by deleting that line: the unavailable case fails.-race -count=5green after.No production defect — the tracker's own code path sets both fields together. What was broken is a test that could not have caught it if they came apart.
pkg/utils/debug_mode_test.go— 19 findings at.Parallel()cannot fixFiled as #373 and excluded in
.golangci.ymlwith the reasoning recorded.DebugManageris async.Oncesingleton with no exported constructor, so every test observes the same instance. That alone would be workable — each test already uses a distinct session ID. The blocker isDebugManager.RecordEvent, which fans every event out to all open sessions:A session's event count is therefore a function of what every other concurrently-open session recorded. Adding
t.Parallel()to all 19 and running-race -count=4:No data race — the locking is correct, and the broadcast is doing exactly what it is written to do. Suppressed rather than silenced with a false
t.Parallel(), which would have left the tests sequential in effect and the lint green: the worst of both. #373 proposes an exported constructor so each test can own a manager, which is the fix that makes the exclusion removable.A note on the transform
The mechanical pass had a bug worth mentioning because it produced a loud failure rather than a quiet one. Its first version inserted
t.Parallel()without checking whether the closure already called it further down, which yieldspanic: testing: t.Parallel called multiple timesinpkg/api. Fixed to scan the closure body up to its first nestedt.Run, reverted and reapplied — 2 insertions rather than 4 in that file. All seventeen files were then scanned for doubled calls; none.Verification
Coverage held at each package's floor:
pkg/status93.0%,pkg/health93.5%, and the rest unchanged.