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", [