pub struct Simulation { /* private fields */ }Expand description
DST simulation harness.
TigerStyle:
- Single seed controls all randomness
- Faults are registered explicitly
- Environment is provided to test closure
§Example
use umi_memory::dst::{Simulation, SimConfig, FaultConfig, FaultType};
#[tokio::test]
async fn test_storage() {
let sim = Simulation::new(SimConfig::with_seed(42))
.with_fault(FaultConfig::new(FaultType::StorageWriteFail, 0.1));
sim.run(|mut env| async move {
env.storage.write("key", b"value").await?;
env.advance_time_ms(1000);
let result = env.storage.read("key").await?;
assert_eq!(result, Some(b"value".to_vec()));
Ok(())
}).await.unwrap();
}Implementations§
Source§impl Simulation
impl Simulation
Sourcepub fn with_fault(self, fault_config: FaultConfig) -> Self
pub fn with_fault(self, fault_config: FaultConfig) -> Self
Register a fault to inject during simulation.
TigerStyle: Fluent API for fault registration.
Sourcepub fn with_storage_faults(self, probability: f64) -> Self
pub fn with_storage_faults(self, probability: f64) -> Self
Add common storage faults.
TigerStyle: Convenience method for common fault patterns.
Sourcepub fn with_db_faults(self, probability: f64) -> Self
pub fn with_db_faults(self, probability: f64) -> Self
Add common database faults.
Sourcepub fn with_llm_faults(self, probability: f64) -> Self
pub fn with_llm_faults(self, probability: f64) -> Self
Add common LLM/API faults.
Sourcepub async fn run<F, Fut, E>(self, test_fn: F) -> Result<(), E>
pub async fn run<F, Fut, E>(self, test_fn: F) -> Result<(), E>
Run the simulation with the given test function.
TigerStyle: Test function receives environment and returns Result.
§Errors
Returns any error from the test function.
Sourcepub fn build(self) -> SimEnvironment
pub fn build(self) -> SimEnvironment
Build the simulation environment without running a test.
Useful for custom test setups.
Auto Trait Implementations§
impl Freeze for Simulation
impl RefUnwindSafe for Simulation
impl Send for Simulation
impl Sync for Simulation
impl Unpin for Simulation
impl UnwindSafe for Simulation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more