[Enhancement✨] Evaluate cargo-nextest to reduce workspace test execution time
Current Behavior
The overall project test suite takes too long, delaying local feedback and pull request validation.
The root workspace currently contains 28 members. In .github/workflows/rocketmq-rust-ci.yaml, the workspace test job runs either cargo test --workspace or cargo test --workspace --all-features, depending on the event and changed paths. Additional jobs cover observability features, RocksDB, lifecycle contracts, and coverage.
There is no measured cargo-nextest comparison yet. We need to distinguish compilation and native dependency costs from test execution time before choosing an optimization.
Proposed Enhancement
Evaluate cargo-nextest as a test runner for the existing Rust tests, with a limited Linux CI pilot and an evidence-based adoption recommendation.
Scheduling
This enhancement is planned for after the 1.0.0 release. The evaluation and Linux CI pilot should begin after that release, with broader adoption proceeding only if the results demonstrate feasibility and a worthwhile reduction in test time while preserving coverage and reliability.
Evaluation and pilot tasks
- [ ] Measure the current default-feature and all-feature workspace runs on a representative Linux runner. Record toolchain, runner resources, selected tests, cache state, compilation time, test execution time, and total duration. Repeat warm runs to report a median and variability.
- [ ] Compare equivalent cargo-nextest runs using the same code, feature sets, environment, and test coverage. Include installation and doctest costs when comparing end-to-end CI time. Do not claim a speedup from fewer tests or a warmer cache.
- [ ] Prepare a minimal
.config/nextest.tomland a Linux pilot in.github/workflows/rocketmq-rust-ci.yaml. Use a pinned nextest version, disable retries during evaluation, collect test timings and JUnit output, and choose concurrency limits from runner capacity. - [ ] Verify ordinary unit tests, Tokio tests, trybuild tests, and Loom tests. Check test selection, ignored-test behavior, failures, timeouts, and resource cleanup. Keep existing feature-absence and feature-combination checks.
- [ ] Audit tests that rely on process-local synchronization or shared resources. Start with
BROKER_TEST_LOCKinrocketmq-broker/tests/broker_transactional_startup.rsandCONTROLLER_INTEGRATION_TEST_LOCKplus port allocation inrocketmq-broker/tests/broker_runtime/unit.rs. Each nextest test runs in a separate process, so these locks no longer serialize tests against one another. Use isolated resources or narrowly scoped nextest test groups where needed; group limits apply only within one runner invocation. - [ ] Preserve doctests with a separate
cargo test --docinvocation using the same workspace and feature selection. Apply both the default-feature and all-feature branches consistently. - [ ] Update
scripts/ci_scope.pyandscripts/tests/test_ci_scope.pyso a change to.config/nextest.tomltriggers the affected Rust test jobs. Today, classifying that path alone returnsrust: false. - [ ] Document the measured result, compatibility findings, local commands, and a recommendation to adopt, narrow the rollout, or defer. If compilation dominates, identify that limitation explicitly.
Scope
Start with the root workspace on Linux. Preserve existing required CI check names and retain the existing cargo-test path until the pilot establishes compatibility. Coverage migration, Windows/macOS rollout, independent workspaces, benchmark execution, and external cluster orchestration can be evaluated separately. This issue does not require changing production code or adding nextest as a runtime dependency.
Acceptance criteria
- [ ] A reproducible before/after comparison reports both test execution and end-to-end duration, with no assumed speedup percentage.
- [ ] Test discovery and results are reconciled for the evaluated feature sets; doctests and required tests are not silently omitted.
- [ ] Any new parallelism-related failures or excessive resource usage are explained and addressed within the proposed pilot scope.
- [ ] Configuration-only changes trigger the appropriate CI validation, with regression coverage for path selection.
- [ ] A documented adoption decision includes remaining limitations and a straightforward fallback. A full migration is recommended only if the evidence supports it.
Validation examples for the pilot
Run these from the repository root after installing the selected nextest version and defining the ci profile:
# Existing baseline.
cargo test --workspace
# Candidate with equivalent doctest coverage.
cargo nextest run --workspace --profile ci
cargo test --workspace --doc
Repeat the comparison with --all-features on all three commands. Use consistent failure behavior when investigating failures; only compare timings for equivalent completed workloads.
For CI routing changes:
python -m unittest scripts.tests.test_ci_scope
python scripts/ci_scope.py --paths .config/nextest.toml
bash ./scripts/check-agents-routing.sh
git diff --check
Benefits
- Potentially shorter test execution through scheduling individual tests across test binaries.
- Faster developer and pull request feedback if execution is a significant part of total CI time.
- Clearer visibility into slow tests, individual failures, and resource-intensive suites.
- A measured migration that preserves existing test coverage and feature validation.
Additional Context
Nextest still uses Cargo to build test binaries; it does not directly eliminate Rust or RocksDB compilation costs. Its process-per-test model can improve isolation but changes shared-state assumptions. Current nextest documentation requires doctests to be run separately.
References:
- cargo-nextest repository
- Execution model
- Running tests and doctest limitation
- Test groups and mutual exclusion
- Windows performance considerations
- Coverage integration
Baseline durations, a validated nextest version, and measured speedup are intentionally left for this investigation; they have not been established yet.
@mxsm Now that 1.0.0 is out, I'd like to take this evaluation. Plan, following the checklist:
- Baseline
cargo test --workspacevscargo nextest run --workspace+cargo test --docon a Linux runner, for both default and--all-features, reporting compile and test time separately. - Audit
BROKER_TEST_LOCK/CONTROLLER_INTEGRATION_TEST_LOCKfirst: nextest runs each test in its own process, so process-local locks stop serializing those tests. I'd use nextest test groups in.config/nextest.tomlwhere needed. - Pinned-version Linux pilot job, plus the
ci_scope.pyupdate and tests.
I'll post the numbers here before proposing any adoption.
@youneedgreg Go ahead