Skip to content

raftengine: run etcd engine tests in parallel - #1395

Merged
bootjp merged 1 commit into
mainfrom
test/parallel-raftengine-etcd
Nov 7, 2026
Merged

bootjp merged 1 commit into
mainfrom
test/parallel-raftengine-etcd

Conversation

@bootjp

@bootjp bootjp commented Nov 6, 2026

Copy link
Copy Markdown
Owner

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.

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 49 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: cea97e24-f0b4-41d2-b608-d3fb24f9d33b
Commits

Reviewing files that changed from the base of the PR and between a9e3223 and 6f30b6d.

Files selected for processing: 50

  • internal/raftengine/etcd/admission_revocation_test.go
  • internal/raftengine/etcd/apply_entry_identity_test.go
  • internal/raftengine/etcd/apply_native_configuration_test.go
  • internal/raftengine/etcd/bootstrap_baseline_initial_journal_test.go
  • internal/raftengine/etcd/bootstrap_baseline_observe_test.go
  • internal/raftengine/etcd/bootstrap_baseline_test.go
  • internal/raftengine/etcd/conformance_test.go
  • internal/raftengine/etcd/encryption_admission_test.go
  • internal/raftengine/etcd/encryption_checkpoint_test.go
  • internal/raftengine/etcd/encryption_scanner_test.go
  • internal/raftengine/etcd/engine_applied_index_test.go
  • internal/raftengine/etcd/engine_test.go
  • internal/raftengine/etcd/external_origin_configuration_test.go
  • internal/raftengine/etcd/external_origin_restart_test.go
  • internal/raftengine/etcd/external_restore_origin_test.go
  • internal/raftengine/etcd/external_snapshot_restore_fifo_unix_test.go
  • internal/raftengine/etcd/external_snapshot_restore_test.go
  • internal/raftengine/etcd/factory_bootstrap_test.go
  • internal/raftengine/etcd/fsm_snapshot_file_test.go
  • internal/raftengine/etcd/grpc_transport_open_test.go
  • internal/raftengine/etcd/grpc_transport_sst_snapshot_test.go
  • internal/raftengine/etcd/grpc_transport_test.go
  • internal/raftengine/etcd/identity_reconciliation_test.go
  • internal/raftengine/etcd/learner_test.go
  • internal/raftengine/etcd/migrate_test.go
  • internal/raftengine/etcd/namespace_configuration_test.go
  • internal/raftengine/etcd/namespace_recovery_test.go
  • internal/raftengine/etcd/namespace_runtime_test.go
  • internal/raftengine/etcd/native_admission_test.go
  • internal/raftengine/etcd/offline_baseline_crypto_test.go
  • internal/raftengine/etcd/peer_metadata_test.go
  • internal/raftengine/etcd/peer_proposal_rejection_test.go
  • internal/raftengine/etcd/peer_session_cancellation_test.go
  • internal/raftengine/etcd/peer_session_client_test.go
  • internal/raftengine/etcd/peer_session_decoder_test.go
  • internal/raftengine/etcd/peers_test.go
  • internal/raftengine/etcd/persisted_snapshot_export_test.go
  • internal/raftengine/etcd/persistence_test.go
  • internal/raftengine/etcd/protected_configuration_recovery_test.go
  • internal/raftengine/etcd/protected_step_test.go
  • internal/raftengine/etcd/recovery_read_test.go
  • internal/raftengine/etcd/removal_notification_protected_test.go
  • internal/raftengine/etcd/removal_notification_test.go
  • internal/raftengine/etcd/snapshot_spool_test.go
  • internal/raftengine/etcd/status_perpeer_test.go
  • internal/raftengine/etcd/wal_identity_test.go
  • internal/raftengine/etcd/wal_preparation_recovery_test.go
  • internal/raftengine/etcd/wal_purge_test.go
  • internal/raftengine/etcd/wal_store_skip_gate_test.go
  • internal/raftengine/etcd/wal_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:34:37.357655Z 6f30b6d PR opened
🔒 Security Review ✅ Completed 2026-11-06T13:36:25.465417Z 6f30b6d PR opened
ℹ️ 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.

@bootjp
bootjp merged commit 6da3723 into main Nov 7, 2026
18 checks passed
@bootjp
bootjp deleted the test/parallel-raftengine-etcd 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