Repository navigation
test: wait on conditions instead of wall-clock in guardrail parallelism and scope-option tests - #45571
Merged
Conversation
…sm and scope-option tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Contributor
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Contributor
|
bugbot run |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6a1c8dd. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
How it solves it:
findByRolebefore checking absencesasyncio.EventbarrierCI evidence, mechanism, and fix
Run date 2026-10-09 (window 2026-10-08 09:19 UTC to 2026-10-09 09:19 UTC)
add_guardrail_form.characterization.test.tsx > hides directional scope choices for providers that do not support them, 15 failures in the window, every one on attempt 1 of the UI Unit Tests workflow, at SHAs where the same test passed on neighbouring commits of the same branch (main included). Failure text:Unable to find an accessible element with the role "option" and name "Both (request and response)". Examples on main: run 37847701422 attempt 1, run 37874103404 attempt 1, run 37876710808 attempt 1. Others: 37815547855, 37847959230, 37849567681, 37852112339, 37857584458, 37857661078, 37858777401, 37859690767, 37863670485, 37867437929, 37872367145, 37903646845, all attempt 1. It also failed locally 4 of 20 file runs on unedited main with the box under loadMechanism: async render race. The scope dropdown renders its options after the click settles, and the test used the synchronous
getByRolefor the one option that must be present. The twoqueryByRole(...).not.toBeInTheDocument()checks ran first, so on a slow tick they also passed vacuously against a dropdown that had not opened yetFix:
await screen.findByRole("option", { name: "Both (request and response)" })first, then the two absence checks, which now run against an open dropdown. MutatingsupportsDirectionalLoggingOnlyScopeto always return true makes the test fail on the absence checktests/unit/proxy/test_proxy_utils.py::test_during_call_hook_parallel_execution, 5 failures in the window, all attempt 1 of the Unit Tests workflow (proxy-infra-root shard), each on a different PR whose next run passed it: 37799269742, 37824913943, 37875589831, 37881579012, 37906512189. Failure text:Parallel execution took 1.10s, expected < 0.2sMechanism: wall-clock dependence. Three guardrails each
asyncio.sleep(0.1)and the test asserted the wholeduring_call_hookfinished in under 0.2s, which a loaded xdist worker misses even though the hooks still ran concurrentlyFix: each guardrail records its start, the last one to start sets an
asyncio.Event, and every guardrail waits on that event (bounded bywait_for(..., timeout=5)) before recording its end. Concurrent execution releases the barrier immediately, sequential execution can never reach it, so the test checks parallelism by ordering and not by duration. Replacingasyncio.gather(*guardrail_tasks)inProxyLogging.during_call_hookwith sequential awaits makes the test fail withTimeoutErrorPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Type
✅ Test
Caveats (if any)
Low
test_native_count_finishing_after_quarter_worker_budget_keeps_plan_and_spendflaked 4 times but did not reproduce locally, left for a follow-upFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/1766c3e04dc7459688fb9df5f70f35b9
Open in Devin Desktop: https://app.devin.ai/desktop/session/1766c3e04dc7459688fb9df5f70f35b9?variant=devin
Note
Low Risk
Test-only changes with no production code; risk is limited to test behavior and CI signal quality.
Overview
Deflakes two CI tests by replacing timing- and sync-query assumptions with condition-based waits.
In
test_during_call_hook_parallel_execution, guardrails no longer use fixedasyncio.sleepplus a < 0.2s total-time check. They coordinate with anasyncio.Eventso each hook blocks until all three have started; parallel runs pass quickly, sequential runs time out. The test still asserts that every guardrail starts before any ends.In the guardrail form characterization test for XecGuard logging-only scope, the test now
awaits the "Both (request and response)" option withfindByRolebefore asserting that input/output-only options are absent, so absence checks run against a fully opened dropdown instead of racing async render.Reviewed by Cursor Bugbot for commit 6a1c8dd. Bugbot is set up for automated code reviews on this repo. Configure here.