# Run the failure tests The chaos runner checks the delivery guarantee under nine faults. A scenario passes only with **0 missing and 0 duplicates**. ```console $ make chaos # all scenarios, 2,000 devices $ make chaos SCENARIOS=network-cut,ingest-kill DEVICES=200 $ bin/fleetwire-chaos list ``` `make chaos` builds the binaries, starts the stack and runs `bin/fleetwire-chaos run`; call the binary directly for the other flags (`-steady`, `-after`, `-wal-sync`, `-interval`). Each scenario: wait for a healthy stack, create a fresh tenant, start the load generator and wait until it has started every device, keep steady load (`-steady`, 60 s), inject the fault, hold it, recover, measure the recovery time, keep load until `-after` (60 s) has passed since the fault ended, stop the load generator (it drains and writes `results.jsonl`), and run the checker. A device that does not start (at the beginning, or when agent-kill restarts the load generator) fails the scenario, and so does a checker report with fewer devices than the run asked for. | Scenario | Fault | Recovery | |---|---|---| | `network-cut` | Toxiproxy disables the device-to-broker proxy for 60 s | enable | | `network-degraded` | 300 ms ± 200 ms latency and 512 KB/s per connection, both ways; `reset_peer` on 5% of connections; 120 s | remove the toxics | | `mosquitto-restart` | `docker compose restart mosquitto` | automatic | | `kafka-broker-kill` | SIGKILL `kafka-2`, 60 s | start it | | `kafka-outage` | stop all three brokers, 60 s | start them | | `postgres-outage` | SIGKILL `postgres`, 60 s | start it | | `bridge-kill` | SIGKILL `bridge-1`, 30 s | start it | | `ingest-kill` | SIGKILL `ingest-1`, 30 s | start it | | `agent-kill` | SIGKILL the whole load generator | restart it with the same state directory | **Recovery time** is the time from the end of the fault until every device is connected again and the p99 end-to-end delay of newly stored readings is under 5 s, both holding for 30 s; it is measured to the start of those 30 s. The p99 comes from Prometheus over a 20 s window that never reaches back before the end of the fault, so readings stored while the stack was still healthy cannot make a recovery look instant. Prometheus scrapes every 5 s, so the runner cannot see a recovery faster than about 5 to 10 s. For `agent-kill` the time includes reopening every device. It also includes the devices' reconnect backoff (full jitter, up to 60 s), so it is often close to a minute after long outages. The tables recorded so far in `docs/results/` and the README were measured with the earlier method. The runner queried the p99 over a 20 s window every 2 s from the end of the fault and stopped at the first value under 5 s, without checking connections. That window could still hold mostly readings committed before or during the fault, so the first query could pass before a backlog reached the database. A recovery of `0s` in those tables says that the first query passed, not that the backlog was already stored. The checker compares each device's line in `results.jsonl` (its last seq and the gaps it reported) with what the database holds, and the table takes its counts from the checker. **Devices** is the number of devices the checker saw, so a device that never started shows as a short count and fails the row. Besides missing and duplicate seqs, the checker counts `beyond_last_seq`: stored seqs above the device's last seq, which is what a device that lost its local state and reused seqs leaves behind. Any of them fails the scenario. The row's note names failures that have no column of their own. Results go to `docs/results/