This backend supports controlled dependency outage simulation for resilience testing.
Chaos testing is implemented around upstream dependency calls (currently contracts data retrieval). The API can intentionally simulate dependency errors/timeouts and verify graceful degradation behavior.
Set these environment variables:
GRACEFUL_DEGRADATION_ENABLED(trueorfalse, defaulttrue)UPSTREAM_CONTRACTS_URL(defaulthttps://example.invalid/contracts)UPSTREAM_TIMEOUT_MS(default1200, clamped to100..10000)CHAOS_MODE(off,error,timeout,random; defaultoff)CHAOS_TARGETS(comma-separated dependency names, e.g.contracts)CHAOS_PROBABILITY(forrandom, float0..1)
Endpoint: GET /api/v1/contracts
- Normal path:
200withdegraded: falseandsource: upstream - Dependency outage with graceful degradation enabled:
200with empty contracts payload anddegraded: true - Dependency outage with graceful degradation disabled:
503withcontracts_unavailable
- Failures are sanitized to avoid leaking upstream internals in API responses.
- Timeout value is clamped to prevent abuse from unsafe environment configuration.
- Fallback response is explicit (
degraded: true) so downstream consumers can avoid treating it as fresh upstream data. - Chaos controls are environment-driven and should remain disabled in production by setting
CHAOS_MODE=off.
- Upstream dependency becomes unreachable.
- Upstream returns malformed payloads.
- Upstream returns non-2xx status codes.
- Induced timeout/error injections to validate graceful degradation behavior.
- Unit tests validate chaos policy decisions and dependency client behavior.
- Integration tests validate API behavior for success, degraded fallback, and strict failure mode.