Skip to content

chore(tests): parallelize pkg/common test files - #70

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
chore/tparallel-pkg-common
Apr 25, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
chore/tparallel-pkg-common

Conversation

@cristim

@cristim cristim commented Apr 25, 2026

Copy link
Copy Markdown
Member

Summary

One incremental step toward closing #58 — adopts t.Parallel() across all three test files in pkg/common/. Picked as the safest leaf-package starting point: no os.Setenv, no shared mocks, no package-level mutable state, no shared file paths (each filesystem-touching test uses t.TempDir()).

Per the issue's explicit guidance, this is one package per PR, not a sweeping change. #58 stays open for subsequent packages.

Changes

  • pkg/common/audit_test.go — 7 top-level tests + 1 table-driven t.Run block parallelized.
  • pkg/common/matches_test.go — 3 top-level tests + 1 table-driven t.Run block parallelized.
  • pkg/common/types_test.go — 23 top-level tests + 6 table-driven t.Run blocks parallelized.

Total: 33 top-level test functions and 8 sub-test loops. Loop variables (tc := tc, tt := tt) captured defensively for pre-Go-1.22 safety even though current go.mod targets a newer toolchain — costless and matches the existing style in already-parallelized packages.

Audit findings

Risk Status
os.Setenv/t.Setenv None present
Package-level mutable state None — only engine.go's read-only engineNameMap (concurrent-read safe)
Shared filesystem paths None — t.TempDir() everywhere
Shared mocks/fixtures None — all fixtures stack-local

Verification

  • go test -race -count=2 ./common/... — clean (~2.78s wall-clock vs ~3.12s baseline).
  • go test -race -count=3 ./common/... — clean.
  • go vet ./common/... — clean.
  • go build ./... — clean for both root module and pkg/ submodule.
  • === PAUSE traces in -v output confirm the runtime is genuinely scheduling tests in parallel.

Status of #58

Adopted (already done before this PR):

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

This PR adds: pkg/common/{audit,matches,types}_test.go.

Still pending audit + parallelization (kept for follow-up PRs):

  • internal/api/ other test files (handler fixtures + shared mocks)
  • internal/config/*_test.go integration tests (share Postgres container — needs schema isolation)
  • internal/server/app_test.go (package-level vars runMigrations, migrationsTimeout)
  • pkg/errors/, pkg/logging/, pkg/scorer/, pkg/config/, pkg/provider/, providers/azure/, providers/gcp/, cmd/, cmd/server/, cmd/lambda/, internal/database/

Test plan

  • go test -race -count=2 ./pkg/common/... from pkg/ submodule
  • go test -race -count=3 ./pkg/common/... (extra repetition for flake hunting)
  • go vet ./pkg/common/...
  • go build ./... (both modules)
  • CI green on push (will be verified by ci-watch)

Refs #58

Adopts t.Parallel() across all three pkg/common test files
(audit_test.go, matches_test.go, types_test.go) — 33 top-level test
functions and 8 table-driven subtests now run in parallel.

Audit findings (per #58 checklist):
- No os.Setenv/t.Setenv usage — no process-wide state.
- No package-level mutable fixtures — only engine.go's read-only
  engineNameMap, which is safe for concurrent readers.
- All filesystem-touching tests use t.TempDir() — per-test isolation.
- Loop variables captured (tc := tc / tt := tt) inside subtest loops
  for pre-Go-1.22 safety, though current go.mod targets 1.22+.

Verified:
- go test -race -count=2 ./common/... clean.
- go test -race -count=3 ./common/... clean.
- go vet ./common/... clean.
- go build ./... clean (root + pkg submodule).

Wall-clock: -race -count=2 went from ~3.12s to ~2.78s locally.

This is one increment of the per-package adoption sweep tracked in
issue #58. Subsequent commits will tackle the other listed packages
(internal/api/* other test files, pkg/retry already done, etc.).
The integration-test packages (internal/config/* sharing Postgres,
internal/server/app_test.go with package vars) require additional
schema-isolation work and stay sequential for now.

Refs #58
@coderabbitai

coderabbitai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@cristim has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 11 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 11 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d3ff485-a0ff-4cb8-a52d-950d320f162f

📥 Commits

Reviewing files that changed from the base of the PR and between c8f58e9 and 96a9bcb.

📒 Files selected for processing (3)
  • pkg/common/audit_test.go
  • pkg/common/matches_test.go
  • pkg/common/types_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/tparallel-pkg-common

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented Apr 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Apr 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 2e33c88 into feat/multicloud-web-frontend Apr 25, 2026
3 checks passed
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-sprint Within the current sprint impact/internal Team-internal only effort/xs Trivial / one-liner type/chore Maintenance / non-user-visible labels Apr 28, 2026
@cristim
cristim deleted the chore/tparallel-pkg-common branch April 29, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant