data net
Namespace of the network controls: net.partition(["api"], ["db"], for: 2s), net.latency(10ms..300ms), net.drop(0.1).
Example:
use std.test { net }
test sim "a partition heals" seeds 1..=2 {
net.partition(["api"], ["db"])
assert net.isBlocked("api", "db")
net.heal()
assert !net.isBlocked("api", "db")
}pub(api) data netThread safety. global to the simulated world of the test; call it from the test body.
Since. 1.0.0-beta
Methods
dropConnections | () netBreaks every client connection of this process (the sockets are shut down). |
latency | (bounds: Dur | Range<Dur> | RangeInclusive<Dur>, hi: Dur)One-way latency of every message, uniform in lo..=hi (jitter = hi - lo). |
drop | (p: f64)Probability (0..1) that a message is lost. |
duplicate | (p: f64)Probability (0..1) that a message is delivered twice. |
reorder | (p: f64)Probability (0..1) that a message is delayed enough to be overtaken by later ones. |
partition | (a: List<str>, b: List<str>, r#for: Dur = 0ms)Cuts all links between the two groups in both directions, for for (0 = until heal()). |
block | (from: List<str>, to: List<str>, r#for: Dur = 0ms)Asymmetric partition |
heal | ()Removes every partition. |
isBlocked | (from: str, to: str) -> boolWhether messages from from to to are currently lost. |
Defined in: std/test/test.oxl:66