Skip to main content

Crate dev_chaos

Crate dev_chaos 

Source
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 */ }
    }
}

Structs§

FailureSchedule
A schedule that decides whether a given attempt fails.
InjectedFailure
An error returned by injected failures.

Enums§

FailureMode
A type of failure that can be injected.

Functions§

assert_recovered
Verify that recovery logic succeeded after a failure schedule.