Skip to content

chore(tests): finish t.Parallel() adoption sweep across remaining packages #58

@cristim

Description

@cristim

Summary

t.Parallel() adoption is partial — only pkg/exchange/{auto,exchange,reshape}_test.go, providers/aws/services/ec2/client_test.go, and internal/api/validation_test.go have been audited and parallelized. Other packages keep sequential execution because each needs a per-test-file shared-state audit before it's race-safe to parallelize.

Captured in: known-issues.md → "Outstanding follow-ups" → "t.Parallel() adoption for remaining packages".

Current state

Adoption complete:

  • pkg/exchange/{auto,exchange,reshape}_test.go
  • providers/aws/services/ec2/client_test.go
  • internal/api/validation_test.go

Pending audit + parallelization (each carries shared-state risk):

  • internal/api/ other test files — handler fixtures + shared mocks; not race-safe without review.
  • internal/config/*_test.go integration tests — share a Postgres container; cannot naively parallelize.
  • internal/server/app_test.go — uses package-level vars (runMigrations, migrationsTimeout) that are not race-safe.
  • Any test file using os.Setenv / t.Setenv for process-wide state — needs verification that the variable scope is per-test (Go ≥1.17 t.Setenv is correct).

Why this matters

go test ./... for the project currently runs each package sequentially. Per-package parallelism would meaningfully reduce CI wall-clock without materially changing test design. Expected speedup is incremental (a few minutes off the suite) but compounds across CI runs.

Steps to verify the gap

grep -rL "t.Parallel" $(find . -name "*_test.go" | xargs grep -l "func Test" | grep -v vendor) | head
# Lists test files that currently never call t.Parallel

Proposed approach

Per-package incremental audit commits, NOT a single sweeping change:

  1. Pick one package at a time (start with internal/api/ test files that don't touch the shared Postgres container).
  2. Audit each test for: os.Setenv (use t.Setenv instead), package-level fixtures, shared mocks (move to per-test setup), shared file paths.
  3. Add t.Parallel() to test functions and (where needed) sub-tests.
  4. Run go test -race -count=2 ./<pkg>/... to confirm no flakes.
  5. Commit per package with chore(tests): parallelize <pkg>.

For integration tests sharing a Postgres container: use sub-test t.Run with t.Parallel() only after introducing per-test-schema isolation, OR keep them sequential and parallelize only unit-level tests within the same package.

References

  • Known-issue doc: known-issues.md → "t.Parallel() adoption for remaining packages".
  • Already-done examples: pkg/exchange/auto_test.go, internal/api/validation_test.go.

Severity

Low — quality-of-life CI improvement, no functional impact.

Effort

Variable per package — small for unit-only packages (~30 min audit + parallelize), larger for integration-test packages (require schema-isolation or stay sequential). Best handled as a series of small per-package commits.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions