fix(tests): Fix flaky container and scientific notation tests#20650
Merged
ishaan-jaff merged 2 commits intomainfrom Feb 7, 2026
Merged
fix(tests): Fix flaky container and scientific notation tests#20650ishaan-jaff merged 2 commits intomainfrom
ishaan-jaff merged 2 commits intomainfrom
Conversation
added 2 commits
February 7, 2026 17:44
The test was mocking container_create_handler (sync), but router.acreate_container uses _is_async=True which calls async_container_create_handler. This caused the test to hit the real OpenAI API. Fixed by using AsyncMock on async_container_create_handler.
The test was using a static "unique" model name which could cause conflicts when running tests in parallel (-n 16 in CI). Using uuid ensures truly unique names to prevent test pollution.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Shin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
Greptile OverviewGreptile SummaryFixed two flaky tests that were causing CI instability when running with parallel test workers.
Both fixes are targeted and correct, addressing the root causes of test flakiness without introducing new issues. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/test_litellm/containers/test_container_api.py | Fixed async mock to match router.acreate_container's async call path |
| tests/test_litellm/test_utils.py | Used uuid for unique model names to prevent parallel test conflicts |
Sequence Diagram
sequenceDiagram
participant Test as test_router_acreate_container
participant Router as router.acreate_container
participant CreateContainer as create_container
participant Handler as base_llm_http_handler
participant AsyncHandler as async_container_create_handler
Test->>Router: await router.acreate_container(name="Test Container")
Router->>CreateContainer: create_container(..., async_call=True)
Note over CreateContainer: Sets _is_async=True from kwargs
CreateContainer->>Handler: container_create_handler(..., _is_async=True)
Note over Handler: Checks _is_async flag
Handler->>AsyncHandler: async_container_create_handler(...)
Note over Test: Mock intercepts here (AsyncMock)
AsyncHandler-->>Handler: ContainerObject
Handler-->>CreateContainer: ContainerObject
CreateContainer-->>Router: ContainerObject
Router-->>Test: ContainerObject
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.
Test Fixes
1.
test_router_acreate_container_without_modelProblem: The test mocked
container_create_handler(sync) butrouter.acreate_containeruses_is_async=Truewhich callsasync_container_create_handler(async). This caused the test to hit the real OpenAI API withAuthorization: Bearer None.Fix: Use
AsyncMockonasync_container_create_handlerinstead.2.
test_register_model_with_scientific_notationProblem: The test used a static "unique" model name (
test-scientific-notation-model-unique-12345). When tests run in parallel with-n 16in CI, this can cause conflicts between test workers accessing the sharedlitellm.model_costdictionary.Fix: Use
uuid.uuid4()to generate truly unique model names per test run.Fixes for CI stability