The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test: fix stale budget-status and bad-database-url assertions
Yuneng Jiang5c6854510400
diff --git a/.circleci/config.yml b/.circleci/config.ymlindex cc9aa7fe1c4..c69ed6a3510 100644--- a/.circleci/config.yml+++ b/.circleci/config.yml@@ -3033,28 +3033,29 @@ jobs:- run:name: Run Docker container with bad DATABASE_URLcommand: |+ set +edocker run --name my-app \-p 4000:4000 \-e LITELLM_DANGEROUSLY_PERMIT_WEAK_OR_UNSET_MASTER_KEY=true \-e DEFAULT_NUM_WORKERS_LITELLM_PROXY=1 \-e DATABASE_URL="postgresql://wrong:wrong@wrong:5432/wrong" \myapp:latest \- --port 4000 > docker_output.log 2>&1 || true+ --port 4000 > docker_output.log 2>&1+ echo "$?" > docker_exit_code+ set -e- run:name: Display Docker logscommand: cat docker_output.log- run:- name: Check for expected error+ name: Proxy must refuse to serve on an unreachable databasecommand: |- if grep -q "Error: P1001: Can't reach database server at" docker_output.log && \- (grep -q "Database setup failed after multiple retries" docker_output.log || \- grep -q "ERROR: Application startup failed. Exiting." docker_output.log); then- echo "Expected error found. Test passed."- else- echo "Expected error not found. Test failed."- cat docker_output.log- exit 1- fi+ fail() { echo "FAILED: $1"; cat docker_output.log; exit 1; }+ exit_code="$(cat docker_exit_code)"+ [ "$exit_code" -ne 0 ] || fail "proxy exited 0 with an unreachable database"+ grep -q "P1001" docker_output.log || fail "log does not name the unreachable database server"+ ! grep -q "Application startup complete" docker_output.log || fail "proxy reached serving state"+ ! docker exec my-app true 2>/dev/null || fail "container is still running"+ echo "Proxy refused to serve (exit $exit_code) and never reached startup. Test passed."provider_replay_harness:docker:diff --git a/tests/otel_tests/test_e2e_budgeting.py b/tests/otel_tests/test_e2e_budgeting.pyindex ca5058818e4..ae8f0ddc3ec 100644--- a/tests/otel_tests/test_e2e_budgeting.py+++ b/tests/otel_tests/test_e2e_budgeting.py@@ -5,6 +5,7 @@ import uuidfrom typing import Any, Optionalimport aiohttp+import openaiimport pytestfrom httpx import AsyncClient@@ -23,7 +24,7 @@ async def make_calls_until_budget_exceeded(session, key: str, call_function, **kcall_count += 1await asyncio.sleep(0.1) # allow spend tracking to catch uppytest.fail(f"Budget was not exceeded after {MAX_CALLS} calls")- except Exception as e:+ except openai.APIStatusError as e:print("vars: ", vars(e))print("e.body: ", e.body)@@ -32,8 +33,8 @@ async def make_calls_until_budget_exceeded(session, key: str, call_function, **k# Check error structure and values that should be consistentassert (- error_dict["code"] == "429"- ), f"Expected error code 429, got: {error_dict['code']}"+ error_dict["code"] == "422"+ ), f"Expected error code 422, got: {error_dict['code']}"assert (error_dict["type"] == "budget_exceeded"), f"Expected error type budget_exceeded, got: {error_dict['type']}"@@ -506,9 +507,9 @@ async def make_calls_until_team_budget_exceeded_cli_sso(call_count += 1await asyncio.sleep(0.1)pytest.fail(f"Budget was not exceeded after {MAX_CALLS} calls")- except Exception as e:+ except openai.APIStatusError as e:error_dict = e.body- assert error_dict["code"] == "429"+ assert error_dict["code"] == "422"assert error_dict["type"] == "budget_exceeded"message = error_dict["message"]assert "Budget has been exceeded!" in message@@ -556,7 +557,7 @@ async def test_team_budget_enforcement_cli_sso_token():1. Create team with a tiny max_budget and a user on that team2. Obtain a CLI SSO JWT (HTTP poll flow when Redis is shared, else mint)3. Make chat completion calls until the team budget is exceeded- 4. Verify HTTP 429 budget_exceeded names the team+ 4. Verify HTTP 422 budget_exceeded names the team"""user_id = f"cli-budget-user-{uuid.uuid4().hex[:8]}"user_email = f"{user_id}@example.com"