Skip to content

tokio-rs/turmoil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turmoil

This is very experimental

Add hardship to your tests.

Turmoil is a framework for testing distributed systems. It provides deterministic execution by running multiple concurrent hosts within a single thread. It introduces "hardship" into the system via changes in the simulated network and filesystem. Both can be controlled manually or with a seeded rng.

Crates.io Documentation Build Status Discord chat

Quickstart

Add this to your Cargo.toml.

[dev-dependencies]
turmoil = "0.7"

See crate documentation for simulation setup instructions.

Examples

  • /tests for TCP, UDP, and filesystem.
  • gRPC using tonic and hyper.
  • axum

Filesystem Simulation (unstable)

Requires the unstable-fs feature.

[dev-dependencies]
turmoil = { version = "0.7", features = ["unstable-fs"] }

Turmoil provides simulated filesystem types for crash-consistency testing:

use turmoil::fs::shim::std::fs::OpenOptions;
use turmoil::fs::shim::std::os::unix::fs::FileExt;

let file = OpenOptions::new()
    .read(true)
    .write(true)
    .create(true)
    .open("/data/db")?;

file.write_all_at(b"data", 0)?;
file.sync_all()?;  // Data now durable, survives sim.crash()

Each host has isolated filesystem state. Use Builder::fs_sync_probability() to configure random sync behavior for testing crash recovery.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in turmoil by you, shall be licensed as MIT, without any additional terms or conditions.