Skip to content
rustfsPublic

About

Deterministic Simulation Testing (DST) framework, runtime abstraction traits, virtual simulators, and correctness verification suite for RustFS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

RustFS DST — Deterministic Simulation Testing

License

RustFS DST is the Deterministic Simulation Testing (DST) framework, runtime trait abstraction layer, virtual fault simulator, and multi-seed correctness verifier for RustFS.

Current Verification Scope: This repository currently verifies standalone behavioral models (SimECStore, QuorumLockClient, Turmoil virtual-TCP quorum cluster, and enterprise/scanner domain simulators) built over rustfs-dst-runtime. It does not yet link or compile upstream rustfs/rustfs production crates directly. See the upstream adoption blueprint for the phased plan to wire rustfs-dst-runtime traits into rustfs/rustfs.

Inspired by FoundationDB's Flow simulator, Tokio turmoil, madsim, and Antithesis, RustFS DST isolates time, randomness, network transport, and crash-consistent disk I/O behind deterministic traits so multi-node fault schedules replay bit-for-bit from a single 64-bit seed.

Core Architecture

                     ┌──────────────────────────────────────────────┐
                     │     Simulated RustFS Storage Subsystems      │
                     │ (SimECStore · QuorumLock · Heal · Scanner)   │
                     └──────────────────────┬───────────────────────┘
                                            │
                            Unified Determinism Traits
                              (`rustfs-dst-runtime`)
       ┌────────────────────┬───────────────┴──────────────┬────────────────────┐
       ▼                    ▼                              ▼                    ▼
  trait Clock         trait RngSource                trait Network         trait DiskIo
  ├─ RealClock        ├─ RealRng                     ├─ SimNetwork         ├─ RealDiskIo
  └─ SimClock         └─ SimRng (ChaCha8 + fork)     │   (Swizzle-Clog,    └─ SimDiskIo
     (skew, drift,                                   │    asymmetric cuts,    (volatile vs
      drift-scaled                                   │    opaque reply loss)   durable fsync,
      sleep)                                         └─ turmoil::net           strict parent dir
                                                        (virtual TCP)          fsync, power loss,
                                                                               torn writes, bitrot,
                                                                               ENOSPC)

Workspace Crates

Crate Purpose
rustfs-dst-runtime Unified traits (Clock, RngSource, Network, DiskIo, RuntimeEnv) with production implementations, deterministic in-memory simulators (SimClock, SimRng, SimNetwork, SimDiskIo with both clean un-fsynced drop and ALICE/CrashMonkey 4 KiB dirty-subset & 512 B sector-tear power-loss modes), Tokio turmoil virtual TCP adapter, and a compile-time madsim cfg hook.
rustfs-dst-faults Two-stage deterministic Buggify injector, zero-cost declarative macros (dst_buggify!, dst_assert_always!, dst_assert_sometimes!, dst_assert_reachable!, dst_assert_unreachable!), CodeProbe coverage tracker (ProbeRegistry) with live unhit_must_hit() gating and Antithesis-compatible JSONL output, drive-targeted CrashPoint registry, and SwizzleClogScheduler.
rustfs-dst-sim Standalone behavioral models of RustFS distributed erasure-coded storage (SimECStore) with GF(2^8) Cauchy Reed-Solomon, xl.meta atomic two-phase commit, crash-safe quorum locking with storage-node fencing, online healing, Turmoil TCP quorum tests, 52 scenarios, and a 6-invariant ConsistencyOracle.
rustfs-dst-cli Parallel multi-seed runner (rustfs-dst run), single-seed bit-exact reproducer (rustfs-dst repro), and determinism prover (rustfs-dst verify-determinism).

Verified Invariants

  1. Linearizable S3 Read-After-Write Consistency: GET responses must match a possible current version across concurrent and sequential acknowledged/indeterminate mutations. LIST is verified against acknowledged live keys and version metadata before repair.
  2. Bit-Exact Data Integrity: Every readable object matches the exact SHA-256 of an acknowledged or indeterminate write for that version. Silent bitrot up to the parity limit is detected and reconstructed transparently.
  3. Crash Atomicity (Old-or-New-Never-Mixed): Abrupt power loss (SimDiskIo::crash_and_reboot) at any xl.meta commit window drops un-fsynced file data and un-fsynced directory entries (including un-fsynced ancestor directories) without corrupting committed versions.
  4. Quorum Safety & Opaque Reply Loss: Writes fail closed below quorum and roll back partial drive writes; post-dispatch reply loss returns an opaque NetError::ReplyLost treated conservatively as indeterminate.
  5. Distributed Lock Mutual Exclusion & Monotonic Fencing: Monotonic-clock quorum leases remain immune to wall-clock skew jumps, use Gray & Cheriton crash-recovery grace windows with durable epoch persistence, issue strictly increasing fencing tokens across sequential and overlapping acquisitions, and reject stale fence tokens at storage nodes.
  6. Heal Convergence & Zero Orphan Leaks: Post-heal, every drive in 4x4 (16 drives, EC:4), 3x2 (6 drives, EC:3), and 4x2 (8 drives, EC:4) converges to the identical (generation, version_id) with zero leaked .rustfs.sys/tmp/ artifacts.

Quickstart

# Format, lint, and run the full unit & integration test suite
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

# Compare two passing reports for every scenario across all 3 topologies
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 4x4 --seed 2026
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 3x2 --seed 2026
cargo run --release -p rustfs-dst-cli -- verify-determinism --topology 4x2 --seed 2026

# Run a multi-seed parallel DST campaign across all 52 scenarios
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x4 --seeds 25
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 3x2 --seeds 25
cargo run --release -p rustfs-dst-cli -- run --scenario all --topology 4x2 --seeds 25

# Replay a single failing seed deterministically
cargo run --release -p rustfs-dst-cli -- repro --scenario swizzle-clog-chaos --topology 4x4 --seed 42

The multipart-commit scenario rejects missing, CRC32, and incorrect SHA256 claims on replacements of a part with a declared SHA256 checksum. Its existing commit crash windows and the final payload check cover preservation of the previously accepted part in the simulator.

Pool Expansion Gates

cargo run --release -p rustfs-dst-cli -- run --scenario expansion-gates --start-seed 2026 --seeds 20 --json
cargo run --release -p rustfs-dst-cli -- verify-determinism --scenario expansion-gates --seed 2026
cargo run --release -p rustfs-dst-cli -- repro --scenario pool-expansion-gates --seed 2026

Each seed tests startup, paired hot/cold expansion, rebalance, decommission, and rolling/full restart gates under the final RustFS product contract:

  • Strict uniform stripe width W and effective EC parity M: appended pools must match the active pool's actual on-disk format.json stripe width W and active runtime effective EC parity M. Node count, drives per node, and set count may vary (e.g., 4x4 W=16 EC:4 + 4x8 2×16 W=16 EC:4, 1x4 + 2x2, 2x4 W=4 + 1x8 W=4).
  • 1x1 + 1x1 accepted, mixed-width rejected: 1x1 (W=1, EC:0) + 1x1 (both same-host and new-host) is accepted across startup, hot, cold, restart, equivalence, and decommission, alongside 1x4 + 1x4 (path & URL), 3x2 + 3x2, 4x2 + 4x2, and 4x4 + 4x8. Mixed-width expansions (such as 2x4 W=8 + 1x4 W=4 and 1x2 W=2 + 1x4 W=4) and same-width different-EC expansions are rejected across startup, hot, and cold paths.
  • Per-node durable config, drift, crash recovery, and generation fencing: models both direct API/Console submit (atomic persist + fsync + re-read of rustfs-startup.json on every node with fail-closed rollback) and file-staged hot expansion (rejecting missing/stale/drifted staged files), per-node EC/W/set-membership/pool-order drift even with identical volume lists, coordinator crash / partial peer commit convergence, lost-response idempotent retry, topology_generation write fencing, and per-node PID/start-time preservation across hot expansion/retirement vs change across cold expansion and rolling/full restarts.
  • Rebalance and hardened decommission: models cross-pool rebalance (live traffic, mid-rebalance crash + idempotent resume, conflict guards, physical placement checks) and hardened decommission (post-quorum source version re-verification before source cleanup under concurrent overwrite/delete races, destination conflict, ENOSPC capacity failure, incomplete drain, unresolved entries, maintenance conflicts, and post-offline survivor read + restart).
  • RSI production regression suite (Bugs #15–#19, #21–#22): covers partitioned unversioned overwrite-then-delete adoption of strictly older superseded null generations (#15), heterogeneous 3-pool 4x4 (1×16) + 8x8 (4×16) + 12x4 (3×16) stripe-width inheritance (#16), standby candidate pool mid-format-initialization retryable vs terminal preflight classification (#17), partitioned overwrite divergent rollback_dir/xl.meta.bkp reclamation and committed absence-delete settlement of pure write rollback backups enabling clean DeleteBucket (#18A/18B), live topology hot-reload (Local -> DistErasure and DistErasure -> +Pool -> Gen-0 retirement) immediately rebinding the background scanner leader onto new-generation pools/sets and lock clients (#19), pool-leader periodic 30s decommission watchdog using non-blocking try_refresh_pool_status_meta() (try_write_owned() after loading persisted metadata outside data_movement_operation_gate) so a 60s scanner_publication_lease never starves concurrent DeleteBucket usage cleanup or ScannerActivity RPCs while active persisted decommissions defer retryably and recover once the lease releases (#21), and delete_recovery_runtime + DeleteBucket hardening: dropping stale deleted/retired bucket hints on BucketNotFound with zero leaked pending_keys (#22A), immediately waking MissingQuorum delete-recovery waiters on returning partitioned remote peers (#22B), ordinary DeleteBucket non-destructively settling pending recovery receipts/stale copies after partition-healed quorum delete while preserving raw metadata-less residue untouched (#22C), and multi-receipt AdoptCommit per-copy matching receipt authority selection plus clean witness-only null conflict classification without OutdatedXLMeta retry loops (#22D).

The --topology option selects the legacy harness preset. Multi-seed --json reports record accepted topologies, semantic manifests, aggregated required must_hit phase probes, verdicts, trace digests, and admission_policy_commit as dst_model evidence (omitting verbose per-seed model_trace on passing runs by default; full model_trace is always retained on failures, in repro, or when --include-model-trace is passed). The release gate obtains live binary evidence from the real-cluster suites.

Supported Topologies

Topology Nodes × Drives Total Drives Parity (m) Data (k) Read Quorum (R) Write Quorum (W)
1x1 1 × 1 1 0 1 1 1
1x4 1 × 4 4 2 2 2 3
3x1 3 × 1 3 1 2 2 2
4x4 4 × 4 16 4 12 12 12
3x2 3 × 2 6 3 3 3 4
4x2 4 × 2 8 4 4 4 5

1x1 and 1x4 use the same names as the unmerged feat/full-audit-hardening-and-advanced-dst branch. The full campaign (--scenario all) is validated on 4x4, 3x2, and 4x2. --scenario gaps is also validated on 1x1, 1x4, and 3x1. Passing a gap scenario does not mean upstream rustfs/rustfs passed that issue.

Documentation

License

Licensed under the Apache License, Version 2.0.

Retention admission against a RustFS checkout

Run scripts/check-retention-admission.sh /path/to/rustfs against a checkout containing the native retention cancellation regression. The case uses a path-scoped pause immediately before RustFS publishes the updated metadata. It cancels the request, checks that the native write still holds the only slot, then releases the pause and checks that a rejected version can be retried and read back. The production retention workflow runs this case against a pinned RustFS revision using that checkout's Cargo lockfile.

About

Deterministic Simulation Testing (DST) framework, runtime abstraction traits, virtual simulators, and correctness verification suite for RustFS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages