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(integration): drop inherited provider API keys from the integration runner env (#46733)
devin-ai-integration[bot]777478425e81
diff --git a/tests/integration/README.md b/tests/integration/README.mdindex 0f1da7b3d97..478ad1cd787 100644--- a/tests/integration/README.md+++ b/tests/integration/README.md@@ -24,7 +24,7 @@ A future selector must explicitly skip a group when no candidates apply; omittinReuse the existing canned provider handlers through `_support/upstream.py`. It rejects internal request fields and exposes actual received requests for independent assertions. Register every created resource for cleanup immediately, keep expected values independent of production calculations, and assert readback plus the runtime effect of a change-Owned proxies disable `.env` loading by default. A contract testing dotenv behavior can explicitly set `PYTHON_DOTENV_DISABLED=0` in its owned environment. An explicit scratch writer database drops an inherited reader with a different database name; pass both database URLs when the contract needs a paired reader. Database relays close listeners, active connections and their event loops on teardown. Upstream startup failures reap the child process before returning the failure. Custom subprocesses, direct SQL and background tasks still need an explicit owner in the test+Owned proxies disable `.env` loading by default. A contract testing dotenv behavior can explicitly set `PYTHON_DOTENV_DISABLED=0` in its owned environment. The runner drops inherited `*_API_KEY` variables, so a contract that needs one sets a synthetic value in its owned environment. An explicit scratch writer database drops an inherited reader with a different database name; pass both database URLs when the contract needs a paired reader. Database relays close listeners, active connections and their event loops on teardown. Upstream startup failures reap the child process before returning the failure. Custom subprocesses, direct SQL and background tasks still need an explicit owner in the testOwned proxy workers configure a 32-thread executor before application startup, preserving additional worker startup hooks. Held synchronous provider calls must not consume a CPU-dependent executor limit before the rest of a fault burst can start. The proxy entrypoint imports LiteLLM inside `main`, so spawned workers begin supervision before importing the application. Worker healthchecks have a five-second deadline by default, so uvicorn kills a worker that stays paused longer than that. Tests never signal proxy processes themselves. `OwnedProxy.kill_worker` SIGKILLs a worker and returns once its replacement answers readiness with its own pid, `replacing_worker` does the same for a kill that has to land mid-burst, and `suspended` pauses a worker or the supervisor, which only works on a proxy launched with `healthcheck=WorkerHealthcheck.LENIENT`. Helper processes that are not the proxy stop through `stop_child`, `stop_processes` and `stop_process_group` and pause through `paused`. `scripts/check_test_quality.py` rule TQ010 rejects a raw `os.kill`, SIGKILL / SIGSTOP / SIGCONT, `.kill()`, `.terminate()`, `.suspend()` or `.send_signal()` anywhere under `tests/integration` outside `_support`, and TQ011 rejects an assertion that caps an elapsed time with a fixed number. Bound timings with `_support/timing.py` instead, relative to a measured control or to the injected delay. `run.py` measures how long this box takes to import the proxy application before it starts pytest, records it in `boot-calibration.json` beside the results and exports it as `INTEGRATION_IMPORT_SECONDS`. Readiness deadlines, graceful stops and the default per-test timeout are multiples of that measurement (`_support/budget.py`), so a slower box gets longer budgets and a two-worker proxy gets twice the readiness deadline of a one-worker one. Readiness requires responsive worker identities that are still alive and a positively identified owned listener. Unreadable socket records cannot establish ownership. Crash tests own their client tasks with `TaskGroup`, release held peers in `finally` and verify that the intended worker dies. A test requiring traffic on both workers prepares that traffic explicitly instead of assuming OS load balancing, for example by sending each half while the other worker is suspendeddiff --git a/tests/integration/compatibility/test_missing_body_param_status.py b/tests/integration/compatibility/test_missing_body_param_status.pyindex a452110f138..32338940931 100644--- a/tests/integration/compatibility/test_missing_body_param_status.py+++ b/tests/integration/compatibility/test_missing_body_param_status.py@@ -2074,8 +2074,8 @@ def test_documented_json_video_edit_routes_and_decodes_the_reference(gateway: Gadef test_multipart_bracketed_video_reference_reaches_upstream_as_a_decoded_id(gateway: Gateway) -> None:pytest.skip(- "BUG: multipart video[id]=<encoded id> to /v1/videos/edits and /v1/videos/extensions returns 404 and "- "never reaches the provider because the handler only reads a top-level video field"+ "BUG: multipart video[id]=<encoded id> to /v1/videos/edits and /v1/videos/extensions is never decoded, "+ "so the request skips the encoded deployment and goes to the default OpenAI api_base")seen: Final[list[Request]] = []with wire_server(_video_upstream(seen)) as wire, gateway.scenario() as scenario:diff --git a/tests/integration/database/test_harness_lifecycle.py b/tests/integration/database/test_harness_lifecycle.pyindex 0d604e03f03..032e00ba854 100644--- a/tests/integration/database/test_harness_lifecycle.py+++ b/tests/integration/database/test_harness_lifecycle.py@@ -44,6 +44,7 @@ from tests.integration._support.database_relay import (from tests.integration._support.runtime import configure_executorfrom tests.integration._support.sharding import ShardExecution, shard_errorsfrom tests.integration._support.wire import Reply, wire_server+from tests.integration.run import _without_provider_api_keysclass ExitRecord(TypedDict):@@ -88,6 +89,22 @@ def _nested_pytest_environment(environment: Mapping[str, str]) -> dict[str, str]return {name: value for name, value in environment.items() if name not in inherited_run_settings}+def test_runner_environment_drops_inherited_provider_api_keys() -> None:+ inherited: Final = {+ "OPENAI_API_KEY": "ambient-openai",+ "GEMINI_API_KEY": "ambient-gemini",+ "OTHER_API_KEY": "ambient-other",+ "LITELLM_MASTER_KEY": "sk-integration-master",+ "OPENAI_BASE_URL": "http://127.0.0.1:8190",+ }+ filtered: Final = _without_provider_api_keys(inherited)+ assert filtered == {+ "LITELLM_MASTER_KEY": "sk-integration-master",+ "OPENAI_BASE_URL": "http://127.0.0.1:8190",+ }+ assert inherited["OPENAI_API_KEY"] == "ambient-openai"++def test_owned_readiness_rejects_a_healthy_listener_from_another_process(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:diff --git a/tests/integration/run.py b/tests/integration/run.pyindex 99518e69d1f..d6ddd9d5e89 100644--- a/tests/integration/run.py+++ b/tests/integration/run.py@@ -66,6 +66,10 @@ def uncollected(nodes: tuple[str, ...], collected: frozenset[str]) -> tuple[str,return tuple(node for node in nodes if file_of(node) not in collected_files)+def _without_provider_api_keys(environment: Mapping[str, str]) -> dict[str, str]:+ return {name: value for name, value in environment.items() if not name.endswith("_API_KEY")}++def worker_settings(group: str, workers: int) -> Mapping[str, str]:if workers < 2:return MappingProxyType({})@@ -119,7 +123,7 @@ def main() -> int:output: Final = options.results.resolve()output.mkdir(parents=True, exist_ok=True)environment: Final = {- **os.environ,+ **_without_provider_api_keys(os.environ),"PYTHONPATH": os.pathsep.join((str(root), str(root / "tests"), str(root / "tests/e2e"))),"INTEGRATION_RESULTS_DIR": str(output),"LITELLM_LOCAL_MODEL_COST_MAP": "True",