test(e2e): add vertex_ai passthrough spend-log coverage - #31761
test(e2e): add vertex_ai passthrough spend-log coverage#31761mubashir1osmani wants to merge 1 commit into
Conversation
Greptile SummaryAdds live e2e coverage for the Vertex AI passthrough spend-log path, closing the gap in the translation coverage matrix. The change is test-only and introduces no production code modifications.
Confidence Score: 4/5Test-only change with no production code touched; safe to merge with minor fixture design notes. The new test and helpers are well-structured and follow established suite patterns. Two small design gaps are worth addressing before the test suite grows: the session-scoped access token can go stale after ~1 hour if a CI session is slow, and conftest.py (session-scoped token scope) and passthrough_client.py (missing
|
| Filename | Overview |
|---|---|
| tests/e2e/llm_translation/test_vertex_passthrough_e2e.py | New e2e test asserting Vertex AI non-streaming passthrough records a costed SpendLogs row; well-structured and follows suite conventions. |
| tests/e2e/llm_translation/vertex_auth.py | New helper that mints a Google ADC access token; uses a typed Protocol to compensate for google.auth's missing stubs; validates token and project before returning a typed dataclass. |
| tests/e2e/llm_translation/conftest.py | Adds session-scoped vertex_credentials fixture that converts ADC failures to skips; the session scope means the access token could expire mid-session in long runs. |
| tests/e2e/llm_translation/passthrough_client.py | Adds VertexHeaders model and vertex_generate route; cosmetic reformatting of existing code included. VertexHeaders omits the tags field that both sibling header models expose. |
| tests/e2e/llm_translation/LLM_TRANSLATION_COVERAGE_MATRIX.md | Updates the coverage matrix to mark Vertex non-streaming + cost as covered and adds a description of the auth split used in the new test. |
Reviews (1): Last reviewed commit: "test(e2e): add vertex_ai passthrough spe..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
c5162d0 to
fc7c1d6
Compare
Port the de-flake of the SDK-based vertex spend test (#31689) into the tests/e2e/llm_translation harness. The vertexai SDK intermittently ignored the proxy api_endpoint override and billed Vertex directly, so the request never reached LiteLLM and no spend was logged; driving native generateContent over the shared transport always reaches the proxy, which the harness already guarantees. The vertex deployment is added at runtime through /model/new with use_in_pass_through rather than declared in the gateway config, and deleted on teardown. That registers the deployment's service account for the /vertex_ai route, so the passthrough call sends only its litellm virtual key in x-litellm-api-key and no upstream bearer, and the proxy mints the Vertex token itself. The credential is the one the proxy already holds, read from the same VERTEXAI_CREDENTIALS/VERTEXAI_PROJECT env; the test never mints a token. Asserts both that the forward succeeds and that a costed SpendLogs row lands (vertex_ai provider, a gemini model, spend > 0, call_type pass_through_endpoint), correlated by the x-litellm-call-id header.
fc7c1d6 to
b2a59c0
Compare
|
Superseded by #31781, a clean single-commit PR with the final approach (vertex deployment added via /model/new with use_in_pass_through, no config, no client-side token minting). The review history here spans two earlier approaches that were abandoned, so closing to avoid confusion |
Relevant issues
Companion to #31689, which de-flakes
tests/pass_through_tests/test_vertex_ai.py::test_basic_vertex_ai_pass_through_with_spendlogby driving the pass-through over HTTP instead of the vertexai SDK. That SDK-bypass flake is why Vertex was the lone gap in the live passthrough matrix (tests/e2e/llm_translation/LLM_TRANSLATION_COVERAGE_MATRIX.md). This closes the non-streaming + cost cell with a real e2e test in that harness, where driving HTTP through the shared transport is the default and the SDK bypass cannot happenLinear ticket
N/A
Pre-Submission checklist
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
Against a live proxy hitting the real Vertex AI API and costing real dollars. The deployment is added through the management endpoint, not the config; the proxy registers its service account for the
/vertex_airoute, so the passthrough call sends only its litellm virtual key and noAuthorizationbearerThe test asserts both sides: the forward returns 2xx with a candidate, and that specific call's
SpendLogsrow lands withcustom_llm_provider == "vertex_ai", a gemini model,spend > 0,call_type == "pass_through_endpoint", andstatus == "success". The 401-before / 200-after above is the non-vacuity: without the registered deployment the passthrough is rejectedType
✅ Test
Changes
tests/e2e/llm_translation/test_vertex_passthrough_e2e.pyadds a vertex deployment at runtime through/model/newwithuse_in_pass_through, drives a nativegenerateContentrequest through/vertex_ai/..., asserts the costedSpendLogsrow, and deletes the deployment on teardown. Adding it through the management endpoint keeps the gateway config untouched;use_in_pass_throughis what makes the proxy register the deployment's service account for the passthrough route and mint the Vertex token itself, so the call carries onlyx-litellm-api-keyand no upstream bearer. The credential is the one the proxy already holds, read from the sameVERTEXAI_CREDENTIALS/VERTEXAI_PROJECTenv, so the test never mints a tokenpassthrough_client.pygains a typedVertexHeadersmodel (just the litellm key) and avertex_generateroute onPassthroughClient. The matrix marks the Vertex non-streaming + cost cell coveredDeploy note: the service account needs
roles/aiplatform.user, and any environment that runs this test needsVERTEXAI_PROJECT/VERTEXAI_CREDENTIALSset (the same secret the proxy uses); the test skips cleanly when they are absentThe change is test-only; no production behavior, performance, or contract changes