[Fix] Test isolation for agent health checks and documentation test path resolution

Fix agent health check tests failing with 500 errors in parallel CI by
mocking prisma_client to None. Fix documentation validation tests using
CWD-relative paths that break depending on the working directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yuneng Jiang 2026-03-28 11:00:22 -07:00
parent 428d837704
commit 7100ed5d0a
No known key found for this signature in database
7 changed files with 48 additions and 17 deletions

View file

@ -0,0 +1,20 @@
name: "Unit Tests: Documentation Validation"
on:
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
documentation:
uses: ./.github/workflows/_test-unit-base.yml
with:
test-path: "tests/documentation_tests"
workers: 2
reruns: 1

View file

@ -32,10 +32,12 @@ error_names = {
# Parse the documentation to extract documented keys
# repo_base = "./"
repo_base = "../../"
_test_dir = os.path.dirname(os.path.abspath(__file__))
repo_base = os.path.abspath(os.path.join(_test_dir, "..", ".."))
print(os.listdir(repo_base))
docs_path = f"{repo_base}/docs/my-website/docs/exception_mapping.md" # Path to the documentation
docs_path = os.path.join(
repo_base, "docs", "my-website", "docs", "exception_mapping.md"
)
documented_keys = set()
try:
with open(docs_path, "r", encoding="utf-8") as docs_file:

View file

@ -2,7 +2,9 @@ import os
import re
# Define the base directory for the litellm repository and documentation path
repo_base = "./litellm" # Change this to your actual path
_test_dir = os.path.dirname(os.path.abspath(__file__))
_repo_root = os.path.abspath(os.path.join(_test_dir, "..", ".."))
repo_base = os.path.join(_repo_root, "litellm")
# Regular expressions to capture the keys used in general_settings.get() and general_settings[]
@ -32,10 +34,9 @@ for root, dirs, files in os.walk(repo_base):
general_settings_keys.update(bracket_matches)
# Parse the documentation to extract documented keys
repo_base = "./"
print(os.listdir(repo_base))
docs_path = (
"./docs/my-website/docs/proxy/config_settings.md" # Path to the documentation
print(os.listdir(_repo_root))
docs_path = os.path.join(
_repo_root, "docs", "my-website", "docs", "proxy", "config_settings.md"
)
documented_keys = set()
try:

View file

@ -7,7 +7,9 @@ import re
from litellm.types.utils import LlmProviders
# Define paths
readme_path = "./README.md"
_test_dir = os.path.dirname(os.path.abspath(__file__))
_repo_root = os.path.abspath(os.path.join(_test_dir, "..", ".."))
readme_path = os.path.join(_repo_root, "README.md")
# Providers that shouldn't be required in README
# (specialized tools, observability, database providers that aren't LLM providers)

View file

@ -37,14 +37,12 @@ print(router_init_params)
router_init_params.remove("model_list")
# Parse the documentation to extract documented keys
repo_base = "./"
print(os.listdir(repo_base))
docs_path = (
"./docs/my-website/docs/proxy/config_settings.md" # Path to the documentation
_test_dir = os.path.dirname(os.path.abspath(__file__))
_repo_root = os.path.abspath(os.path.join(_test_dir, "..", ".."))
print(os.listdir(_repo_root))
docs_path = os.path.join(
_repo_root, "docs", "my-website", "docs", "proxy", "config_settings.md"
)
# docs_path = (
# "../../docs/my-website/docs/proxy/config_settings.md" # Path to the documentation
# )
documented_keys = set()
try:
with open(docs_path, "r", encoding="utf-8") as docs_file:

View file

@ -38,7 +38,11 @@ def test_standard_logging_payload_documentation():
print(_field)
# Read the documentation
docs_path = "../../docs/my-website/docs/proxy/logging_spec.md"
_test_dir = os.path.dirname(os.path.abspath(__file__))
_repo_root = os.path.abspath(os.path.join(_test_dir, "..", ".."))
docs_path = os.path.join(
_repo_root, "docs", "my-website", "docs", "proxy", "logging_spec.md"
)
try:
with open(docs_path, "r", encoding="utf-8") as docs_file:

View file

@ -454,6 +454,10 @@ class TestAgentHealthCheck:
self.admin_client = _make_app_with_role(LitellmUserRoles.PROXY_ADMIN)
self.mock_registry = MagicMock()
monkeypatch.setattr(ar_mod, "global_agent_registry", self.mock_registry)
# Ensure prisma_client is None so the endpoint skips DB queries.
# In CI with parallel workers, a MagicMock can leak from other test
# scopes, causing "object MagicMock can't be used in 'await'" errors.
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", None)
def _make_agent(self, agent_id: str, url: str | None = None) -> AgentResponse:
card = _sample_agent_card_params()