[test] Fix flaky gateway e2e tests - #2500
Conversation
Signed-off-by: Jiaxin Shan <seedjeffwan@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request refactors end-to-end tests to improve reliability. In model_rps_limit_test.go, sequential requests are replaced with concurrent requests to reliably test the 1 RPS limit within the same window, and a helper function is introduced to assert that exactly one request is allowed and one is rejected. In routing_strategy_test.go, the flaky probabilistic test for novel prefix routing is removed. The reviewer suggests reusing a single OpenAI client instance across concurrent requests in sendConcurrentRequests to minimize TCP/TLS handshake overhead and timing jitter, ensuring requests are dispatched as simultaneously as possible.
There was a problem hiding this comment.
Pull request overview
This PR targets flakiness in the gateway E2E test suite by making routing and rate-limit assertions deterministic under timing variance and load-balancing tie-breaking.
Changes:
- Simplifies
TestPrefixCacheRoutingto only assert deterministic warm-pod reuse (removing probabilistic “novel prefix routes elsewhere” logic). - Updates
TestModelRPSLimitto issue two short requests concurrently to reliably land in the same fixed Redis 1s window and assert one 429.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
test/e2e/routing_strategy_test.go |
Removes probabilistic assertions from prefix-cache routing E2E test to avoid tie-break flakiness. |
test/e2e/model_rps_limit_test.go |
Sends concurrent requests and checks exactly one allowed/one throttled to avoid timing-dependent RPS window rollover. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
586bc89 to
d018cfb
Compare
d018cfb to
0852864
Compare
| targetPod2 := getTargetPodFromChatCompletion(t, req, "prefix-cache") | ||
| t.Logf("req: %s, target pod: %v\n", req, targetPod2) | ||
| assert.Equal(t, targetPod, targetPod2) |
Pull Request Description
flaky test fix
Related Issues
Resolves: #2498
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]: Corrections to existing functionality[CI]: Changes to build process or CI pipeline[Docs]: Updates or additions to documentation[API]: Modifications to aibrix's API or interface[CLI]: Changes or additions to the Command Line Interface[Misc]: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.