Skip to content

refactor(aibridge): consolidate key failover interceptor tests#26032

Open
ssncferreira wants to merge 1 commit into
ssncf/refactor-mock-helpersfrom
ssncf/consolidate-failover-tests
Open

refactor(aibridge): consolidate key failover interceptor tests#26032
ssncferreira wants to merge 1 commit into
ssncf/refactor-mock-helpersfrom
ssncf/consolidate-failover-tests

Conversation

@ssncferreira
Copy link
Copy Markdown
Contributor

@ssncferreira ssncferreira commented Jun 3, 2026

Consolidates the per-interceptor key-failover tests into a single table-driven keyfailover_test.go, parameterized over the interceptors (messages, chatcompletions, responses) and modes (blocking and streaming).

It keeps the two scenarios as separate tests: TestInterception_KeyFailover (failover within a single interception) and TestInterception_AgenticLoopFailover (failover across an agentic-loop continuation). Same cases and assertions as before with far less duplication, reusing the shared testutil mocks (MockUpstream, MockServerProxier, fixture helpers).

Closes https://linear.app/codercom/issue/AIGOV-396/consolidate-intercept-key-failover-tests-across-modes-and-providers
Closes https://linear.app/codercom/issue/AIGOV-395/share-a-single-mockupstream-helper-between-integration-tests-and

Note

Initially generated by Claude Opus 4.7, modified and reviewed by @ssncferreira

Copy link
Copy Markdown
Contributor Author

ssncferreira commented Jun 3, 2026

@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch from 7cec5a2 to 10db29f Compare June 3, 2026 18:53
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from a4ce49f to e54a44b Compare June 3, 2026 18:53
@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch from 10db29f to e126bf3 Compare June 3, 2026 19:40
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from e54a44b to 0d8660b Compare June 3, 2026 19:40
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from 0d8660b to 96a8da9 Compare June 5, 2026 08:43
@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch from e126bf3 to 2ba2851 Compare June 5, 2026 08:43
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from 96a8da9 to 425030a Compare June 5, 2026 11:41
@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch 2 times, most recently from 312f185 to d885ef1 Compare June 5, 2026 17:02
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from 425030a to 0c09405 Compare June 5, 2026 17:02
Comment on lines +442 to +444
if retryAfter := r.responseHeaders.Get("Retry-After"); retryAfter != "" {
w.Header().Set("Retry-After", retryAfter)
}
Copy link
Copy Markdown
Contributor Author

@ssncferreira ssncferreira Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by: aibridge was not forwarding the Retry-After header to clients in error responses (e.g., 429). More specifically, in the context of this PR, for the BYOK test case below, when the upstream responds with a 429. This is to keep the response logic consistent with the other interceptors to consolidate the tests.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 5, 2026

AIGOV-396

AIGOV-395

@ssncferreira ssncferreira marked this pull request as ready for review June 5, 2026 17:33
@ssncferreira ssncferreira requested a review from pawbana June 5, 2026 17:33
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from 0c09405 to 3d46b76 Compare June 8, 2026 07:55
@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch from d885ef1 to 0873093 Compare June 8, 2026 07:55
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from 3d46b76 to f38f8d5 Compare June 8, 2026 09:25
@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch from 0873093 to b8b0b96 Compare June 8, 2026 09:25
@ssncferreira ssncferreira force-pushed the ssncf/refactor-mock-helpers branch from f38f8d5 to d4e86bb Compare June 8, 2026 12:19
@ssncferreira ssncferreira force-pushed the ssncf/consolidate-failover-tests branch from b8b0b96 to 00a11c2 Compare June 8, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant