Expand description
§dev-chaos
Failure injection and recovery testing for Rust. Part of the
dev-* verification suite.
Most code is tested only on the happy path. Real systems fail
through partial writes, crashes, timeouts, corrupt data, and
broken connections. dev-chaos provides primitives for injecting
those failures on purpose, then verifying that recovery logic does
its job.
§Quick example
use dev_chaos::{FailureSchedule, FailureMode};
// Fail on the 3rd, 7th, and 10th attempt.
let schedule = FailureSchedule::on_attempts(&[3, 7, 10], FailureMode::IoError);
for attempt in 1..=12 {
match schedule.maybe_fail(attempt) {
Ok(()) => { /* operation proceeds */ }
Err(_e) => { /* recovery path */ }
}
}§Modules
io— sync IO wrappers (ChaosReader,ChaosWriter,ChaosFile).latency— non-failing slowdowns viaLatencyInjector.crash— write-truncation viaCrashPoint.async_io(featureasync-io) —tokio::ioequivalents (visible in rustdoc when the feature is enabled).
§Determinism
All schedules are deterministic by default: the same sequence of
attempts MUST produce the same sequence of failures across runs
and machines. Probabilistic schedules
(FailureSchedule::seeded_random) are opt-in, seeded, and
reproducible from the seed.
Modules§
- async_
io async-io - Async IO wrappers. Available with the
async-iofeature. - crash
- Crash-point markers that truncate writes at a known byte offset.
- io
- Synchronous IO wrappers that inject failures into real
Read/Writetypes. - latency
- Latency injection: simulate slow-but-not-failing operations.
Structs§
- Chaos
Producer - Producer wrapper that runs a chaos suite and emits a Report with
each scenario’s
CheckResult. - Failure
Schedule - A schedule that decides whether a given attempt fails.
- Injected
Failure - An error returned by injected failures.
Enums§
- Failure
Mode - A type of failure that can be injected.
Functions§
- assert_
recovered - Verify that recovery logic succeeded after a failure schedule.