Expand description
Inject failure with buggify
buggify allow you to cooperate with the simulator to inject failures.
It has the following rules:
- it only ever evaluates to true when run in simulation.
- The first time each
buggifyuse is evaluated, it is either enabled or disabled for the entire simulation run. - Enabled uses of
buggifyhave 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
buggifywill returns true only once per execution with a probability of 0.05.- buggify_
with_ prob buggifyversion 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