test(proxy): isolate run_server CLI tests from prisma DB-setup path - #28029
Conversation
test_keepalive_timeout_flag and test_timeout_worker_healthcheck_flag were the only run_server tests in test_proxy_cli.py that neither stripped DATABASE_URL/DIRECT_URL nor mocked the prisma DB path. When a DATABASE_URL is present (CI/env leak), run_server --local enters the DB block and blocks in the un-timeout'd subprocess.run(["prisma"]) at proxy_cli.py:987 plus the ProxyExtrasDBManager migrate-deploy retry loops, ~370s per test on the CI runner. --dist=loadscope pins both to one xdist worker, so the proxy-infra job appears stuck at 99% and hits the 20-min timeout. Apply the same isolation every other run_server test in this file already uses: mock PrismaManager.setup_database + should_update_prisma_schema and strip DATABASE_URL/DIRECT_URL. Full module drops from 31.7s to 2.9s locally; both tests fall off the slow list.
…itellm_/determined-yalow-811fee
Greptile SummaryTwo
Confidence Score: 5/5Tests-only change; no production code is modified and all assertions remain intact. The two modified tests receive the exact same DB-isolation scaffolding already present in every other run_server test in the file. Decorator ordering matches the method signature, clear=True correctly replaces the full environment, and no test assertions were weakened or removed. No files require special attention.
|
| Filename | Overview |
|---|---|
| tests/test_litellm/proxy/test_proxy_cli.py | Applies the same DB-isolation mocks and env-stripping pattern to test_keepalive_timeout_flag and test_timeout_worker_healthcheck_flag that all other run_server tests in this file already use; no assertions weakened. |
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! |
c706184
into
litellm_internal_staging
…ow-811fee test(proxy): isolate run_server CLI tests from prisma DB-setup path
Summary
test_keepalive_timeout_flagandtest_timeout_worker_healthcheck_flagintests/test_litellm/proxy/test_proxy_cli.pywere the onlyrun_servertests in that file that neither strippedDATABASE_URL/DIRECT_URLfrom the environment nor mocked the prisma DB-setup path.When a
DATABASE_URLis present (CI env / cross-test leak within an xdist worker),run_server --localenters the DB-setup block and blocks in:subprocess.run(["prisma"], capture_output=True)atlitellm/proxy/proxy_cli.py:987, thenProxyExtrasDBManagerprisma migrate deployretry loops (4 ×timeout=60+ backoff, repeated)On the CI runner (no reachable Postgres) this is ~370s per test. Because
--dist=loadscopepins both tests (same module) to one xdist worker, theUnit Tests: Proxy Infrastructurejob spends ~12.5 min on that single worker while the other finishes in ~3 min — the run appears stuck at 99% and crosses the 20-minute job timeout.The fix applies the same isolation every other
run_servertest in this file already uses: mockPrismaManager.setup_database+should_update_prisma_schema, and stripDATABASE_URL/DIRECT_URLviapatch.dict(os.environ, clean_env, clear=True). Tests-only change; no production code touched.Test plan
Reproduced and verified locally (
tests/test_litellm/proxy/test_proxy_cli.py, full module):test_keepalive_timeout_flagtest_timeout_worker_healthcheck_flagDATABASE_URLsetThe two tests fall off the slow-durations list entirely and behave like the other 30
run_serversiblings. Assertions (uvicorn arg threading) are unchanged and still pass.Note
Low Risk
Tests now explicitly avoid the Prisma DB-setup path when
DATABASE_URL/DIRECT_URLare present, reducing CI flakiness/timeouts; production behavior is unchanged. Risk is low since changes are limited to test isolation/mocking.Overview
Makes
test_keepalive_timeout_flagandtest_timeout_worker_healthcheck_flagconsistent with otherrun_serverCLI tests by preventing accidental entry into the Prisma DB-setup path.Both tests now (1) patch
PrismaManager.setup_databaseandshould_update_prisma_schemaand (2) run under a sanitized env (patch.dict(..., clear=True)) that stripsDATABASE_URL/DIRECT_URL, keeping assertions focused on uvicorn arg threading without triggering slow DB/migration subprocess work in CI.Reviewed by Cursor Bugbot for commit aebb606. Bugbot is set up for automated code reviews on this repo. Configure here.