PropertyDamage.Nemesis.NetworkLatency (PropertyDamage v0.2.0)
View SourceInject network latency into the test environment.
Simulates slow network conditions by adding delay to network operations. Useful for testing timeout handling, retry logic, and degraded performance.
Configuration
:latency_ms- Base latency to add (default: 100ms):jitter_ms- Random jitter ± this value (default: 0):duration_ms- How long the latency persists (default: 5000ms):target- What to affect::all,:upstream,:downstream, or specific host
Usage with Toxiproxy
When using Toxiproxy, set :toxiproxy in the adapter context:
context = %{toxiproxy: %{proxy_name: "my_service", api_url: "http://localhost:8474"}}Simulated Mode
Without Toxiproxy, operates in simulated mode where latency is tracked in state but not actually injected. Useful for testing nemesis logic.
Example
defmodule MyModel do
def commands do
[
{CreateOrder, weight: 5},
{PropertyDamage.Nemesis.NetworkLatency, weight: 1} # Low weight for chaos
]
end
endEvents
Emits %NetworkLatencyInjected{} on inject and %NetworkLatencyRestored{} on restore.