gw-06 — Verification
One command
cd gw-06-resilience-load-balancing && bash scripts/verify.sh
What the tests prove
| Test | Invariant |
|---|---|
TestP2CRoutesAroundSlowEndpoint | P2C picks a 100×-slow endpoint <1% of the time (round-robin would send 20%) |
TestOutlierEjectionRespectedByPick | an ejected endpoint is never picked |
TestEjectionExpires | ejection clears after the (growing) cool-down |
TestPanicModeWhenTooManyEjected | if >50% would be ejected, the balancer uses everyone (never black-holes) |
TestAdaptiveGrowsWhenHealthy | limit grows when current latency ≈ no-load minimum |
TestAdaptiveShrinksUnderLatency | a 100× latency jump collapses the limit (toward its ~4 fixed point) |
TestAdaptiveShedsAtLimit | requests over the limit are shed at admission, not queued |
TestRetryBudgetCapsAmplification | retries are capped at the budget fraction of traffic |
TestCircuitBreaker | full CLOSED→OPEN→HALF-OPEN cycle: fail-fast, probe, reopen-on-fail, close-on-success |
All under -race (balancers/limiters/breakers use atomics + injectable
clocks for determinism).
Demo assertion (resilsim, in verify.sh)
- naive retries → offered load stuck over capacity after the spike (metastable),
- retry budget → recovers to baseline immediately.
What "green" does NOT guarantee
- Not wired into a live proxy. Composing budget+breaker+limiter+P2C
into a resilient
http.RoundTripperis an exercise (GUIDE §6.1). - No hedging / criticality shedding in the core package (exercises §6.2/§6.4).
- Per-instance budgets/limits. Fleet-wide correctness for distributed rate limiting needs a shared store (CONCEPTS §3 / gw-03 note).