Chaos test APIs by injecting latency, errors, and network faults with Toxiproxy, then load-testing resilience with vegeta and hey.
Agentic Workflow: Read -> Reason -> Act (chaos-testing)
You are Chaos Testing (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for chaos-testing
- Domain: Chaos test APIs by injecting latency, errors, and network faults with Toxiproxy, then load-testing resilience with vegeta and hey.
- fault-injection: Inject latency, bandwith, and error faults on a proxy between client and API using toxiproxy-cli —
toxiproxy-cli create api -l localhost:8081 -u localhost:8080
- resilience-load: Generate load against the faulted API and measure error rates and percentiles —
vegeta attack -targets targets.txt -rate 50 -duration 30s | vegeta report
- Check
knowledge and prerequisites: hey, toxiproxy-cli, vegeta
2. Reason — think for chaos-testing
- For
fault-injection: Inject latency, bandwith, and error faults on a proxy between client and API using toxiproxy-cli — decide which checks to run
- For
resilience-load: Generate load against the faulted API and measure error rates and percentiles — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with chaos-testing tools
- Tools:
Glob, Grep, Read, Toxiproxy-cli, Vegeta (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
chaos-testing:f1e0bd7e
Chaos Testing
Test API resilience by injecting faults through a proxy and measuring behavior under load.
When to Use
- Verifying circuit breakers and retries trigger correctly
- Measuring p95/p99 latency under injected latency
- Confirming the API degrades gracefully, not fatally
Setup
toxiproxy-server &
# or in Docker
docker run -d -p 8474:8474 shopify/toxiproxy
export GOPATH=$(go env GOPATH)
go install github.com/tsenart/vegeta/v12@latest
Proxy and Faults
toxiproxy-cli create api -l localhost:8081 -u localhost:8080
toxiproxy-cli toxic add -t latency -a latency=500 -a jitter=100 api
toxiproxy-cli list
toxiproxy-cli toxic remove -t latency api
toxiproxy-cli delete api
Load Test
cat > targets.txt <<EOF
POST http://localhost:8081/api/users
Content-Type: application/json
EOF
vegeta attack -targets targets.txt -rate 50 -duration 30s | vegeta report
hey -n 1000 -c 50 http://localhost:8081/api/users
Interpretation
- Latency 500ms injected: expect p95 to rise ~500ms
- Disconnect toxic: expect errors to spike and circuit breaker to open
Testing
# Baseline without faults, then with faults, and compare
vegeta attack -targets targets.txt -rate 50 -duration 30s -output baseline.bin
vegeta report baseline.bin
Best Practices
- Run baseline before injecting faults
- Inject one fault at a time to attribute effects
- Point load at the proxy (8081), not the real API (8080)
- Clean up toxics after each experiment
- Combine with monitoring to correlate spikes
Capabilities
fault-injection
Inject latency, bandwith, and error faults on a proxy between client and API using toxiproxy-cli
Parameters:
toxin_type (string): latency, bandwidth, disconnect, timeout, or reset_peer
latency_ms (string): Amount of latency to inject in milliseconds
Commands:
toxiproxy-cli create api -l localhost:8081 -u localhost:8080
toxiproxy-cli toxic add -t latency -a latency=500 -a jitter=100 api
toxiproxy-cli toxic add -t bandwidth -a rate=10 api
toxiproxy-cli toxic add -t disconnect -a toxicity=1 api
Examples:
- toxiproxy-cli create api -l localhost:8081 -u localhost:8080
- toxiproxy-cli toxic add -t latency -a latency=500 -a jitter=100 api
- toxiproxy-cli toxic remove -t latency api
resilience-load
Generate load against the faulted API and measure error rates and percentiles
Parameters:
rate (string): Requests per second for vegeta
duration (string): Test duration such as 30s or 1m
Commands:
vegeta attack -targets targets.txt -rate 50 -duration 30s | vegeta report
vegeta attack -targets targets.txt -rate 50 -duration 30s -output results.bin && vegeta report -type=json results.bin
hey -n 1000 -c 50 http://localhost:8080/api/users
ab -n 1000 -c 50 http://localhost:8080/api/users
Examples:
- echo "POST http://localhost:8080/api/users" > targets.txt && echo "Content-Type: application/json" >> targets.txt && vegeta attack -targets targets.txt -rate 20 -duration 20s | vegeta report
- hey -n 500 -c 25 http://localhost:8080/api/users
- vegeta attack -targets targets.txt -rate 100 -duration 60s -output results.bin; vegeta report -type=hist[0,100ms,500ms,1s] results.bin
References
1---2name: "chaos-testing"3description: "Chaos test APIs by injecting latency, errors, and network faults with Toxiproxy, then load-testing resilience with vegeta and hey. Use when working with fault injection, resilience load, api or when the user mentions fault injection, resilience load, api."4license: "MIT"5compatibility: "Requires hey, toxiproxy-cli, vegeta."6metadata:7 source: https://skillmd.com/skills/opknock/chaos-testing8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(ab:*) Bash(hey:*) Bash(toxiproxy-cli:*) Bash(vegeta:*)"12---1314Chaos test APIs by injecting latency, errors, and network faults with Toxiproxy, then load-testing resilience with vegeta and hey.1516## Agentic Workflow: Read -> Reason -> Act (chaos-testing)1718You are **Chaos Testing** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `chaos-testing`21- Domain: Chaos test APIs by injecting latency, errors, and network faults with Toxiproxy, then load-testing resilience with vegeta and hey.22- **fault-injection**: Inject latency, bandwith, and error faults on a proxy between client and API using toxiproxy-cli — `toxiproxy-cli create api -l localhost:8081 -u localhost:8080`23- **resilience-load**: Generate load against the faulted API and measure error rates and percentiles — `vegeta attack -targets targets.txt -rate 50 -duration 30s | vegeta report`24- Check `knowledge` and `prerequisites: hey, toxiproxy-cli, vegeta`2526### 2. Reason — think for `chaos-testing`27- For `fault-injection`: Inject latency, bandwith, and error faults on a proxy between client and API using toxiproxy-cli — decide which checks to run28- For `resilience-load`: Generate load against the faulted API and measure error rates and percentiles — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `chaos-testing` tools32- Tools: `Glob`, `Grep`, `Read`, `Toxiproxy-cli`, `Vegeta` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `chaos-testing:f1e0bd7e`3536# Chaos Testing3738Test API resilience by injecting faults through a proxy and measuring behavior under load.3940## When to Use4142- Verifying circuit breakers and retries trigger correctly43- Measuring p95/p99 latency under injected latency44- Confirming the API degrades gracefully, not fatally4546## Setup4748```bash49toxiproxy-server &50# or in Docker51docker run -d -p 8474:8474 shopify/toxiproxy52export GOPATH=$(go env GOPATH)53go install github.com/tsenart/vegeta/v12@latest54```5556## Proxy and Faults5758```bash59toxiproxy-cli create api -l localhost:8081 -u localhost:808060toxiproxy-cli toxic add -t latency -a latency=500 -a jitter=100 api61toxiproxy-cli list62toxiproxy-cli toxic remove -t latency api63toxiproxy-cli delete api64```6566## Load Test6768```bash69cat > targets.txt <<EOF70POST http://localhost:8081/api/users71Content-Type: application/json72EOF73vegeta attack -targets targets.txt -rate 50 -duration 30s | vegeta report74hey -n 1000 -c 50 http://localhost:8081/api/users75```7677## Interpretation7879- Latency 500ms injected: expect p95 to rise ~500ms80- Disconnect toxic: expect errors to spike and circuit breaker to open8182## Testing8384```bash85# Baseline without faults, then with faults, and compare86vegeta attack -targets targets.txt -rate 50 -duration 30s -output baseline.bin87vegeta report baseline.bin88```8990## Best Practices9192- Run baseline before injecting faults93- Inject one fault at a time to attribute effects94- Point load at the proxy (8081), not the real API (8080)95- Clean up toxics after each experiment96- Combine with monitoring to correlate spikes9798## Capabilities99100### fault-injection101Inject latency, bandwith, and error faults on a proxy between client and API using toxiproxy-cli102103**Parameters:**104- `toxin_type` (string): latency, bandwidth, disconnect, timeout, or reset_peer105- `latency_ms` (string): Amount of latency to inject in milliseconds106107**Commands:**108- `toxiproxy-cli create api -l localhost:8081 -u localhost:8080`109- `toxiproxy-cli toxic add -t latency -a latency=500 -a jitter=100 api`110- `toxiproxy-cli toxic add -t bandwidth -a rate=10 api`111- `toxiproxy-cli toxic add -t disconnect -a toxicity=1 api`112113**Examples:**114- toxiproxy-cli create api -l localhost:8081 -u localhost:8080115- toxiproxy-cli toxic add -t latency -a latency=500 -a jitter=100 api116- toxiproxy-cli toxic remove -t latency api117118### resilience-load119Generate load against the faulted API and measure error rates and percentiles120121**Parameters:**122- `rate` (string): Requests per second for vegeta123- `duration` (string): Test duration such as 30s or 1m124125**Commands:**126- `vegeta attack -targets targets.txt -rate 50 -duration 30s | vegeta report`127- `vegeta attack -targets targets.txt -rate 50 -duration 30s -output results.bin && vegeta report -type=json results.bin`128- `hey -n 1000 -c 50 http://localhost:8080/api/users`129- `ab -n 1000 -c 50 http://localhost:8080/api/users`130131**Examples:**132- echo "POST http://localhost:8080/api/users" > targets.txt && echo "Content-Type: application/json" >> targets.txt && vegeta attack -targets targets.txt -rate 20 -duration 20s | vegeta report133- hey -n 500 -c 25 http://localhost:8080/api/users134- vegeta attack -targets targets.txt -rate 100 -duration 60s -output results.bin; vegeta report -type=hist[0,100ms,500ms,1s] results.bin135136## References137- [Toxiproxy Docs](https://github.com/Shopify/toxiproxy)138- [Vegeta Docs](https://github.com/tsenart/vegeta)