Repository navigation
test: fix two flaky callback probe and spend-cleanup tests - #46898
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…dge failure test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Automatic reviews are disabled for this repository. |
|
@litereview code-review |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
#46855 merged a fix for test_worker_killed_mid_stream_leaves_the_sibling_billing_each_stream_once, so please drop that hunk and keep the other two fixes |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # tests/integration/streaming/test_google_genai_stream_usage_settings_wire.py
|
|
|
Dropped the worker-kill hunk after merging main, since #46855 covers it. The callback probe and spend cleanup fixes are unchanged |
TLDR
Problem this solves:
How it solves it:
CI evidence
Run of 2026-10-16
tests/integration/sdk/test_anthropic_messages_bridge_mid_stream_failure_sdk.py::test_sdk_native_messages_stream_delivers_one_success_callback_with_usagefailed 8 times and passed 14 in the window, flipping ate0fe9626(CircleCI job 2261242 failed, rerun job 2261294 passed) and failing again atecbea933in job 2261441. The mechanism is shared module-level state._CallbackProbesits in the globallitellm.callbacksand recorded every success event in the process, so late success callbacks from earlier sdk-shard tests (a databricks completion and two other chat calls in job 2261242) landed in it andlen(successes) == 1saw 3. Running the wholesdkgroup locally atorigin/mainreproduced it 3 out of 3. The probe now takes thelitellm_call_ids it owns and ignores the rest. The bridge test in the same file now uses one probe for both of its calls, sinceLoggingCallbackManagerdedupes custom loggers by a key that ignores private fields, so a second probe instance is never registeredtests/unit/proxy/test_spend_log_cleanup.py::test_cleanup_old_spend_logs_retention_period_cutofffailed on attempt 1 and passed on attempt 2 of run 38843643564 and run 38839048391, withassert 1.29 < 1. The mechanism is wall-clock dependence. The expected cutoff came from adatetime.now()read after cleanup finished, with a 1 second tolerance, so a slow runner broke it. The test now reads the clock right before and right aftercleanup_old_spend_logsand asserts the cutoff sits between those two reads minus 24 hoursEach regression test was checked against a mutation of the behavior it covers (a duplicated success callback, a duplicated failure callback, retention parsed as 86000 seconds) and failed every time, then the mutation was reverted
Dropped
The worker-kill fix for
test_worker_killed_mid_stream_leaves_the_sibling_billing_each_stream_oncewas dropped after merging main, since #46855 already landed a fix for itOpen deflake PRs left alone
#41219, #42936 and #43437 each have a human approval, so this run left them untouched and opened this PR instead
Pre-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 moreDelays 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
Final Attestation
Link to Devin session: https://app.devin.ai/sessions/202405334c3a4d739d07339a886f4a45
Open in Devin Desktop: https://app.devin.ai/desktop/session/202405334c3a4d739d07339a886f4a45?variant=devin