From 1a00dd4dbbc6f259181b0ee3d08d5aaaeb440bf9 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sun, 15 Mar 2026 21:36:56 -0700 Subject: [PATCH] Fix router test isolation for xdist and rebalance proxy unit tests Router tests: expand conftest save/restore to cover all globals mutated by router tests (default_fallbacks, tag_budget_config, request_timeout, enable_azure_ad_token_refresh, num_retries_per_request, model_cost, token_counter). These were leaking across xdist workers. Proxy tests: move test_proxy_utils.py (169 parametrized) and test_proxy_server.py (72 parametrized) from part2 to part1, balancing ~370 vs ~360 tests (was ~129 vs ~600). Co-Authored-By: Claude Opus 4.6 --- .circleci/config.yml | 7 +++---- tests/local_testing/conftest.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78a701319e..617a8cb3ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1008,12 +1008,11 @@ jobs: ./docker/entrypoint.sh set -e - run: - name: Run proxy unit tests (part 1 - auth checks only, key generation in separate job) + name: Run proxy unit tests (part 1 - auth checks + proxy_utils + proxy_server) command: | pwd ls - # Run auth tests with parallel execution (test_key_generate_prisma moved to separate job to avoid event loop issues) - python -m pytest tests/proxy_unit_tests/test_auth_checks.py tests/proxy_unit_tests/test_user_api_key_auth.py --junitxml=test-results/junit-part1.xml --durations=10 -n 8 --timeout=300 -v + python -m pytest tests/proxy_unit_tests/test_auth_checks.py tests/proxy_unit_tests/test_user_api_key_auth.py tests/proxy_unit_tests/test_proxy_utils.py tests/proxy_unit_tests/test_proxy_server.py --junitxml=test-results/junit-part1.xml --durations=10 -n 8 --timeout=300 -v no_output_timeout: 15m - store_test_results: path: test-results @@ -1109,7 +1108,7 @@ jobs: command: | pwd ls - python -m pytest tests/proxy_unit_tests --ignore=tests/proxy_unit_tests/test_key_generate_prisma.py --ignore=tests/proxy_unit_tests/test_auth_checks.py --ignore=tests/proxy_unit_tests/test_user_api_key_auth.py --junitxml=test-results/junit-part2.xml --durations=10 -n 8 --timeout=300 -v + python -m pytest tests/proxy_unit_tests --ignore=tests/proxy_unit_tests/test_key_generate_prisma.py --ignore=tests/proxy_unit_tests/test_auth_checks.py --ignore=tests/proxy_unit_tests/test_user_api_key_auth.py --ignore=tests/proxy_unit_tests/test_proxy_utils.py --ignore=tests/proxy_unit_tests/test_proxy_server.py --junitxml=test-results/junit-part2.xml --durations=10 -n 8 --timeout=300 -v no_output_timeout: 15m - store_test_results: path: test-results diff --git a/tests/local_testing/conftest.py b/tests/local_testing/conftest.py index 71cfec4157..b858154e2f 100644 --- a/tests/local_testing/conftest.py +++ b/tests/local_testing/conftest.py @@ -39,7 +39,18 @@ def isolate_litellm_state(): original_state[attr] = val.copy() if val else [] # Save other globals that tests commonly mutate - for attr in ("set_verbose", "cache", "num_retries"): + for attr in ( + "set_verbose", + "cache", + "num_retries", + "num_retries_per_request", + "request_timeout", + "default_fallbacks", + "enable_azure_ad_token_refresh", + "tag_budget_config", + "model_cost", + "token_counter", + ): if hasattr(litellm, attr): original_state[attr] = getattr(litellm, attr)