Skip to content

test: run small-package tests in parallel - #1390

Merged
bootjp merged 3 commits into
mainfrom
test/parallel-small-packages
Nov 7, 2026
Merged

bootjp merged 3 commits into
mainfrom
test/parallel-small-packages

Conversation

@bootjp

@bootjp bootjp commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Summary

Adds t.Parallel() to 208 top-level tests in ./cmd/..., ./internal, ./internal/backup, ./internal/peersession, ./internal/raftadmission, ./internal/snapshotoffload, ./internal/s3keys, ./internal/testutil/..., ./keyviz, ./distribution/autosplit, ./store/storetest, ./internal/raftengine/raftenginetest, ./internal/encryption/encryptiontest that did not call it (1038 already did). Part of the effort to parallelize the Go test suite; CI-side sharding is in #1387.

Candidates were picked with a go/ast scan that skips any test which (directly or through same-package helpers) calls t.Setenv/os.Setenv/os.Chdir, writes a package-level variable from test code, calls process-global setters (slog.SetDefault, prometheus.MustRegister, signal.Notify, runtime.GOMAXPROCS(n), …), or carries a comment about parallelism.

Left serial (27 tests):

  • 9 assign flag package globals (cmd/elastickv-split 8 via resetFlags, cmd/elastickv-list-routes 1).
  • 9 use t.Setenv / os.Unsetenv (cmd/raftadmin 6, internal/backup 2, cmd/elastickv-admin 1).
  • 3 swap os.Stdout through captureStdout (cmd/raftadmin).
  • 1 asserts allocations with testing.AllocsPerRun (internal/peersession).
  • 1 asserts runtime.NumGoroutine (internal/snapshotoffload).
  • 1 has a comment explaining why it is not parallel (cmd/server).
  • 3 reverted by hand in internal: TestGRPCForwardTokenOnlyAuthenticatesPeerForward, TestConfigureGRPCTLSValidatesFiles, TestGRPCTLSCommonOptionsVerifyPeer. They call ConfigureGRPCForwardToken / ConfigureGRPCTLS, which store into the package-level atomics grpcForwardToken / grpcTLS. The scan cannot see that because the write happens through a method call. Each one has a // Not parallel: comment naming the global.

cmd/* tests were checked by hand. The parallelized ones call run(args, …) with their own flag.FlagSet, or pure helpers. None of them reads flag.CommandLine, os.Args, or os.Stdout. TestProductionImportGuard execs a subprocess but passes its env through cmd.Env, not the process environment.

Behavior change / risk

Test-only. No production code changes. The risk is a hidden shared-state flake that -count=3 did not catch. Each package's serial tests still finish before its parallel tests resume, so the serial tests that change globals cannot overlap the new parallel ones.

Test evidence

  • go test -race -count=3 on all listed packages: ok
  • package time (-race -count=1), before → after (the machine was under heavy load from other test runs, load average about 10–14, so these numbers are noisy):
    • cmd/elastickv-admin 6.0s → 6.7s, cmd/elastickv-snapshot-archive 2.6s → 1.5s, cmd/elastickv-snapshot-offload 4.0s → 3.0s, cmd/elastickv-snapshot-prepare-restore 4.0s → 3.0s, other cmd/* about 1.4–2.7s → 1.1–2.7s
    • internal 1.7s → 1.4s, internal/backup 5.8s → 4.7s, internal/peersession 4.9s → 3.1s, internal/raftadmission 2.0s → 2.0s, internal/s3keys 2.0s → 1.7s, internal/testutil 2.3s → 2.0s
    • internal/snapshotoffload 31.9s → 20–53s across reruns (origin/main reran at 20.2s under the same load). The package is dominated by tests that were already parallel or are serial (TestSchedulerStaggerDoesNotAccumulateAcrossGroups ~9.6s, TestSchedulerBoundsScanGoroutines ~8.6s), so the spread is load noise.
    • keyviz, distribution/autosplit, store/storetest, raftenginetest, encryptiontest: about 1.4–2.0s, unchanged within noise
  • golangci-lint run on all listed packages: 0 issues
  • gofmt -l: clean
  • No pre-existing flakes observed.

Self-review

  1. Data loss: Not applicable. Only test scheduling changes; no storage, Raft, or FSM code is touched.
  2. Concurrency: Tests that write package globals (flag vars, os.Stdout, env, grpcTLS, grpcForwardToken) stay serial. The new parallel tests use t.TempDir(), 127.0.0.1:0 listeners, and per-test fixtures. encryptiontest nonce IDs come from an atomic counter. Passed -race -count=3.
  3. Performance: Wall time drops in most packages. Tests that measure goroutines or allocations stay serial.
  4. Data consistency: Not applicable. No production code changes.
  5. Test coverage: Unchanged. No test logic was modified apart from the t.Parallel() lines and three comments.

Signed-off-by: bootjp <contact@bootjp.me>
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b55d38d5-c554-42c8-be33-018517514122
Commits

Reviewing files that changed from the base of the PR and between 07f6391 and 373407f.

Files selected for processing: 46

  • cmd/elastickv-list-routes/main_test.go
  • cmd/elastickv-route-key/main_test.go
  • cmd/elastickv-snapshot-archive/main_fifo_unix_test.go
  • cmd/elastickv-snapshot-archive/main_test.go
  • cmd/elastickv-snapshot-offload/main_test.go
  • cmd/elastickv-snapshot-prepare-restore/main_fifo_unix_test.go
  • cmd/elastickv-snapshot-prepare-restore/main_test.go
  • cmd/raftadmin/main_test.go
  • cmd/redis-proxy/main_test.go
  • cmd/server/demo_test.go
  • distribution/autosplit/detector_rapid_test.go
  • internal/backup/archive_hardlink_unix_test.go
  • internal/backup/archive_test.go
  • internal/backup/live_producer_test.go
  • internal/backup/snapshot_reader_live_test.go
  • internal/cleanup_test.go
  • internal/encryption/encryptiontest/fixtures_test.go
  • internal/grpc_forward_auth_test.go
  • internal/grpc_tls_test.go
  • internal/peersession/authorizer_test.go
  • internal/peersession/format_test.go
  • internal/peersession/lifecycle_test.go
  • internal/peersession/limits_test.go
  • internal/peersession/method_factory_test.go
  • internal/peersession/mixed_methods_test.go
  • internal/peersession/native_test.go
  • internal/peersession/negative_test.go
  • internal/peersession/recovery_test.go
  • internal/peersession/snapshot_stream_test.go
  • internal/raftadmission/arbiter_test.go
  • internal/raftadmission/prepared_test.go
  • internal/raftadmission/publication_test.go
  • internal/raftadmission/registration_binding_test.go
  • internal/raftadmission/request_rotation_test.go
  • internal/raftadmission/rotation_review_test.go
  • internal/raftadmission/rotation_test.go
  • internal/raftengine/raftenginetest/helpers_test.go
  • internal/s3keys/keys_test.go
  • internal/snapshotoffload/offload_test.go
  • internal/snapshotoffload/s3_store_test.go
  • internal/testutil/cmd/importguard/main_test.go
  • internal/testutil/grpctest/grpc_test.go
  • internal/testutil/production_imports_test.go
  • internal/testutil/testutil_test.go
  • keyviz/flusher_test.go
  • store/storetest/store_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T13:11:21.648718Z 88a5da5 New commits
🔒 Security Review ✅ Completed 2026-11-06T13:13:16.595130Z 88a5da5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (56876a6):

  • distribution/autosplit/detector_rapid_test.go

What to check, by subsystem:

  • kv/hlc*.go — Next() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (the TSO allocation floor; legacy modes have none and are pinned as known gaps), and the NextFenced ceiling fence (fail-closed when wall_now >= physicalCeiling or when the next value's physical half exceeds it). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/tso*.go — RaftTSOAllocator must Observe the committed allocation floor before reserving and commit the new floor before handing a window out (HLC.tla IssuanceMode = "tso").
  • kv/coordinator.go, kv/sharded_coordinator.go — RunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and which node stamps StartTS / CommitTS (HLC-3; legacy ShardedCoordinator stamping is the known gap G10). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on (OCC.tla; G0 / G1 are pinned as known gaps).
  • kv/fsm.go, kv/fsm_migration_serving.go — FSM apply of HLC lease entries (SetPhysicalCeiling), the one-phase / PREPARE / COMMIT validation OCC.tla models, verifyComposed1, and the migration serving guard Composed.tla relies on for unpinned writes.
  • store/mvcc_store.go, store/lsm_store.go — version visibility, resumable compaction, the commit-ts apply fence, and the MVCC-1 / MVCC-4 / MVCC-5 invariants.
  • adapter/ts.go — the snapshot start timestamp OCC.tla assumes (applied watermark; MaxUint64 on an empty store).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (88a5da5):

  • distribution/autosplit/detector_rapid_test.go

What to check, by subsystem:

  • kv/hlc*.go — Next() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (the TSO allocation floor; legacy modes have none and are pinned as known gaps), and the NextFenced ceiling fence (fail-closed when wall_now >= physicalCeiling or when the next value's physical half exceeds it). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/tso*.go — RaftTSOAllocator must Observe the committed allocation floor before reserving and commit the new floor before handing a window out (HLC.tla IssuanceMode = "tso").
  • kv/coordinator.go, kv/sharded_coordinator.go — RunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and which node stamps StartTS / CommitTS (HLC-3; legacy ShardedCoordinator stamping is the known gap G10). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on (OCC.tla; G0 / G1 are pinned as known gaps).
  • kv/fsm.go, kv/fsm_migration_serving.go — FSM apply of HLC lease entries (SetPhysicalCeiling), the one-phase / PREPARE / COMMIT validation OCC.tla models, verifyComposed1, and the migration serving guard Composed.tla relies on for unpinned writes.
  • store/mvcc_store.go, store/lsm_store.go — version visibility, resumable compaction, the commit-ts apply fence, and the MVCC-1 / MVCC-4 / MVCC-5 invariants.
  • adapter/ts.go — the snapshot start timestamp OCC.tla assumes (applied watermark; MaxUint64 on an empty store).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

…dline

TestRunLiveBackupStopsRenewalBeforeManifestPublication failed the rest
shard with "renew live backup pin: context deadline exceeded". The fake
releases the stream only once the renewal RPC is in flight, and at a
300ms TTL that RPC's attempt timeout is 100ms, so streaming plus
finalize had to finish within 100ms for stop() to end the renewal. Under
-race on a loaded runner it overran and the test took the deadline
route instead.

A 3000ms TTL leaves 1s. The failure predates the t.Parallel additions:
the test was already parallel on main and failed there too.

Measured with go test -race -count=10 ./internal/backup: 3 failures
before, 0 after.

Signed-off-by: bootjp <contact@bootjp.me>
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (373407f):

  • distribution/autosplit/detector_rapid_test.go

What to check, by subsystem:

  • kv/hlc*.go — Next() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (the TSO allocation floor; legacy modes have none and are pinned as known gaps), and the NextFenced ceiling fence (fail-closed when wall_now >= physicalCeiling or when the next value's physical half exceeds it). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/tso*.go — RaftTSOAllocator must Observe the committed allocation floor before reserving and commit the new floor before handing a window out (HLC.tla IssuanceMode = "tso").
  • kv/coordinator.go, kv/sharded_coordinator.go — RunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and which node stamps StartTS / CommitTS (HLC-3; legacy ShardedCoordinator stamping is the known gap G10). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on (OCC.tla; G0 / G1 are pinned as known gaps).
  • kv/fsm.go, kv/fsm_migration_serving.go — FSM apply of HLC lease entries (SetPhysicalCeiling), the one-phase / PREPARE / COMMIT validation OCC.tla models, verifyComposed1, and the migration serving guard Composed.tla relies on for unpinned writes.
  • store/mvcc_store.go, store/lsm_store.go — version visibility, resumable compaction, the commit-ts apply fence, and the MVCC-1 / MVCC-4 / MVCC-5 invariants.
  • adapter/ts.go — the snapshot start timestamp OCC.tla assumes (applied watermark; MaxUint64 on an empty store).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@bootjp
bootjp merged commit 5461121 into main Nov 7, 2026
21 checks passed
@bootjp
bootjp deleted the test/parallel-small-packages branch November 7, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant