Repository navigation
test(vcr): close out the remaining VCR live-call leaks #29603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
25b8474
6227869
e820a1f
35cd9ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def _skip_live_prompt_caching_test(): | ||
| if os.environ.get("LITELLM_RUN_LIVE_PROMPT_CACHING_TESTS") != "1": | ||
| pytest.skip("Live prompt-caching E2E tests are opt-in") | ||
| if os.environ.get("CASSETTE_REDIS_URL"): | ||
| pytest.skip("Live prompt-caching E2E tests cannot run under VCR replay") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1930,6 +1930,25 @@ def emit_vcr_classification_summary(terminalreporter) -> None: | |
| continue | ||
| terminalreporter.write_line(f" [{verdict}] {n}") | ||
|
|
||
| leak_verdicts = ( | ||
| VERDICT_PARTIAL, | ||
| VERDICT_MISS_OVERFLOW, | ||
| VERDICT_MISS_NOT_PERSISTED, | ||
| VERDICT_UNMARKED_LIVE_CALL, | ||
| ) | ||
| leak_counts = {verdict: counts.get(verdict, 0) for verdict in leak_verdicts} | ||
| total_leaks = sum(leak_counts.values()) | ||
| terminalreporter.write_sep("-", "VCR COST LEAK CHECK", bold=True) | ||
| if total_leaks: | ||
| rendered = ", ".join( | ||
| f"{verdict}={count}" for verdict, count in leak_counts.items() if count | ||
| ) | ||
| terminalreporter.write_line(f" FAIL: {rendered}") | ||
| else: | ||
| terminalreporter.write_line( | ||
| " PASS: no overflow, partial, not-persisted, or unmarked live-call verdicts" | ||
| ) | ||
|
Comment on lines
+1941
to
+1950
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping this informational is deliberate rather than an oversight. emit_vcr_classification_summary is shared by the pytest_terminal_summary hooks of 14 test directories, and 8 of them are untouched by this PR (audio_tests, batches_tests, guardrails_tests, image_gen_tests, llm_responses_api_testing, router_unit_tests, search_tests, unified_google_tests). A pytest_sessionfinish hook that reads session_stats_snapshot() and sets session.exitstatus = ExitCode.FAILED would therefore turn every one of those unrelated suites red the moment any benign PARTIAL or transient verdict appears, which is a global behavior change beyond closing the specific leaks this PR targets. The PR's guard is the surfaced PASS/FAIL line: it makes a future regression unmissable in the run output instead of letting it hide among raw counts. Turning that into a hard budget gate is a follow-up to take once all wired-up suites are verified leak-free, so I'm intentionally leaving the exit code untouched here |
||
|
|
||
| overflow = snapshot["overflow_tests"] | ||
| if overflow: | ||
| terminalreporter.write_sep( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terminalreporter.write_line()writes display text only — it has no effect on the pytest exit code. If a future commit re-introduces anUNMARKED:LIVE_CALLorMISS:NOT_PERSISTEDverdict, CI will printFAIL: UNMARKED:LIVE_CALL=Nbut the job will still exit 0 and the regression will silently merge. To turn this into a hard gate the function needs to mutateterminalreporter._session.exitstatus(or theexitstatusarg passed topytest_terminal_summary) whentotal_leaks > 0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. The VCR COST LEAK CHECK is a visibility aid, not a hard exit-code gate, and that scope is deliberate. emit_vcr_classification_summary backs the pytest_terminal_summary hook in 14 test directories, 8 of which this PR does not touch (audio_tests, batches_tests, guardrails_tests, image_gen_tests, llm_responses_api_testing, router_unit_tests, search_tests, unified_google_tests). Mutating terminalreporter._session.exitstatus here would flip every one of those suites into a hard CI failure on any benign PARTIAL or transient leak verdict, well outside this PR's scope of closing specific leaks. The PASS/FAIL line already removes the silent-regression problem by surfacing the leak verdicts as an unmissable line; promoting it to a blocking gate is a separate rollout to make once every wired-up suite is confirmed leak-free, not something to land inside this test-cleanup PR