Repository navigation
test: de-flake langfuse callbacks-in-db e2e test - #32167
Conversation
The test posted /config/update, slept a fixed 20s, then fired a single chat request with no readiness check or retry. When the single-process proxy was momentarily not accepting connections in that window, the request failed with a bare openai.APIConnectionError and took the whole job down, since the suite runs against one shared container with pytest -x Gate the chat request behind a /health/liveliness poll, retry it on connection errors only so real HTTP errors and the Langfuse assertion still fail the test, close the previously leaked aiohttp session, and target 127.0.0.1 instead of the 0.0.0.0 bind address. In CI, give the proxy container --restart on-failure so an intermittent crash recovers instead of leaving the port dead for the rest of the run
…itellm_/suspicious-jennings-5b6ef7
Greptile SummaryThis PR de-flakes the
Confidence Score: 5/5Safe to merge — changes are scoped entirely to a CI test file and the CircleCI config; no production code is touched. Both changes target the flaky test window: the Docker restart policy prevents a dead port from blocking the job, and the readiness poll plus connection-error retry loop in the test ensure the request is only sent when the proxy is up and can survive a momentary blip. The core Langfuse assertion is preserved verbatim, so the test still validates the actual callback behaviour. The aiohttp.ClientSession leak fix and address change from 0.0.0.0 to 127.0.0.1 are straightforward correctness improvements with no side effects. No files require special attention; both changed files are self-contained and the modifications are well-scoped.
|
| Filename | Overview |
|---|---|
| tests/store_model_in_db_tests/test_callbacks_in_db.py | Reliability improvements: adds proxy readiness polling, connection-error-only retry logic, fixes leaked aiohttp session, changes bind address from 0.0.0.0 to 127.0.0.1, and extends Langfuse flush sleep; core assertions are unchanged |
| .circleci/config.yml | Adds --restart on-failure to the proxy Docker container so an intermittent crash no longer leaves port 4000 permanently dead for the rest of the job |
Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
The failure this addresses is
proxy_store_model_in_db_testsdying ontest_e2e_langfuse_callbacks_in_dbwithopenai.APIConnectionError: Connection errorwhile opening a connection to the proxy, one recent example being this run. The captured stdout shows/config/updatereturning 200, then twenty seconds later the single chat request cannot open a TCP connection, so the whole job stops there underpytest -xThis is a CI-timing fix rather than a request/response behavior change, so the proof is the job itself. Before, a momentary window where the single-process proxy is not accepting connections fails the one blind request outright. After, the request waits on
/health/livelinessand retries transient connection errors, and the container can restart if it crashed, so that window no longer sinks the run. The most direct validation is re-runningproxy_store_model_in_db_testsand watching it stay greenType
🐛 Bug Fix
✅ Test
Changes
tests/store_model_in_db_tests/test_callbacks_in_db.pygets four reliability changes. The chat request is now gated behind a/health/livelinesspoll so it never fires while the worker is mid-cycle, and it retries onopenai.APIConnectionErroronly, which means a real HTTP error or a failed Langfuse assertion still fails the test rather than being masked. The previously leakedaiohttp.ClientSessionis wrapped inasync with, clearing theUnclosed client sessionwarning. Requests target127.0.0.1:4000instead of the0.0.0.0bind address.circleci/config.ymlgives themy-appproxy container--restart on-failure. The proxy runs as a single process with no supervisor, so an intermittent crash previously left port 4000 dead for the rest of the job; with the restart policy the container comes back and the readiness poll rides out the gapThe Langfuse assertion path is unchanged, so the test still verifies that the callback actually logs the request