Crate circus_buggify

Crate circus_buggify 

Source
Expand description

Inject failure with buggify buggify allow you to cooperate with the simulator to inject failures. It has the following rules:

  1. it only ever evaluates to true when run in simulation.
  2. The first time each buggify use is evaluated, it is either enabled or disabled for the entire simulation run.
  3. Enabled uses of buggify have a 5% chance of evaluating to true

A good blogpost about buggify can be found here.

use circus_buggify::{buggify_with_prob, enable_buggify, Buggifier};
use rand::rngs::SmallRng;
use rand::SeedableRng;

// let's create a buggifier
let b = Buggifier::default();

// enables buggify with a seed
b.enable_buggify(SmallRng::seed_from_u64(42));

for i in 0..10 {
    // this block has a 0.05% chance to be run
    // which is iteration 8 for seed 42
    if b.buggify() {
        println!("buggified at iteration {}", i);
    }
}

// buggify can also accept a probability
if b.buggify_with_prob(1.0) {
    println!("buggified with a 100% probability!");
}

// you can also get a static buggifier that needs to be enabled
enable_buggify(SmallRng::seed_from_u64(42));
if buggify_with_prob(1.00) {
    println!("buggified with a 100% probability!");
}

Structs§

Buggifier
Buggifier’s definition

Functions§

buggifier
retrieves the static buggifier
buggify
buggify will returns true only once per execution with a probability of 0.05.
buggify_with_prob
buggify version where you can choose the probability.
disable_buggify
disable buggify
enable_buggify
enables buggify by giving a random source
is_buggify_enabled
checks if buggify is enabled