mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
test(mcp): isolate MCP discovery tests from a leaked SERVER_ROOT_PATH
tests/test_litellm/proxy/test_custom_proxy.py sets SERVER_ROOT_PATH at import time (its app mounts under a custom path) and never restores it, so in a shared shard the value leaks into the process. The discovery routes and the 401 challenges now read SERVER_ROOT_PATH to path-insert it where they previously ignored it, so a leaked value rewrites every resource_metadata URL and the exact-URL assertions in the delegate, pass-through, and aggregate challenge tests fail depending on shard order An autouse fixture clears SERVER_ROOT_PATH for the MCP discovery tests so they deterministically exercise the default root-mounted deployment; the tests that assert a sub-path deployment set the value explicitly within their own body. No assertion changed; the leak was invisible before only because the code ignored the variable
This commit is contained in:
parent
e7e5265f65
commit
90195afa06
1 changed files with 22 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _hermetic_server_root_path():
|
||||
"""Isolate MCP discovery tests from a leaked ``SERVER_ROOT_PATH``.
|
||||
|
||||
``tests/test_litellm/proxy/test_custom_proxy.py`` sets ``SERVER_ROOT_PATH`` at import time
|
||||
(its app mounts under a custom path) and never restores it, so in a shared shard the value
|
||||
leaks into this process. The discovery routes and the 401 challenges read it, so a leaked
|
||||
value would silently rewrite every ``resource_metadata`` URL and make these tests depend on
|
||||
shard ordering. Clearing it here pins the default (root-mounted) deployment; a test that
|
||||
exercises a sub-path deployment sets the value explicitly within its own body.
|
||||
"""
|
||||
saved = os.environ.pop("SERVER_ROOT_PATH", None)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if saved is not None:
|
||||
os.environ["SERVER_ROOT_PATH"] = saved
|
||||
Loading…
Add table
Reference in a new issue