Skip to content

main: run server package tests in parallel - #1401

Merged
bootjp merged 2 commits into
mainfrom
test/parallel-server
Nov 7, 2026
Merged

bootjp merged 2 commits into
mainfrom
test/parallel-server

Conversation

@bootjp

@bootjp bootjp commented Nov 6, 2026

Copy link
Copy Markdown
Owner

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.

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 9 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: 3b42f5ab-0fbb-4a9b-8e3f-2560dbb7499c
Commits

Reviewing files that changed from the base of the PR and between a9e3223 and 4e005c1.

Files selected for processing: 74

  • main_admin_dynamo_stopping_test.go
  • main_admin_forward_test.go
  • main_admin_lifecycle_test.go
  • main_admin_shutdown_test.go
  • main_admin_test.go
  • main_autosplit_e2e_test.go
  • main_bootstrap_activation_fixture_test.go
  • main_bootstrap_artifact_commands_test.go
  • main_bootstrap_artifacts_test.go
  • main_bootstrap_auth_exception_test.go
  • main_bootstrap_baseline_cli_test.go
  • main_bootstrap_catalog_defer_test.go
  • main_bootstrap_control_gate_test.go
  • main_bootstrap_e2e_test.go
  • main_bootstrap_encrypted_payload_factory_test.go
  • main_bootstrap_encrypted_payload_rotation_test.go
  • main_bootstrap_encrypted_payload_test.go
  • main_bootstrap_encryption_installed_test.go
  • main_bootstrap_encryption_projection_test.go
  • main_bootstrap_encryption_runtime_io_test.go
  • main_bootstrap_encryption_startup_test.go
  • main_bootstrap_external_rotation_lifecycle_test.go
  • main_bootstrap_external_rotation_recipe_material_test.go
  • main_bootstrap_external_rotation_recipe_test.go
  • main_bootstrap_external_rotation_runtime_test.go
  • main_bootstrap_flag_test.go
  • main_bootstrap_fsm_test.go
  • main_bootstrap_ingress_test.go
  • main_bootstrap_ingress_transport_test.go
  • main_bootstrap_launch_test.go
  • main_bootstrap_methods_test.go
  • main_bootstrap_network_test.go
  • main_bootstrap_observation_cli_test.go
  • main_bootstrap_offline_encryption_cli_test.go
  • main_bootstrap_offline_encryption_test.go
  • main_bootstrap_offline_store_test.go
  • main_bootstrap_outcome_test.go
  • main_bootstrap_payload_scope_test.go
  • main_bootstrap_payload_test.go
  • main_bootstrap_peer_config_test.go
  • main_bootstrap_prepared_runtime_test.go
  • main_bootstrap_prepared_source_test.go
  • main_bootstrap_registration_cipher_test.go
  • main_bootstrap_registration_test.go
  • main_bootstrap_rotation_recipe_test.go
  • main_bootstrap_rotation_rpc_test.go
  • main_bootstrap_rotation_runtime_test.go
  • main_bootstrap_runtime_test.go
  • main_bootstrap_test.go
  • main_bootstrap_tso_baseline_test.go
  • main_bootstrap_tso_recovery_test.go
  • main_bootstrap_tso_test.go
  • main_encryption_admin_test.go
  • main_encryption_compacted_restart_test.go
  • main_encryption_rotate_on_startup_test.go
  • main_encryption_startup_guard_test.go
  • main_filesystem_reaper_test.go
  • main_filesystem_startup_test.go
  • main_filesystem_test.go
  • main_grpc_stop_test.go
  • main_leader_balance_test.go
  • main_migration_apply_members_test.go
  • main_migration_membership_probe_test.go
  • main_migration_namespace_membership_test.go
  • main_migration_ownership_refresh_test.go
  • main_prepare_evidence_test.go
  • main_raft_join_test.go
  • main_s3_test.go
  • main_shutdown_e2e_test.go
  • main_snapshot_offload_gc_test.go
  • main_snapshot_offload_test.go
  • multiraft_runtime_test.go
  • raft_member_replace_script_test.go
  • shard_config_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-06T14:14:12.339446Z 4e005c1 New commits
🔒 Security Review ✅ Completed 2026-11-06T14:16:58.356398Z 4e005c1 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread main_migration_apply_members_test.go Outdated
}

func TestSplitMigrationApplyMemberSnapshotFactoryPreservesTLSCredentials(t *testing.T) {
t.Parallel()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@bootjp
bootjp merged commit c3f4399 into main Nov 7, 2026
19 checks passed
@bootjp
bootjp deleted the test/parallel-server 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