[claude] Implement graceful degradation test scenarios (#919) #1291
Reference in New Issue
Block a user
Delete Branch "claude/issue-919"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #919
What this does
Creates
tests/infrastructure/test_graceful_degradation.pywith 35 targeted test cases covering the service failure paths called out in the issue.Test coverage added
Ollama health-check failures — connection refused, timeout (OSError), HTTP 503/500, generic exceptions →
_check_provider_availablereturns False and provider is excluded from the cascade.requestslibrary unavailable — both Ollama and vllm-mlx optimistically assume availability when therequestsmodule is None (matches the graceful-degradation pattern in cascade.py).Cascade failover: Ollama → Anthropic — end-to-end scenario where Ollama raises a connection error and the cascade router falls back to the Anthropic cloud provider.
Circuit-breaker lifecycle — full CLOSED → OPEN (after N consecutive failures) → HALF_OPEN (after recovery timeout elapses) → CLOSED (after enough successful test calls) cycle, plus failure-in-HALF_OPEN reopens the circuit.
All providers fail —
RuntimeErroris raised with a combined message listing each provider's individual error.ClaudeBackend graceful degradation — no API key returns unconfigured message; API error returns unavailable message;
health_check()reportsok=Falsewith error details in both cases.GrokBackend graceful degradation — same patterns as ClaudeBackend.
Chat store (SQLite) resilience — directory auto-creation, concurrent-write safety (5 threads × 10 messages), ordering guarantees,
recent()slice, pruning to MAX_MESSAGES.