Repository navigation
main: run server package tests in parallel - #1401
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 9 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: 7797d7ec62
ℹ️ 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".
| } | ||
|
|
||
| func TestSplitMigrationApplyMemberSnapshotFactoryPreservesTLSCredentials(t *testing.T) { | ||
| t.Parallel() |
There was a problem hiding this comment.
Keep tests that configure process-global gRPC TLS serial
When the root package tests run together, this test now overlaps with the newly parallel TestMigrationMemberProtocolProbeUsesDedicatedTLSCredential and TestOwnershipRefreshDifferentRaftLeadersRespectExplicitClosedGate. All three call internalutil.ConfigureGRPCTLS with independently generated certificates and reset it in cleanup, but that function replaces a process-global pointer used by both GRPCServerOptions and GRPCDialOptions. Another test can therefore replace the trusted certificate or clear TLS between server creation and client dialing, causing intermittent handshake failures and failed assertions; the atomic pointer prevents a data race, not this configuration interference. Keep all three global-TLS-mutating tests serial, or give their transports test-local credentials.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the latest commit: the three tests that call internalutil.ConfigureGRPCTLS (this one, TestMigrationMemberProtocolProbeUsesDedicatedTLSCredential, TestOwnershipRefreshDifferentRaftLeadersRespectExplicitClosedGate) run serially again, so their writes and cleanups finish before any parallel test reads the global TLS config. The other ConfigureGRPCTLS callers in the package were already serial.
🤖 Addressed by Claude Code
TestSplitMigrationApplyMemberSnapshotFactoryPreservesTLSCredentials, TestMigrationMemberProtocolProbeUsesDedicatedTLSCredential and TestOwnershipRefreshDifferentRaftLeadersRespectExplicitClosedGate each call internalutil.ConfigureGRPCTLS with their own certificate and reset it in cleanup. That replaces the process-global pointer behind GRPCServerOptions and GRPCDialOptions, so in parallel one test could swap the trusted cert or clear TLS between another's server start and dial. Run them serially; serial tests and their cleanups finish before parallel tests resume, so readers of the global config never overlap a writer. Signed-off-by: bootjp <contact@bootjp.me>
Summary
Adds
t.Parallel()to 358 top-level tests in.(the repo-rootmainpackage) 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.
t.Setenv: 42raftBootstrapPeerConfigDir18, TSO flags (tsoModeFile,tsoPhaseDEnabled, …) 17,snapshotOffload*12, admin/gRPC shutdown flags 11,splitMigration*10,filesystem*9,autoSplitFlags1installShutdownSignalHandler/startMemoryWatchdog(signal.Notify,signalShutdown,memoryPressureExit): 22slog.SetDefault: 4TestBootstrapOfflineDataPreparation{NeverWritesWithoutTrustedBackup,RejectsPostStageEditsAfterRestart,RuntimeMetadataAfterRestart,StageVerifyAndRestart}andTestBootstrapOfflineEncryptionPrepareRestartPreservesCiphertext. With these tests parallel,-racereported a data race betweenstore.VerifyBootstrapBaselinePhysicalEqualityand an unrelated test's catalog watcher on another Pebble DB. The cause is instore/bootstrap_baseline_encryption.go:221:defer func() { err = errors.Join(err, b.Close(), a.Error(), b.Error()) }()callsb.Error()afterb.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.TestConfigureAdminServiceWiresLeaderVersionProbe. Its 1srequire.Eventuallyon 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 aresignalShutdown,memoryPressureExit, and theautoSplitFlagsread, and the scan already covers all three. Every fixedhost:portstring 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 theirt.Cleanuprestores) before any paused parallel test resumes.Test evidence
go test -race -count=3 -timeout=60m .: ok (1123.8s, on a shared, loaded machine)-race -count=1): 592.8s → 241.8sgolangci-lint run .: 0 issuesgofmt -l .: cleanSelf-review
VerifyBootstrapBaselinePhysicalEqualityis handled by keeping its callers serial and is reported for a separate fix.-race.