Repository navigation
partitions: refactor inline tests #4684
Description
Work can start only after both PR #4683 and PR #4658 have merged.
Separate tests from implementation as the first step toward refactoring core/partitions/. At c92d2bd907cf, iggy_partition.rs contains 35,344 lines, roughly 21,800 of them in inline test modules. Large suites also live in segment_recovery.rs and state_transfer.rs, making production code harder to navigate and review.
Design
Start with those three files and follow the message_bus layout:
- Move tests using the existing public API to
core/partitions/tests/, grouped by behavior. Extend the layout established byconsumer_offset_history.rs. - Extract private unit suites into separate child module files under
src/, retaining their#[cfg(test)]declarations and fixture access. - Share reused external fixtures through
tests/common/mod.rs; keep specialized helpers with their suites.
Keep production code and visibility unchanged. Preserve assertions, feature guards, fault injection, runtime setup and fixture lifetimes. Leave unrelated unit suites alone.
Alternatives
A wholesale move to tests/ would require exposing internals or rewriting tests: some directly mutate partition.log or call helpers available only under cfg(test). Separate private unit modules preserve that access.
Risks
Relocation can lose test discovery or alter setup and cleanup. All-features builds can also hide dependence on simulator or fault-injection APIs, so validate default features independently.
Tests
- Large inline suites are extracted from the three target files.
- Every existing test has a destination; compare discovered test identities before and after, allowing for module path changes.
- No coverage is weakened or tests newly ignored; default-feature and all-features suites pass.
- Public APIs, runtime behavior, storage formats and durability ordering remain unchanged.
Follow-ups
Split IggyPartition responsibilities in subsequent changes, reusing existing modules such as persistence.rs, poll_plan.rs, io.rs and state_transfer.rs.
Commands
Compare test discovery before and after for each configuration, then run the repository checks:
rtk cargo test -p partitions -- --list
rtk cargo test -p partitions --all-features -- --list
rtk cargo fmt --all
rtk cargo sort --no-format --workspace
./scripts/ci/taplo.sh --check
rtk cargo build
rtk cargo clippy --all-features --all-targets -- -D warnings
rtk cargo test -p partitions
rtk cargo test -p partitions --all-features
Activity
Surajsuthar commentedon Oct 30, 2026
@hubcio after following PR merged i can work on them
hubcio commentedon Oct 30, 2026
yes, assigned