gw-06 — Verification

One command

cd gw-06-resilience-load-balancing && bash scripts/verify.sh

What the tests prove

TestInvariant
TestP2CRoutesAroundSlowEndpointP2C picks a 100×-slow endpoint <1% of the time (round-robin would send 20%)
TestOutlierEjectionRespectedByPickan ejected endpoint is never picked
TestEjectionExpiresejection clears after the (growing) cool-down
TestPanicModeWhenTooManyEjectedif >50% would be ejected, the balancer uses everyone (never black-holes)
TestAdaptiveGrowsWhenHealthylimit grows when current latency ≈ no-load minimum
TestAdaptiveShrinksUnderLatencya 100× latency jump collapses the limit (toward its ~4 fixed point)
TestAdaptiveShedsAtLimitrequests over the limit are shed at admission, not queued
TestRetryBudgetCapsAmplificationretries are capped at the budget fraction of traffic
TestCircuitBreakerfull 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.RoundTripper is 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).