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

11 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, 48 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 48 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

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.

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