From 86312da3be488a56ad8597f76d82bfe4d1e9f8c8 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Sat, 1 Aug 2026 14:55:05 -0700 Subject: [PATCH] fix(ci): let the E2E proxy accept the mock testing params its suite sends Gating the mock testing request params behind general_settings.dangerously_allow_mock_testing_request_params (#35423) turned every fallback, retry and timeout drill in tests/test_fallbacks.py into a 400: the build_and_test job mounts proxy_server_config.yaml, which never opted in. Opt that config in. It is the config the CI proxy runs with, and the suite it serves exists to drive synthetic failures. Add a unit test that ties the two together: it scans the top-level tests/test_*.py files build_and_test globs for gated param names and fails if the config they run against has not opted in, so the next change to either side is caught in a fast lint-tier job rather than a Docker E2E. --- proxy_server_config.yaml | 1 + .../proxy/test_route_llm_request.py | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/proxy_server_config.yaml b/proxy_server_config.yaml index 1a51dd0d0a7..73990153227 100644 --- a/proxy_server_config.yaml +++ b/proxy_server_config.yaml @@ -227,6 +227,7 @@ general_settings: proxy_budget_rescheduler_max_time: 64 proxy_batch_write_at: 1 database_connection_pool_limit: 10 + dangerously_allow_mock_testing_request_params: true # background_health_checks: true # use_shared_health_check: true # needs a coordination Redis (below) # health_check_interval: 30 diff --git a/tests/test_litellm/proxy/test_route_llm_request.py b/tests/test_litellm/proxy/test_route_llm_request.py index e74693a4f6c..3ae0e1e7d18 100644 --- a/tests/test_litellm/proxy/test_route_llm_request.py +++ b/tests/test_litellm/proxy/test_route_llm_request.py @@ -488,6 +488,45 @@ def test_gated_mock_params_cover_mock_router_testing_params(): assert {"mock_testing_rate_limit_error", "mock_timeout", "mock_delay"} <= set(GATED_MOCK_PARAM_NAMES) +def test_e2e_proxy_config_opts_in_to_the_mock_params_its_suite_sends(): + """The ``build_and_test`` CI job runs the top-level ``tests/test_*.py`` suite + against a proxy mounted with ``proxy_server_config.yaml``. Several of those + tests drive fallback, retry and timeout paths by asking the proxy to + fabricate a failure, which the gate rejects with a 400 unless the config + opts in. Without the opt-in the positive cases fail outright and the + negative ones pass for the wrong reason, so the suite and the config it + runs against have to move together.""" + from pathlib import Path + + import yaml + + from litellm.proxy.route_llm_request import ( + GATED_MOCK_PARAM_NAMES, + MOCK_TESTING_CONFIG_KEY, + ) + + repo_root = Path(__file__).parents[3] + suite_sources = tuple( + (path, path.read_text(encoding="utf-8")) for path in sorted(repo_root.glob("tests/test_*.py")) + ) + senders = frozenset( + f"{path.name}:{param}" + for path, source in suite_sources + for param in GATED_MOCK_PARAM_NAMES + if f"{param}=" in source or f'"{param}"' in source + ) + assert senders, "expected the E2E suite to still exercise the gated mock testing params" + + config = yaml.safe_load((repo_root / "proxy_server_config.yaml").read_text(encoding="utf-8")) + general_settings = config.get("general_settings") or {} + + assert general_settings.get(MOCK_TESTING_CONFIG_KEY) is True, ( + f"proxy_server_config.yaml must set general_settings.{MOCK_TESTING_CONFIG_KEY}: true — " + f"the E2E suite sends gated mock testing params ({', '.join(sorted(senders))}) " + "and the proxy rejects them with a 400 otherwise" + ) + + @pytest.mark.parametrize( "mock_param", [