Repository navigation
ci: shard race tests into parallel jobs - #1387
Conversation
Signed-off-by: bootjp <contact@bootjp.me>
|
Warning Review limit reachedYou'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 15 minutes. View limit details
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. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f675f70e1e
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: bootjp <contact@bootjp.me>
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
## Summary Adds `t.Parallel()` to 414 top-level tests in `./kv` and `./kv/kvtest` that did not call it (399 in `kv`, 15 in `kvtest_test`; 1040 in `kv` 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 (5 tests): - writes a package-level hook/knob from test code (3): `TestEncodeObservedRouteVersionZeroGatedForRollingUpgrade` (`observedRouteVersionZeroWireEncodingEnabled`), `TestLeaseState_InvalidateClearsExpiryBeforeBumpingGen` (`onInvalidateBetweenStores`, already documented as not parallel), `TestTransactionManagerBatchesConcurrentRawCommits` (`rawBatchWindow`) - `t.Setenv` (1): `TestTSOControlDiskReopen` - re-execs itself as a crash child via `os.Exit` (1): `TestFSMApplyBatch_CrashBetweenRequestsLeavesNoPartialEntry` None reverted by hand. Reviewed by hand: - `raftPayloadPublicationID` (reached by 6 tests through `SetObservedRaftPayloadWrapInMutation`) is a process-wide monotonic ID allocator; tests only compare observations for equality and never assert on the identity value, so they stay parallel. - No fixed-port listeners (all use `127.0.0.1:0` or bufconn); literal `host:port` strings are data only. No default Prometheus registry, goroutine-count or alloc assertions. No package-level `Configure*`/`Set*` helpers in `kv`. - Serial tests that write package globals restore them via `t.Cleanup`/`defer` and finish before any top-level parallel test is released. ## Behavior change / risk Test-only. No production code touched. Residual risk: a few tests assert wall-clock bounds (`raft_engine_test.go` verifyLeader upper bound of 2x timeout, `leader_proxy_test.go` retry-budget upper bound); they passed under `-count=3` with the higher concurrency but could become load-sensitive on a slow CI runner. ## Test evidence - `go test -race -count=3 -timeout=60m ./kv ./kv/kvtest` — ok - package time (`-race -count=1`): `kv` 127.9s → 70.6s, `kv/kvtest` 1.9s → 2.0s - `golangci-lint run ./kv/...` — 0 issues; `gofmt -l kv` — clean - No flakes observed ## Self-review 1. Data loss: test-only change; no storage, Raft or FSM code touched. 2. Concurrency: parallel tests each build their own stores/engines/HLC instances; package-global writers stay serial; the only shared mutable global reached is an atomic monotonic ID allocator. `-race -count=3` clean. 3. Performance: `kv` package wall time under `-race` roughly halved. 4. Data consistency: no change to MVCC/OCC/HLC semantics; test assertions untouched. 5. Test coverage: no tests added or removed; only execution scheduling changes.
## Summary Adds `t.Parallel()` to 194 top-level tests in `./internal/filesystem` (180), `./internal/filesystem/fstest` (4) and `./internal/fskeys` (10) that did not call it (11 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 (0 tests): the scan found no candidate to skip, and a manual review found no hidden shared state. Package-level variables in these packages are error sentinels, constant key prefixes, and `operationAccountingTrace` (read once at init). The process-kill tests in `operation_crash_test.go` re-exec the test binary with the env var set on `cmd.Env` (not `os.Setenv`) and write only under `t.TempDir()`, so they are safe to run in parallel. No fixed ports, default Prometheus registry, or goroutine/timing assertions are involved. No tests were reverted by hand. ## Behavior change / risk Test-only. No production code changes. Risk is limited to test flakiness from shared state the review missed; `-race -count=3` passed cleanly. ## Test evidence - `go test -race -count=3 ./internal/filesystem ./internal/filesystem/fstest ./internal/fskeys` — ok - package time (`-race -count=1`), before → after: - `internal/filesystem`: 180.0s → 70.9s - `internal/filesystem/fstest`: 1.5s → 1.6s - `internal/fskeys`: 1.3s → 1.3s - `golangci-lint run` — no new issues (only the pre-existing cyclop finding in `internal/filesystem/fuseadapter/adapter.go:776`, which is on main) - No flakes observed ## Self-review 1. Data loss: test-only change; no storage, Raft, or FSM code touched. 2. Concurrency: each test builds its own store/coordinator/service from `t.TempDir()` or in-memory fixtures; no package-level mutable state is shared. Verified under `-race -count=3`. 3. Performance: `internal/filesystem` test wall time drops from ~180s to ~71s; no production hot paths changed. 4. Data consistency: no MVCC/OCC/HLC logic changed; test assertions unchanged. 5. Test coverage: unchanged; same tests, same assertions, now running concurrently.
## Summary Adds `t.Parallel()` to the 107 top-level tests in `distribution` that did not call it (60 already did). Part of the effort to parallelize the Go test suite; the CI-side sharding is in #1387. The 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. No test in this package hit any of those. ## Behavior change / risk Test-only. Risk is a test that shares hidden state with another and flakes under parallel scheduling; the `-race -count=3` run below is the guard. ## Test evidence - `go test -race -count=3 ./distribution/` — ok - `go test -race -count=1 ./distribution/` package time: 2.5 s → 2.1 s - `golangci-lint run ./distribution/...` — 0 issues ## Self-review 1. Data loss: test-only, no runtime code. 2. Concurrency: tests now run concurrently; each builds its own engine/catalog and no test writes package state. Verified under `-race -count=3`. 3. Performance: package test time down; no production hot path touched. 4. Data consistency: N/A (no runtime code). 5. Test coverage: unchanged set of tests and assertions.
## Summary Adds `t.Parallel()` to 288 top-level tests in `./internal/admin` that did not call it (164 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 (0 tests): the scan skipped none, and a manual review found no hidden shared state. `127.0.0.1:<port>` literals in the tests are fake `RemoteAddr`/config values, not listeners; servers use `httptest.NewServer` (ephemeral ports); the only package-level mutable state (`secretCompareKey`) is initialised once via `sync.Once` and read-only afterwards. The timing assertions in `keyviz_fanout_test.go` / `capability_fanout_test.go` belong to tests that were already parallel. ## Behavior change / risk Test-only. No production code changes. Risk is limited to latent shared state between tests surfacing as flakes; none observed across `-race -count=3`. ## Test evidence - `go test -race -count=3 ./internal/admin` — ok - package time (`-race -count=1`): `internal/admin` 3.35s → 2.67s - `golangci-lint run ./internal/admin/...` — 0 issues; `gofmt -l` clean - No pre-existing flakes observed ## Self-review 1. Data loss: no production code touched; not applicable. 2. Concurrency: tests now run concurrently; checked for fixed ports, fixed file paths, global registries, and package-level mutable state; none shared. `-race -count=3` clean. 3. Performance: package wall time drops (3.35s → 2.67s); no hot-path changes. 4. Data consistency: not applicable (test scheduling only). 5. Test coverage: unchanged; same tests, same assertions, only `t.Parallel()` inserted as the first statement.
## Summary Adds `t.Parallel()` to 331 top-level tests in `./store` (327 in package `store`, 4 in `store_test`) that did not call it (110 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 (19 tests): - 12 change `pebbleCacheBytes` and with it the process-wide Pebble cache (`setSmallPebbleCacheForTest` / `setPebbleCacheBytesForTest`): the `DefaultPebbleOptions*` / process-cache sharing tests, the SST ingest snapshot tests, and `TestSwapInTempDBRollsBackOnMetadataFailure`. - 4 shrink `maxSnapshotValueSize`: the `ValueTooLarge` tests, `TestEncryption_RejectsAuthenticatedOversizedSnappyBeforeDecode`, and `TestEncryption_SnapshotRestoreAtMaxValueSize`, which already carries a "not parallel" comment. - 1 uses `t.Setenv`: `TestSetDurableAppliedIndex_UsesPebbleSync`. - 1 measures heap with `runtime.ReadMemStats`: `TestMemoryRaftEntryOverlaySharesUnmodifiedPayloads`. - 1 carries a doc comment about parallelism: `TestPebbleCacheEnvOverride`. No hand reverts were needed. I checked the inserted tests by hand. The FSM sync-mode tests use per-instance write options rather than the env var. The env/cache resolution tests call pure functions. The only mutable package state in `store` is the Pebble cache and `maxSnapshotValueSize`, and only the serial tests above write it. Go runs every serial top-level test before it releases the parallel ones, and those serial tests restore the globals in `t.Cleanup`. ## Behavior change / risk Test-only. No production code changes. The risk is a hidden shared state that only shows up under scheduling interleavings. The `-count=3 -race` run below exercised the package three times without failures. ## Test evidence - `go test -race -count=3 ./store`: ok (658.5s) - package time (`-race -count=1`): `store` 538.6s → 399.2s (both measured while other test runs shared the machine, so the absolute numbers are noisy) - `golangci-lint run ./store/...`: 0 issues - No flakes observed ## Self-review 1. Data loss: Test-only change, no storage or replication code touched. 2. Concurrency: Every parallel test uses its own `t.TempDir()` stores. Tests that write the package-level knobs stay serial. The race detector found nothing across 3 iterations. 3. Performance: Package wall time drops (538.6s → 399.2s under shared load). No production hot paths changed. 4. Data consistency: No MVCC/OCC/HLC code touched. 5. Test coverage: No tests were removed or changed in logic. Each test only gained `t.Parallel()`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **テスト** * ストア、移行、Raft、スナップショットなど幅広いテストを並列実行可能にしました。 * 外部スナップショットのキー保護を確認するテストを追加しました。 <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary Adds `t.Parallel()` to 455 top-level tests in `./adapter` that did not call it (1699 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, mutates one through a method (atomic `Store`/`Swap`, `Set`/`Reset`/`Register`), calls process-global setters (`slog.SetDefault`, `prometheus.MustRegister`, `signal.Notify`, `runtime.GOMAXPROCS(n)`, …), or carries a comment about parallelism. Left serial (47 tests): - 25 shorten package-level shutdown bounds via helpers (`httpShutdownTimeout`, `httpHandlerJoinTimeout`, `s3CleanupJoinTimeout`, `redisShutdownTimeout`, `sqsWorkerStopTimeout`): HTTP/S3/DynamoDB/Redis/SQS `Stop` tests. - 13 use `t.Setenv` (S3 blob/admission env config, DynamoDB item-write dedup, Redis peer limiter default, snapshot-seal restart, migration quorum acceptance). - 9 `TestEncryptionAdmin_EnableRaftEnvelope_*` tests toggle the process-wide `raftEnvelopeWrapEnabled` gate through `withWrapEnabledForTest`; they now carry `// Not parallel: toggles process-wide raftEnvelopeWrapEnabled.` No other process-wide `Set*`/`Configure*` helpers were found by hand (the remaining package-level vars in `adapter` are read-only lookup tables; the cluster helper's port allocator is atomic + mutex with bind retry). ## Behavior change / risk Test-only. No production code changes. The main risk is flakiness under higher concurrency; the full package passed three times under `-race` with the change. Note for follow-up: the test cluster port allocator in `adapter/test_util_test.go` only increments, and the Redis range starts at 63790 (~1.7k ports of headroom). Under `-count=3` in a single process the counters pass 65535 and every later `createNode` fails with `listen tcp: address 65536: invalid port`. On macOS the ranges also overlap the ephemeral port range, so busy machines take more bind retries, each of which consumes another port. CI runs `-count=1`, which is unaffected, but the allocator could wrap or use `:0` listeners. ## Test evidence - `go test -race -count=3 ./adapter` in one process: all 254 failures were `invalid port` from the allocator overflow above (no other failure type), so verification used three fresh `go test -race -count=1 ./adapter` processes instead (the full package, including `Test_consistency_satisfy_write_after_read_sequence` and `Test_grpc_transaction`) — ok ×3 - package time (`-race -count=1`, shared machine with other test runs): 1189.5 s → 985.1 s / 744.4 s / 735.9 s - `golangci-lint run ./adapter/...` — 0 issues; `gofmt -l adapter` — clean - No pre-existing flakes observed in these runs. ## Self-review 1. Data loss: test-only change; no storage, Raft, or FSM code touched. 2. Concurrency: tests touching package-level shutdown bounds, env vars, or the `raftEnvelopeWrapEnabled` gate stay serial (Go runs serial top-level tests before any parallel ones). Cluster tests allocate ports through the mutex-guarded allocator and each uses its own `t.TempDir()`. Passed under `-race` three times. 3. Performance: package time under `-race` dropped from ~1190 s to ~740–985 s locally. 4. Data consistency: N/A (no runtime code). 5. Test coverage: unchanged; no tests added, removed, or modified beyond the `t.Parallel()` call and the 9 comments. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **テスト** * 多数のテストを並列実行可能にし、テスト実行の効率向上を図りました。 * バックアップ時のカタログ取得、レガシータイムスタンプの検証、分割・移行処理などに関する検証を追加しました。 * 一部の時間制約やリーダー移譲を伴うテストは、並列実行の対象外であることを明確にしました。 <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary Adds `t.Parallel()` to 112 top-level tests in `./internal/encryption` (86) and `./internal/encryption/kek` (26) that did not call it (188 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 (6 tests, all in `kek`): `t.Setenv` plus process-wide `os.Unsetenv` of the KEK env var by `NewEnvWrapper` / `NewWrapperFromSources` (`TestEnvWrapper{InvalidInputStillUnsets,RejectsInvalidDEKLength,RoundTripAndUnset}`, `TestNewWrapperFromSources{FileAndEnv,NoSource,RejectsAmbiguity}`). No tests were reverted by hand: the newly parallel tests use `t.TempDir()` for sidecar/KEK files, in-memory fakes for AWS KMS / GCP KMS / Vault (no listeners or fixed ports), and per-test keystores; the only fixed paths (`/tmp/never-written`, a NUL-containing path) are never written. ## Behavior change / risk Test-only. No production code changes. Risk is limited to hidden shared state between tests, which the `-race -count=3` run did not surface. ## Test evidence - `go test -race -count=3 ./internal/encryption ./internal/encryption/kek` — ok - package time (`-race -count=1`, shared loaded machine): - `internal/encryption`: 67.6s → 52.8s - `internal/encryption/kek`: 1.8s → 1.6s - `golangci-lint run ./internal/encryption/...` — 0 issues; `gofmt -l` clean - No flakes observed ## Self-review 1. Data loss: no production code touched; nothing to lose. 2. Concurrency: newly parallel tests use per-test `t.TempDir()`, per-test keystores and in-memory KMS fakes; env-mutating KEK tests stay serial (Go runs serial top-level tests before paused parallel ones resume). `-race -count=3` clean. 3. Performance: `internal/encryption` wall time drops ~22% locally; most of its slow tests were already parallel. 4. Data consistency: no change to MVCC/OCC/HLC or the encryption code paths. 5. Test coverage: unchanged; test bodies are untouched apart from the inserted `t.Parallel()` calls.
## Summary Adds `t.Parallel()` to 75 top-level tests in `./internal/raftbootstrap` that did not call it (7 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 (2 tests): `TestCrashChild` and `TestPublicationStagingCrashChild` are subprocess entry points that call `os.Exit` when re-executed by their parent tests. No tests were reverted by hand: a manual pass found no fixed paths outside `t.TempDir()`, no mutable package-level fixtures, and no timing/goroutine-count assertions. The crash-boundary parents (`TestProcessCrashEveryBoundary`, staging equivalent) re-exec the test binary with per-subtest temp dirs passed via `cmd.Env`, so they are independent under parallelism. ## Behavior change / risk Test-only. No production code changes. Risk is limited to latent shared state between tests in this package surfacing as flakes; none observed across `-count=3 -race`. ## Test evidence - `go test -race -count=3 ./internal/raftbootstrap` — ok - package time (`-race -count=1`): 19.5s → 9.6s - `golangci-lint run ./internal/raftbootstrap/...` — 0 issues - No pre-existing flakes observed ## Self-review 1. Data loss: test-only change; no storage or replication code touched. 2. Concurrency: every parallelized test uses its own `t.TempDir()` and local fixtures; subprocess crash tests pass their directory via per-command env, not process env. 3. Performance: package wall time roughly halved under `-race`. 4. Data consistency: no MVCC/OCC/HLC/routing code touched. 5. Test coverage: unchanged; same tests, same assertions.
## Summary Adds `t.Parallel()` to 172 top-level tests in `./proxy` (167 in package `proxy`, 5 in package `proxy_test`) that did not call it (3 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 (0 tests): the scan skipped nothing and no test was reverted by hand. Manual review found no hidden shared state: every listener binds `127.0.0.1:0`, metrics use a fresh `prometheus.NewRegistry()` per test, `NewSentryReporter` is always called with an empty DSN (so `sentry.Init` never touches the global hub), the shared `testLogger` discards output and is read-only, and the `TestIntegration_*` tests (which need a real Redis on `localhost:6379`) use per-test `UnixNano`-suffixed keys. ## Behavior change / risk Test-only. No production code changes. Risk is limited to test flakiness from shared state the review missed; `-race -count=3` passed twice. ## Test evidence - `go test -race -count=3 ./proxy` — ok (run twice) - package time (`-race -count=1`): `proxy` 9.26s → 2.43s - `golangci-lint run ./proxy/...` — 0 issues; `gofmt -l proxy` — clean - No pre-existing flakes observed. `TestIntegration_*` skip locally (no Redis on `localhost:6379`), so their parallel behavior was checked by reading only. ## Self-review 1. Data loss: Test-only change; no storage, Raft, or FSM code touched. 2. Concurrency: Tests now run concurrently. Checked for fixed ports, the default prometheus registry, global Sentry hub, and package-level mutable state; none are shared. Verified under `-race -count=3`. 3. Performance: `./proxy` race run drops from ~9.3s to ~2.4s. 4. Data consistency: No change to MVCC/OCC/HLC or adapter semantics. 5. Test coverage: Same tests and assertions; only `t.Parallel()` added.
## Summary Adds `t.Parallel()` to 358 top-level tests in `.` (the repo-root `main` package) that did not call it (226 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 (119 tests): reasons overlap, so the counts below sum to more than 119. - 113 skipped by the scan: - `t.Setenv`: 42 - assigning flag globals: encryption/KEK flags 20, `raftBootstrapPeerConfigDir` 18, TSO flags (`tsoModeFile`, `tsoPhaseDEnabled`, …) 17, `snapshotOffload*` 12, admin/gRPC shutdown flags 11, `splitMigration*` 10, `filesystem*` 9, `autoSplitFlags` 1 - `installShutdownSignalHandler` / `startMemoryWatchdog` (`signal.Notify`, `signalShutdown`, `memoryPressureExit`): 22 - `slog.SetDefault`: 4 - comment about parallelism: 1 - 5 reverted by hand: `TestBootstrapOfflineDataPreparation{NeverWritesWithoutTrustedBackup,RejectsPostStageEditsAfterRestart,RuntimeMetadataAfterRestart,StageVerifyAndRestart}` and `TestBootstrapOfflineEncryptionPrepareRestartPreservesCiphertext`. With these tests parallel, `-race` reported a data race between `store.VerifyBootstrapBaselinePhysicalEquality` and an unrelated test's catalog watcher on another Pebble DB. The cause is in `store/bootstrap_baseline_encryption.go:221`: `defer func() { err = errors.Join(err, b.Close(), a.Error(), b.Error()) }()` calls `b.Error()` after `b.Close()`. The closed iterator's allocation goes back to Pebble's pool, which every DB in the process shares. These tests stay serial until that is fixed separately, which is a production change and out of scope here. - 1 already-parallel test made serial: `TestConfigureAdminServiceWiresLeaderVersionProbe`. Its 1s `require.Eventually` on a remote version probe timed out once under the new parallel e2e load, and it passes alone. I also checked production code for package-level state written outside `main()`. The only writes are `signalShutdown`, `memoryPressureExit`, and the `autoSplitFlags` read, and the scan already covers all three. Every fixed `host:port` string in the parallel tests is a value inside a struct, not a listener. ## Behavior change / risk Test-only. The only non-mechanical edits are the six `// Not parallel:` comments. Parallel tests still read flag globals. That is safe because Go runs all serial tests (and their `t.Cleanup` restores) before any paused parallel test resumes. ## Test evidence - `go test -race -count=3 -timeout=60m .`: ok (1123.8s, on a shared, loaded machine) - package time (`-race -count=1`): 592.8s → 241.8s - `golangci-lint run .`: 0 issues - `gofmt -l .`: clean - Pre-existing flakes: none besides the two items above. ## Self-review 1. Data loss: Test-only change. No production code touched. 2. Concurrency: Parallel tests only read process globals that serial tests write, and serial tests finish before parallel ones resume. The race exposed in `VerifyBootstrapBaselinePhysicalEquality` is handled by keeping its callers serial and is reported for a separate fix. 3. Performance: Package wall time drops by about 60% under `-race`. 4. Data consistency: No change to MVCC/OCC/HLC/routing code. 5. Test coverage: No test logic changed; the same tests run, only scheduling differs.
## 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.
## Summary Adds `t.Parallel()` to 394 top-level tests in `./internal/raftengine/etcd` (393 in package `etcd`, 1 in `etcd_test`) that did not call it (58 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 (37 tests): - `t.Setenv` (28): env-driven knobs (`MaxWALFilesFromEnv_*`, `SnapshotEveryFromEnv_*`, `SnapshotSpool_*`, PreVote / dispatcher-lane / send-stream toggles) plus integration tests that shrink WAL/snapshot thresholds through env (3 of them via the `recoveryWALConfig` helper). Two of these also swap `snapshotSpoolAvailableBytes`. - Package test hooks: `prewriteWALSnapshotIndexes` (4), `snapshotSyncDir` (3), `grpcNewClient` (1). - Other-package global `wal.SegmentSizeBytes` (1): `TestSingleNodeWALRotatesSegments`. Hand review found nothing else to revert: there are no package-level fixtures in the test files, transports in parallel tests listen on `127.0.0.1:0` or bufconn (the fixed `127.0.0.1:70xx` strings are peer metadata only and nothing binds to them), the only process-wide counter (`JoinRoleViolationCount`) is asserted monotonically (`> before`), and the one timing-window assertion (`TestQuorumAckTracker_LoadReturnsMonotonicRaw`) was already parallel. Serial tests restore their hooks/env through `t.Cleanup` before the parallel tests are released, so the parallel tests still see the defaults. ## Behavior change / risk Test-only. No production code changes. Risk: under heavier parallel load, election/heartbeat-driven tests may need more wall time; three `-race -count=3` iterations on a loaded machine passed without failures. ## Test evidence - `go test -race -count=3 -timeout=60m ./internal/raftengine/etcd`: ok (579 s for all three iterations) - package time (`-race -count=1`): 533.7 s → 171.5 s (local, machine shared with other concurrent test runs) - `golangci-lint run ./internal/raftengine/etcd/...`: 0 issues - `gofmt -l`: clean - No pre-existing flakes observed ## Self-review 1. Data loss: n/a; test-only change, no storage/Raft code touched. 2. Concurrency: each parallel test uses its own `t.TempDir()` data dir, its own engine instances, and ephemeral listeners. Tests that mutate package hooks, other-package globals, or env stay serial. `-race -count=3` is clean. 3. Performance: package wall time under `-race` drops about 3x locally. 4. Data consistency: n/a; no assertions or production logic changed. 5. Test coverage: unchanged; same tests and assertions, only scheduling differs.
## Summary Adds `t.Parallel()` to 37 top-level tests in `./monitoring` that did not call it (92 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 (3 tests): - 1 skipped by the scan: `TestAuxiliaryShutdownTasksReturnNilAfterForcedClose` assigns the package global `metricsShutdownTimeout`. - 2 reverted by hand: `TestShutdownHTTPServerForcesCloseAfterTimeout` (asserts shutdown elapsed within 150ms..3s) and `TestShutdownHTTPServerReturnsPromptlyWhenIdle` (asserts return within 2s). Both assert a tight wall-clock budget that CPU contention from peer tests can push out, so they stay serial with a `// Not parallel: ...` comment. No test in the package uses the default Prometheus registry (each builds its own via `NewRegistry`) or a fixed TCP port (listeners use `127.0.0.1:0`). ## Behavior change / risk Test-only. No production code changes. Risk is limited to hidden shared state between the newly parallel tests; each test constructs its own registry/collector, and the run below passed at `-count=3` with the race detector. ## Test evidence - `go test -race -count=3 ./monitoring` — ok - package time (`-race -count=1`): monitoring 3.52s → 3.29s - `golangci-lint run ./monitoring/...` — 0 issues - No flakes observed. ## Self-review 1. Data loss: test-only change; no production write paths touched. 2. Concurrency: newly parallel tests each own their registry, collectors and loopback listeners; tests that write a package global or assert tight wall-clock windows stay serial. `-race -count=3` is clean. 3. Performance: no production impact; package wall time slightly lower. 4. Data consistency: no MVCC/OCC/HLC/routing code touched. 5. Test coverage: no assertions changed; only `t.Parallel()` insertions and two explanatory comments.
## Summary Adds `t.Parallel()` to 161 top-level tests in `./internal/filesystem/fuseadapter` (141 in `fuseadapter`, 20 in `fuseadapter_test`) that did not call it (1 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 (25 tests): - 23 in `fuseadapter` that swap package-level seams or timeouts (`detachMountTable` via `useFakeDetachMountTable`, `mountHelperFallbackDir` + `PATH` via `onlyMountHelpersIn`/`writeRecordingMountHelper`, `lookupMountHelperFn`, `abandonedUnmountTimeout`/`abandonedDetachTimeout`, `mountPointCandidatesFn`, `mountPointResolveTimeout`). Most of these also carry wall-clock budget assertions. - `TestMountContextAbortsWhileMountHelperHangs` (`t.Setenv`). - `TestHelperProcessHoldsMount` (re-exec helper entry point that calls `os.Exit`). No tests were reverted by hand. The parallel tests only read those package-level seams; Go runs all serial top-level tests (including their `t.Cleanup` restores) before releasing paused parallel tests, so the swaps never overlap a parallel reader. All kernel-mount tests that became parallel mount under `t.TempDir()` (including the re-exec stale-mount helper), so there are no shared mountpoints. ## Behavior change / risk Test-only. No production code changes. Risk is limited to hidden shared state between tests surfacing as flakes; the kernel-mount tests (which skip on macOS without FUSE) now run concurrently on Linux CI with `ELASTICKV_REQUIRE_FUSE=1`, each against its own temp mountpoint. ## Test evidence - `go test -race -count=3 ./internal/filesystem/fuseadapter` — ok (macOS; kernel-mount tests skipped locally) - package time (`-race -count=1`): 15.45s → 15.42s. Locally the wall time is dominated by the serial deadline/helper tests (multi-second budgets by design), so there is no local gain; the gain is expected on Linux where the kernel-mount e2e tests run. - `golangci-lint run ./internal/filesystem/fuseadapter/...` — no new issues (only the pre-existing `cyclop` finding at `adapter.go:776`) - No flakes observed. ## Self-review 1. Data loss: Test-only change; no storage, Raft, or FSM code touched. 2. Concurrency: Parallel tests only read package-level seams that serial tests swap; serial tests finish before parallel ones resume. Each kernel mount uses its own `t.TempDir()` mountpoint. `-race -count=3` is clean. 3. Performance: No production impact. Test wall time unchanged locally; Linux CI should benefit from concurrent kernel-mount tests. 4. Data consistency: No change to MVCC/OCC/HLC/routing code. 5. Test coverage: Test logic unchanged; only scheduling differs. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **テスト** * FUSEアダプターの多数のテストを並列実行可能にしました。 * 実際のカーネルFUSEマウントを行うテストは並列実行せず、タイムアウトを避けるための注記を追加しました。 * テスト対象の動作や検証内容に変更はありません。 <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
go-test.ymlran the whole race suite in one job (~10 min;adapteralone is ~440 s and.~340 s of package time). This splits it into five parallel matrix jobs defined byscripts/go-test-shard.sh:adapter./adapterminus the full-length gRPC sequencesadapter-seqTest_consistency_satisfy_write_after_read_sequence,Test_grpc_transactionroot.raft-cryptointernal/encryption,internal/raftengine/etcdrestgo list, so new packages land here)Branch protection requires the check
test (ubuntu-latest), so atestaggregator job keeps that name and passes only when every shard passed (if: always(), so a failed shard fails the required check instead of skipping it).Behavior change / risk
check-production-imports.shruns once, in therestshard.adaptershard.fail-fast: falseso one flaky shard does not hide results from the others.Test evidence
bash -n/actionlinton the workflow; the script's usage path was exercised locally.restpackage list was checked locally: 54 of 58 packages, i.e. all minus the four heavy ones.Self-review
-race; coverage moves between jobs but nothing is dropped.