litellm/tests/unit/caching
yuneng-jiang ff281dbd14
test(unit): make 21 flaky unit tests deterministic (#54785)
* test(unit): make 20 flaky unit tests deterministic

These tests failed on main and on PR reruns over the last two weeks without a code change. Each fix keeps
what the test proves and only removes the timing, clock or shared-state dependency.

Router usage tests now read usage with usage_since, because the Rust core stamps usage with its own system
clock, so a read in the next minute missed the write. The header parity test checks the remaining count
against the minute the header was read in. The websocket admission test pins the usage-based-routing-v2
clock, and the deployment rpm test freezes time with time-machine because its old patch never reached the
clock bound as a default argument.

The bedrock realtime test stubs AWS signing like its sibling. The swagger test stubs FastAPI's schema
builder. The prisma span scan skips files that cannot hold a call site. The http, live session and custom
code bounds are tied to the timeout constants they guard.

The vertex test reads only LiteLLM log records, the agentops test reads only its own route's requests, the
redis test picks a port whose shared breaker is closed, and the SAML test freezes the clock and now asserts
the exact TTL.

* test(bedrock): stub the boto3 session instead of our own signing helper

Greptile flagged that the realtime guardrail fixture replaced run_aws_signing, which tests/unit/AGENTS.md
forbids. The CI timeout was resolve_credentials building a real boto3.Session on the signing pool, so the
fixture now swaps boto3.Session for a static-key session and the real signing path runs.

* test(s3): keep the short upload deadline for the timeout case only

The dropped-connection case also ran under the 0.3s per-attempt deadline. When the fake bucket's handler
thread answered one attempt late on a loaded runner, that attempt was retried as a timeout instead of a
dropped connection, so the test counted 5 PUTs instead of 6. Only the timeout case needs the short deadline.
2026-11-26 20:48:13 -08:00
..
__init__.py
_event_loop_reuse.py fix(caching): key cached async clients by a per-loop token instead of id(loop) (#48877) 2026-10-29 13:14:48 -07:00
redis_batch_double.py refactor(redis): move per-request miss, settlement and shutdown-drain tracking from Python into Rust (#51384) 2026-11-20 17:57:37 +09:00
test_azure_blob_cache.py feat(cache): apply scoped settings to exact-match response caching (#54041) 2026-11-24 11:37:16 -08:00
test_cache_preset_key.py
test_caching.py fix(hosted_vllm): keep vLLM's prompt_token_ids on the first streamed chat chunk (#51087) 2026-11-25 19:54:45 -08:00
test_caching_handler.py fix(embeddings): send request-shaped extra_body fields at the provider's documented path (#54273) 2026-11-25 13:29:52 -08:00
test_check_and_fix_namespace_none_guard.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_dual_cache.py perf(caching): format dual cache debug logs lazily (#51902) 2026-11-15 06:50:04 +00:00
test_embedding_router.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_evicted_client_closer.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_gcs_cache.py test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
test_in_memory_cache.py fix(cache): honor request TTL when refreshing in-memory responses (#54270) 2026-11-24 14:14:49 -08:00
test_llm_caching_handler.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_llm_client_cache_e2e.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_qdrant_semantic_cache.py feat(caching): configure semantic cache params per key, user and team (#53905) 2026-11-23 13:55:45 -08:00
test_redis_batch.py refactor(redis): move per-request miss, settlement and shutdown-drain tracking from Python into Rust (#51384) 2026-11-20 17:57:37 +09:00
test_redis_cache.py test(unit): make 21 flaky unit tests deterministic (#54785) 2026-11-26 20:48:13 -08:00
test_redis_cluster_cache.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_redis_cluster_node_isolation.py test: move tests/test_litellm core utils, routing, responses, caching and rust_bridge into tests/unit (#43199) 2026-09-25 17:10:13 -07:00
test_redis_connection_pool.py fix(redis): reuse the async connection pool across client-cache rotations (#34871) 2026-11-23 11:29:37 -08:00
test_redis_semantic_cache.py fix(caching): upgrade redisvl to 0.26.0 so the redis-semantic cache works with restricted Redis users (#54410) 2026-11-25 17:27:11 +00:00
test_request_redis_batch_post_call.py refactor(redis): move per-request miss, settlement and shutdown-drain tracking from Python into Rust (#51384) 2026-11-20 17:57:37 +09:00
test_request_redis_batch_pre_call.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_responses_stream_cache_keys.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_s3_cache.py fix(cache): honor request TTL when refreshing in-memory responses (#54270) 2026-11-24 14:14:49 -08:00
test_unit_test_caching.py fix(caching): read the cache key's model group from the router's metadata for the call (#48917) 2026-10-29 05:35:23 -07:00
test_valkey_semantic_cache.py feat(caching): configure semantic cache params per key, user and team (#53905) 2026-11-23 13:55:45 -08:00