Skip to content

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]

fix(e2e): stop tests from breaking the shared proxy for every suite after them (#34664)

mubashir1osmani64fc19d61ac9
diff --git a/tests/e2e/a2a/test_a2a_agent_e2e.py b/tests/e2e/a2a/test_a2a_agent_e2e.py
index 802b01455b1..8b89ce91806 100644
--- a/tests/e2e/a2a/test_a2a_agent_e2e.py
+++ b/tests/e2e/a2a/test_a2a_agent_e2e.py
@@ -32,10 +32,17 @@ from e2e_config import unique_marker
from e2e_http import Result, UnknownApiError, unwrap
from lifecycle import ResourceManager
+# No api_key: litellm resolves ANTHROPIC_API_KEY from the proxy's own environment
+# for this provider, which is what the agent-owner flow relies on. Pinning
+# "os.environ/ANTHROPIC_API_KEY" here (#34512) was worse than redundant. The a2a
+# bridge forwards litellm_params to acompletion() without expanding "os.environ/"
+# indirection, so that literal string was sent upstream as x-api-key and every
+# message/send failed with `AnthropicException - invalid x-api-key`. Omitting the
+# key lets the normal provider resolution apply. Verified against a live proxy:
+# omitted -> 200, "os.environ/..." -> 500 invalid x-api-key, literal key -> 200.
BRIDGE = A2ABridgeParams(
custom_llm_provider="anthropic",
model="claude-haiku-4-5",
- api_key="os.environ/ANTHROPIC_API_KEY",
)
MOVEHOME_AGENT_CARD_URL = "https://movehome.org/.well-known/agent.json"
diff --git a/tests/e2e/batches/test_batches_e2e.py b/tests/e2e/batches/test_batches_e2e.py
index f9cd2a3f15f..5c25b7f2a93 100644
--- a/tests/e2e/batches/test_batches_e2e.py
+++ b/tests/e2e/batches/test_batches_e2e.py
@@ -524,6 +524,17 @@ class TestOpenAIFiles:
"llm.files.openai.list.nonstream.works",
exercised_on=["files"],
)
+ @pytest.mark.skip(
+ reason=(
+ "LIT-4820 (https://linear.app/litellm-ai/issue/LIT-4820): GET /v1/files omits "
+ "newly uploaded files. The upload succeeds and "
+ "GET /v1/files/{id} returns the file, but it never appears in the listing; the "
+ "returned set is stable with its newest entry ~10h old, on both the managed "
+ "(/v1/files?model=) and provider-scoped (/openai/v1/files) routes. Skipped rather "
+ "than weakened because the assertion below is the correct contract. Remove this "
+ "marker when LIT-4820 is fixed; do not relax the assertion to make it pass."
+ )
+ )
def test_uploaded_file_appears_in_list(
self, client: BatchClient, resources: ResourceManager, batch_deployments: None
) -> None:
diff --git a/tests/e2e/coverage_registry/mgmt.yaml b/tests/e2e/coverage_registry/mgmt.yaml
index da4652460f1..68c5ef6b31d 100644
--- a/tests/e2e/coverage_registry/mgmt.yaml
+++ b/tests/e2e/coverage_registry/mgmt.yaml
@@ -58,7 +58,7 @@
- {id: mgmt.budget.delete.persists, module: mgmt, tier: P1, surface: api, assertions: [persists], source: "budget_management_endpoints.py:280", rationale: "Clears limits"}
- {id: mgmt.budget.list.happy_path, module: mgmt, tier: P1, surface: api, assertions: [happy_path], source: "budget_management_endpoints.py:215", rationale: "Budget enumeration"}
- {id: mgmt.callback.list.happy_path, module: mgmt, tier: P2, surface: api, assertions: [happy_path], source: "callback_management_endpoints.py", rationale: "Callback config (smoke)"}
-- {id: mgmt.cache_settings.update.happy_path, module: mgmt, tier: P2, surface: api, assertions: [happy_path], source: "cache_settings_endpoints.py", rationale: "Cache config (smoke)"}
+- {id: mgmt.cache_settings.update.happy_path, module: mgmt, tier: P2, surface: api, assertions: [happy_path], source: "cache_settings_endpoints.py", rationale: "Cache config (smoke). Deliberately uncovered: the previous test read the live settings and wrote them back, which proves nothing (identical values in, so a no-op POST still passes) while being able to break the deployment. /cache/settings persists what it receives and that row outranks YAML cache_params, re-applied on a timer, so a write that omits ssl or redis_startup_nodes turns a TLS cluster into a plaintext standalone node and every later Redis call hangs. That took out 60 of 72 tests on 2026-07-25. GET cannot round-trip it either: it resolves the stored row overlaid with REDIS_* env and never reads YAML, so on a fresh deploy it cannot see YAML ssl to echo back. A safe test needs an isolated proxy, or LIT-4816 fixed so a partial write cannot downgrade transport. Do not re-add a read-then-write-back test against a shared proxy."}
- {id: mgmt.cost_tracking.estimate.happy_path, module: mgmt, tier: P2, surface: api, assertions: [happy_path], source: "cost_tracking_settings.py", rationale: "Cost estimate (smoke)"}
- {id: mgmt.router_settings.update.happy_path, module: mgmt, tier: P2, surface: api, assertions: [happy_path], source: "router_settings_endpoints.py", rationale: "Router config (smoke)"}
- {id: mgmt.jwt_key_mapping.new.happy_path, module: mgmt, tier: P2, surface: api, assertions: [happy_path], source: "jwt_key_mapping_endpoints.py", rationale: "JWT->key mapping (smoke)"}
diff --git a/tests/e2e/e2e_config.py b/tests/e2e/e2e_config.py
index feed680bd4a..e62b866f0a9 100644
--- a/tests/e2e/e2e_config.py
+++ b/tests/e2e/e2e_config.py
@@ -77,10 +77,16 @@ REQUEST_TIMEOUT = float(os.environ.get("E2E_REQUEST_TIMEOUT", "60"))
EXPECT_RUST = os.environ.get("E2E_EXPECT_RUST", "").strip().lower() in ("1", "true", "yes")
-LOAD_USERS = int(os.environ.get("E2E_LOAD_USERS", "750"))
-LOAD_SPAWN_RATE = float(os.environ.get("E2E_LOAD_SPAWN_RATE", "50"))
+# Deliberately modest concurrency. The suite shares its proxy with every other
+# suite in the run, and 750 users at spawn rate 50 saturated the request path hard
+# enough to distort latency-sensitive neighbours (and to spend real provider money
+# fast). The SLO is scaled with the user count to keep the same per-user throughput
+# expectation (~0.47 RPS/user), so this still catches a request-path regression
+# rather than becoming a formality. Raise all four via env for a real load run.
+LOAD_USERS = int(os.environ.get("E2E_LOAD_USERS", "200"))
+LOAD_SPAWN_RATE = float(os.environ.get("E2E_LOAD_SPAWN_RATE", "20"))
LOAD_DURATION_SECONDS = float(os.environ.get("E2E_LOAD_DURATION_SECONDS", "60"))
-LOAD_MIN_RPS = float(os.environ.get("E2E_LOAD_MIN_RPS", "355"))
+LOAD_MIN_RPS = float(os.environ.get("E2E_LOAD_MIN_RPS", "90"))
LOAD_MAX_FAILURE_RATIO = float(os.environ.get("E2E_LOAD_MAX_FAILURE_RATIO", "0.01"))
WEEKLY_ANOMALY_OPT_IN_ENV = "E2E_WEEKLY_ANOMALY"
diff --git a/tests/e2e/guardrails/guardrails_client.py b/tests/e2e/guardrails/guardrails_client.py
index 8fa5baee6e4..d56e4e9311a 100644
--- a/tests/e2e/guardrails/guardrails_client.py
+++ b/tests/e2e/guardrails/guardrails_client.py
@@ -140,7 +140,17 @@ class GuardrailsClient:
*,
identifier: str,
version: str,
+ default_on: bool = False,
) -> str:
+ """Register a Bedrock guardrail, opted out of `default_on` by default.
+
+ `default_on=True` applies the guardrail to every request the proxy serves,
+ not just this test's. When the upstream ApplyGuardrail call fails (a missing
+ bedrock:ApplyGuardrail permission answers 403), that failure is returned to
+ unrelated traffic as `403 Bedrock guardrail request failed`, so one guardrail
+ test takes out whatever else is running. Callers select the guardrail
+ per-request instead, which keeps the blast radius to the test that wants it.
+ """
return unwrap(
self.proxy.transport.post(
"/guardrails",
@@ -150,7 +160,7 @@ class GuardrailsClient:
guardrail_name=name,
litellm_params=BedrockGuardrailParamsBody(
mode="pre_call",
- default_on=True,
+ default_on=default_on,
guardrailIdentifier=identifier,
guardrailVersion=version,
),
diff --git a/tests/e2e/guardrails/test_bedrock_guardrail_e2e.py b/tests/e2e/guardrails/test_bedrock_guardrail_e2e.py
index e57605cc8f1..ba3c5071cbb 100644
--- a/tests/e2e/guardrails/test_bedrock_guardrail_e2e.py
+++ b/tests/e2e/guardrails/test_bedrock_guardrail_e2e.py
@@ -47,7 +47,10 @@ class TestBedrockGuardrail:
)
resources.defer(lambda: client.delete_guardrail(guardrail_id))
- result = client.chat(scoped_key, MODEL, BLOCKED_PROMPT)
+ # Selected per request rather than registered default_on, so an upstream
+ # ApplyGuardrail failure surfaces here instead of 403ing every other suite
+ # running against this proxy.
+ result = client.chat(scoped_key, MODEL, BLOCKED_PROMPT, guardrails=[name])
match result:
case UnknownApiError(status_code=status, body=body):
diff --git a/tests/e2e/llm_translation/passthrough_client.py b/tests/e2e/llm_translation/passthrough_client.py
index 7aa2eb793ad..3744f33e345 100644
--- a/tests/e2e/llm_translation/passthrough_client.py
+++ b/tests/e2e/llm_translation/passthrough_client.py
@@ -105,7 +105,12 @@ class AnthropicMessageBody(BaseModel):
class OpenAIChatBody(BaseModel):
model: str
messages: list[ChatMessage]
- max_tokens: int = 64
+ # Passthrough sends this body to OpenAI untranslated, so it has to satisfy
+ # OpenAI's current contract directly: newer models reject `max_tokens` with
+ # "Unsupported parameter: 'max_tokens' is not supported with this model. Use
+ # 'max_completion_tokens' instead." litellm's drop_params/translation does not
+ # apply on this route.
+ max_completion_tokens: int = 64
class VllmChatBody(BaseModel):
@@ -198,14 +203,14 @@ class PassthroughClient:
)
def openai_chat(
- self, key: str, model: str, text: str, *, max_tokens: int = 64
+ self, key: str, model: str, text: str, *, max_completion_tokens: int = 64
) -> StreamingResponse:
return self.proxy.transport.send(
"/openai/v1/chat/completions",
headers=self.proxy.transport.bearer(key),
json=OpenAIChatBody(
model=model,
- max_tokens=max_tokens,
+ max_completion_tokens=max_completion_tokens,
messages=[ChatMessage(role="user", content=text)],
),
)
diff --git a/tests/e2e/llm_translation/test_chat_completions_regression_e2e.py b/tests/e2e/llm_translation/test_chat_completions_regression_e2e.py
index 076ffdf158b..6a69384d31a 100644
--- a/tests/e2e/llm_translation/test_chat_completions_regression_e2e.py
+++ b/tests/e2e/llm_translation/test_chat_completions_regression_e2e.py
@@ -535,13 +535,25 @@ class TestOpenAIChatCompletions:
ChatBody(
model=model,
messages=[
+ # The prompt and effort have to make the model actually think,
+ # otherwise this asserts something the model is free not to do:
+ # at reasoning_effort="low" a one-step arithmetic question comes
+ # back with reasoning_tokens=0, which is correct behavior and not
+ # a reporting bug. Verified against the live model:
+ # low + "60 miles in 1.5 hours" -> reasoning_tokens=0,
+ # high + the prompt below -> reasoning_tokens=90.
+ # What is under test is that litellm surfaces the field, so the
+ # request has to be one where the field is populated.
ChatMessage(
role="user",
- content="A train travels 60 miles in 1.5 hours. What is its average speed in mph?",
+ content=(
+ "Prove that the sum of two odd integers is even, then find the "
+ "smallest prime p greater than 100 such that p+2 is also prime."
+ ),
)
],
- reasoning_effort="low",
- max_tokens=2048,
+ reasoning_effort="high",
+ max_tokens=3000,
),
)
)
diff --git a/tests/e2e/management/test_config_misc_endpoints_e2e.py b/tests/e2e/management/test_config_misc_endpoints_e2e.py
index 6c4de621271..195732c0201 100644
--- a/tests/e2e/management/test_config_misc_endpoints_e2e.py
+++ b/tests/e2e/management/test_config_misc_endpoints_e2e.py
@@ -3,9 +3,13 @@
One method per registry cell, each asserting the real contract against a live
proxy: read-only inventory routes return their documented shape, stateless
validators compute their verdict from the request, and the write routes persist
-so a read-back reflects the change. The two routes that mutate global proxy state
-(cache settings and router settings, both driven from the admin UI) are exercised
-with a benign, self-restoring change so a shared proxy is left as it was found.
+so a read-back reflects the change. Router settings, which mutate global proxy
+state, are exercised with a benign, self-restoring change so a shared proxy is left
+as it was found.
+
+Cache settings are deliberately not covered here; see the rationale on
+mgmt.cache_settings.update.happy_path in coverage_registry/mgmt.yaml before adding
+a test for that route.
"""
from __future__ import annotations
@@ -124,34 +128,6 @@ class ComplianceResponse(BaseModel):
checks: list[ComplianceCheck]
-# ---- cache settings --------------------------------------------------------
-
-
-class CacheSettingsValue(BaseModel):
- type: str
- host: str = ""
- port: str = ""
-
-
-class CacheSettingsUpdateBody(BaseModel):
- cache_settings: CacheSettingsValue
-
-
-class CacheCurrentValues(BaseModel):
- type: str | None = None
- host: str | None = None
- port: str | None = None
-
-
-class CacheGetResponse(BaseModel):
- current_values: CacheCurrentValues
-
-
-class CacheUpdateResponse(BaseModel):
- status: str
- settings: CacheSettingsValue
-
-
# ---- fallback management ---------------------------------------------------
@@ -369,70 +345,6 @@ class TestComplianceRoutes:
)
-class TestCacheSettings:
- @pytest.mark.covers("mgmt.cache_settings.update.happy_path")
- def test_update_persists_cache_backend_to_get(
- self, client: ManagementClient, resources: ResourceManager
- ) -> None:
- """Exercise the update route without changing global state: capture the live
- cache backend and write exactly that back, so the config the proxy ends on is
- byte-for-byte the one it started with. A teardown restore of the same captured
- settings is the safety net if the body fails partway. The update route is only
- meaningful against a configured cache, so an unconfigured proxy fails loudly
- here rather than being silently switched to redis."""
- before = self._read_settings(client)
- assert before.type is not None, (
- "GET /cache/settings reported no cache type; refusing to invent one and mutate the shared proxy"
- )
- captured = CacheSettingsValue(type=before.type, host=before.host or "", port=before.port or "")
- resources.defer(lambda: self._write_settings(client, captured))
-
- updated = unwrap(
- client.proxy.transport.post(
- "/cache/settings",
- headers=client.proxy.transport.master,
- json=CacheSettingsUpdateBody(cache_settings=captured),
- response_type=CacheUpdateResponse,
- )
- )
- assert updated.status == "success", f"/cache/settings update status {updated.status!r}, expected 'success'"
- assert updated.settings.type == captured.type, (
- f"/cache/settings echoed type {updated.settings.type!r}, wrote {captured.type!r}"
- )
-
- def reflected() -> CacheCurrentValues | None:
- current = self._read_settings(client)
- return current if current.type == captured.type else None
-
- after = _poll(client, reflected, f"/cache/settings never reported type {captured.type!r} after the update")
- assert after.host == captured.host and after.port == captured.port, (
- f"/cache/settings persisted host/port {after.host!r}/{after.port!r}, "
- f"wrote {captured.host!r}/{captured.port!r}"
- )
-
- @staticmethod
- def _read_settings(client: ManagementClient) -> CacheCurrentValues:
- return unwrap(
- client.proxy.transport.get(
- "/cache/settings",
- headers=client.proxy.transport.master,
- params=NoBody(),
- response_type=CacheGetResponse,
- )
- ).current_values
-
- @staticmethod
- def _write_settings(client: ManagementClient, settings: CacheSettingsValue) -> None:
- _ = unwrap(
- client.proxy.transport.post(
- "/cache/settings",
- headers=client.proxy.transport.master,
- json=CacheSettingsUpdateBody(cache_settings=settings),
- response_type=CacheUpdateResponse,
- )
- )
-
-
class TestFallbackManagement:
@pytest.mark.covers("mgmt.fallback_management.update.happy_path")
def test_create_persists_and_is_read_back(self, client: ManagementClient, resources: ResourceManager) -> None: