Router Chaos Testing Runbook

Sprint: SPRINT_5100_0005_0001 Last Updated: 2025-12-22 Audience: Platform / SRE engineers operating or hardening the Stella Ops Router.

Overview

This runbook describes the chaos-testing approach for the Stella Ops Router — the admission and request-routing layer in front of the platform’s microservices. The goal is to prove three behaviours under stress:

For the production rate-limiting contract (response semantics, headers, metrics), see the companion Router Rate Limiting Runbook.

Test Categories

1. Load Testing (k6)

Location: src/__Tests/load/router/

Spike Test Scenarios

ScenarioRateDurationPurpose
Baseline100 req/s1 minEstablish normal operation
10x Spike1000 req/s30sModerate overload
50x Spike5000 req/s30sSevere overload
Recovery100 req/s2 minMeasure recovery time

Running Load Tests

# Install k6
brew install k6  # macOS
# or
choco install k6  # Windows

# Run spike test against a local Router
k6 run src/__Tests/load/router/spike-test.js \
  -e ROUTER_URL=http://localhost:8080

# Run against a staging Router
k6 run src/__Tests/load/router/spike-test.js \
  -e ROUTER_URL=https://router.staging.example.com

# Output results to JSON
k6 run src/__Tests/load/router/spike-test.js \
  --out json=results.json

2. Backpressure Verification

Location: src/__Tests/chaos/StellaOps.Chaos.Router.Tests/BackpressureVerificationTests.cs

Tests verify:

Expected Behavior

Load LevelExpected ResponseRetry-After
Normal200 OKN/A
High (>80% capacity)429 Too Many Requests1-10s
Critical (>95% capacity)503 Service Unavailable10-60s

3. Recovery Testing

Location: src/__Tests/chaos/StellaOps.Chaos.Router.Tests/RecoveryTests.cs

Tests verify:

Recovery Thresholds

MetricTargetCritical
P95 Recovery Time<15s<30s
P99 Recovery Time<25s<45s
Data Loss0%0%

4. Valkey Failure Injection

Location: src/__Tests/chaos/StellaOps.Chaos.Router.Tests/ValkeyFailureTests.cs

Tests verify router behavior when Valkey (cache/session store) fails:

Failure Scenarios

ScenarioExpected Behavior
Valkey unreachableFallback to direct processing
Valkey slow (>500ms)Timeout and continue
Valkey returnsResume normal caching

CI Integration

Workflow: .gitea/workflows/chaos-router.yml

The StellaOps.Chaos.Router.Tests suite runs against an in-process Gateway hosted by ChaosGatewayFactory. It is triggered:

Gating flags. The suite is gated on the environment variable STELLAOPS_TEST_CHAOS=1; without it the tests skip silently (see Fixtures/ChaosFactAttribute.cs). The Valkey-flap subset is gated additionally on STELLAOPS_TEST_CHAOS_VALKEY=1 and is left off in the default lane because the in-process Gateway is not yet wired to a Valkey messaging transport (the container runs as a sidecar only).

Workflow stages

  1. Build — compile the Router and chaos test projects.
  2. Backpressure — run BackpressureVerificationTests.
  3. Recovery & resilience — run RecoveryTests and (when enabled) ValkeyFailureTests.
  4. Report — upload results as workflow artifacts.

Interpreting Results

Success Criteria

MetricPassFail
Request success rate during normal load>=99%<95%
Throttle response rate during spike>0% (expected)0% (no backpressure)
Recovery time P95<30s>=45s
Data loss0%>0%

Common Failure Patterns

No Throttling Under Load

Symptom: 0% throttled requests during 50x spike Cause: Backpressure not configured or circuit breaker disabled Fix: Check router configuration backpressure.enabled=true

Slow Recovery

Symptom: Recovery time >45s Cause: Request queue not draining properly Fix: Check maxQueueSize and drainTimeoutSeconds settings

Missing Retry-After Header

Symptom: 429/503 without Retry-After Cause: Header middleware not applied Fix: Ensure UseRetryAfterMiddleware() is in pipeline

Metrics & Dashboards

Key Metrics to Monitor

# Throttle rate
rate(http_requests_total{status="429"}[5m]) / rate(http_requests_total[5m])

# Recovery time
histogram_quantile(0.95, rate(request_recovery_seconds_bucket[5m]))

# Queue depth
router_request_queue_depth

Alert Thresholds

AlertConditionSeverity
High Throttle Ratethrottle_rate > 10% for 5mWarning
Extended Throttlethrottle_rate > 50% for 2mCritical
Slow Recoveryp95_recovery > 30sWarning
No Recoveryp99_recovery > 60sCritical

Troubleshooting

Test Environment Setup

# Start the Router locally
docker compose up router valkey

# Verify Router health
curl http://localhost:8080/health

# Verify Valkey connection
docker exec -it valkey valkey-cli ping

Debug Mode

# Run the chaos suite with verbose logging (set the gating flag first)
STELLAOPS_TEST_CHAOS=1 dotnet test \
  src/__Tests/chaos/StellaOps.Chaos.Router.Tests/StellaOps.Chaos.Router.Tests.csproj \
  --logger "console;verbosity=detailed"

# k6 with debug output
k6 run src/__Tests/load/router/spike-test.js --verbose

References