test(e2e): lock in rate-limit failover and saturated-alias behavior#496
Conversation
The two most subtle rate-limit behaviors had unit coverage only, because the e2e fixture could not wire failover rules or a model resolver. The fixture now accepts a shared registry, a model resolver, and a failover resolver, mirroring the app wiring. Two tests pin the end-to-end contracts: - A rate-saturated primary route with configured failover rules is served by the failover target with no 429, and the saturated primary is never called again. - A virtual model whose targets are all rate-saturated still resolves and returns the honest 429 with Retry-After and rate_limit_exceeded — not an unavailable-model error — after round-robin alternated targets while capacity lasted, and the blocked request never reaches upstream. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds a new E2E test file exercising rate-limit-driven failover and virtual-model alias saturation scenarios, including a static failover resolver and request/model inspection helpers. The E2E server test harness is extended with optional fields for injecting a shared registry, model resolver, and failover resolver. ChangesRate-limit failover E2E tests
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant Test
participant Server
participant RateLimiter
participant PrimaryModel
participant FailoverModel
Test->>Server: send request 1 (primary model)
Server->>RateLimiter: check capacity
RateLimiter-->>Server: allowed
Server->>PrimaryModel: forward request
PrimaryModel-->>Test: 200
Test->>Server: send request 2 (primary model)
Server->>RateLimiter: check capacity
RateLimiter-->>Server: saturated
Server->>FailoverModel: forward request (failover)
FailoverModel-->>Test: 200
sequenceDiagram
participant Test
participant Server
participant VirtualModelService
participant RateLimiter
participant TargetA
participant TargetB
Test->>Server: alias request 1
Server->>VirtualModelService: resolve target
VirtualModelService->>RateLimiter: check capacity TargetA
RateLimiter-->>VirtualModelService: allowed
VirtualModelService->>TargetA: forward
TargetA-->>Test: 200
Test->>Server: alias request 2
Server->>VirtualModelService: resolve target
VirtualModelService->>RateLimiter: check capacity TargetB
RateLimiter-->>VirtualModelService: allowed
VirtualModelService->>TargetB: forward
TargetB-->>Test: 200
Test->>Server: alias request 3
Server->>VirtualModelService: resolve target
VirtualModelService->>RateLimiter: check capacity (both saturated)
RateLimiter-->>VirtualModelService: denied
VirtualModelService-->>Test: 429 rate_limit_exceeded
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
What
Closes the last test gap from #482/#492: the two most subtle rate-limit behaviors — saturated primary → skip provider → failover serves and fully saturated alias → honest 429 — were covered by unit tests only, because the e2e fixture had no way to wire failover rules or a model resolver.
Changes
e2eServerOptionsgains three fields mirroring the app wiring: a sharedregistry(so collaborators like virtual models and capacity probes see the same catalog), amodelResolver, and afailoverResolver.TestRateLimitSaturatedPrimaryFailsOver_E2E: a model rule saturatesgpt-4after one request; with a failover rule togpt-3.5-turbo, the second request returns 200 served by the failover target, and the recorded upstream traffic proves the saturated primary was never called again.TestRateLimitFullySaturatedAliasReturns429_E2E: a two-target virtual model wired exactly like production (registry catalog +SetTargetCapacityprobe) round-robins while a provider-scoped rule has capacity, then — with every target saturated — returns429+Retry-After+rate_limit_exceeded, not an unavailable-model error, with the blocked request never reaching upstream.User-visible impact
None — test-only, plus fixture plumbing. Full e2e and unit suites pass.
🤖 Generated with Claude Code
Summary by CodeRabbit
429 Too Many Requestsresponse with retry information and a standard error payload.