litellm/tests/test_litellm/proxy
Ishaan Jaff 3e67cb5287
fix: resolve flaky test failures in health, spend logs, and CLI tests (#21769)
* fix: reset db_health_cache in source module to prevent stale cache hits

The test was reassigning db_health_cache via `global` in the test module,
which doesn't affect the _health_endpoints module's variable. When a prior
test set the cache to "connected" within 2 minutes, _db_health_readiness_check
returned early without calling health_check(), causing assert_called_once to fail.

Also use PrismaError with a connection message so it's properly recognized
as a connection error by PrismaDBExceptionHandler.is_database_connection_error.

* fix: replace asyncio.sleep with polling loop in spend logs tests

The GLOBAL_LOGGING_WORKER processes callbacks via an async queue, so
asyncio.sleep(1) is a race condition - under CI load the worker may not
have processed the queued task within 1 second. Replace with a polling
helper that waits up to 10 seconds for the mock to be called.

Also add metadata.attempted_retries and metadata.max_retries to
ignored_keys since these are new fields.

* fix: isolate test_skip_server_startup from CI environment

Remove mix_stderr=False (unsupported in some Click versions). Strip
DATABASE_URL/DIRECT_URL from environment during the test to prevent
real prisma operations when these are set in CI.
2026-02-21 10:02:24 -08:00
..
_experimental/mcp_server Add test for base url extraction and migration 2026-02-20 13:47:44 +05:30
agent_endpoints tests 2026-02-13 22:01:28 -08:00
anthropic_endpoints
auth Merge pull request #21009 from BerriAI/litellm_docker-count-no-req 2026-02-21 20:57:28 +05:30
client
common_utils fix(proxy): fix master key rotation Prisma validation errors (#21330) 2026-02-16 15:13:05 -08:00
db fix(proxy): self-heal Prisma connection for auth and runtime (#21706) 2026-02-20 18:11:36 -08:00
discovery_endpoints fix(azure): preserve content_policy_violation error details from Azure OpenAI (#20883) 2026-02-10 22:47:03 -08:00
experimental/mcp_server
google_endpoints
guardrails Guardrail - competitor name blocker (#21719) 2026-02-20 18:52:40 -08:00
health_endpoints fix: resolve flaky test failures in health, spend logs, and CLI tests (#21769) 2026-02-21 10:02:24 -08:00
hooks [Fix] Fix flaky tests: spend logs metadata keys, proxy CLI isolation, Redis TTL uniqueness 2026-02-20 17:26:44 -08:00
image_endpoints fixing core proxy tests 2026-02-12 17:54:32 -08:00
management_endpoints feat: expose user_email in organization members response 2026-02-20 21:41:53 -08:00
management_helpers
middleware fix: improve streaming proxy throughput by fixing middleware and logging bottlenecks (#21501) 2026-02-18 16:16:49 -08:00
openai_files_endpoint
pass_through_endpoints Add test got method speicifc routing 2026-02-19 11:58:48 +05:30
policy_engine [Guardrails] Add guardrail pipeline support for conditional sequential execution (#21177) 2026-02-13 19:49:12 -08:00
prompts
public_endpoints
rag_endpoints tests and route permissions (#21508) 2026-02-18 16:58:38 -08:00
response_api_endpoints
spend_tracking fix: resolve flaky test failures in health, spend logs, and CLI tests (#21769) 2026-02-21 10:02:24 -08:00
test_configs
ui_crud_endpoints
vector_store_endpoints
__init__.py
conftest.py
test_api_key_masking_in_errors.py fix: mask API keys in error responses for invalid/malformed keys (#20289) 2026-02-12 19:58:05 +05:30
test_batch_metadata_none_fix.py
test_caching_routes.py
test_chat_completion_metadata.py
test_common_request_processing.py
test_custom_proxy.py
test_empty_model_list.py
test_enforce_user_param.py
test_fallback_management_endpoints.py
test_fastapi_offline_routes.py
test_health_check_functions.py
test_litellm_pre_call_utils.py fix(tests): wrap callbacks cleanup in try/finally and resolve merge conflict 2026-02-18 18:50:17 -03:00
test_model_id_header_propagation.py
test_proxy_cli.py fix: resolve flaky test failures in health, spend logs, and CLI tests (#21769) 2026-02-21 10:02:24 -08:00
test_proxy_server.py address greptile review feedback (greploop iteration 2) 2026-02-19 20:25:00 -08:00
test_proxy_types.py
test_proxy_utils.py
test_pyroscope.py Fix CI/CD pyroscope test failure (#21219) 2026-02-14 12:07:20 -08:00
test_response_model_sanitization.py
test_route_a2a_models.py
test_route_llm_request.py
test_shared_health_check.py
test_spend_log_cleanup.py
test_swagger_chat_completions.py
test_team_member_update.py