litellm/tests/unit/proxy/db
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
..
db_transaction_queue fix(proxy): avoid blocking writes when attaching spend log partitions (#53858) 2026-11-23 11:19:33 -08:00
mcp_server
__init__.py
conftest.py
fake_prisma_engine.py fix(proxy): cancel the Admin UI's raw spend-log reads in Postgres after 30s (#49965) 2026-11-03 16:07:00 -08:00
test_autorouter_session_rollup.py fix(proxy): retain unwritten rollups after database disconnects (#51706) 2026-11-13 13:36:12 -08:00
test_budget_window_spend_writer.py fix(proxy): preserve budget window edits during resets (#53064) 2026-11-20 10:50:27 -08:00
test_check_migration.py fix(proxy): point the startup schema drift check at the packaged schema.prisma (#52435) 2026-11-19 17:49:06 -08:00
test_connection_budget.py feat(spend-logs): rust spend log callback (#52182) 2026-11-20 16:31:04 -08:00
test_create_views.py
test_daily_spend_bulk_upsert.py feat(proxy): add app groups with shared budgets and usage (#53232) 2026-11-21 12:50:58 -08:00
test_db_lookup_gate.py test: make three flaky unit tests deterministic (#50114) 2026-11-04 14:38:44 -08:00
test_db_span.py
test_db_spend_update_writer.py fix(proxy): stop requeueing rejected tool discovery batches to Redis (#53886) 2026-11-23 11:57:09 -08:00
test_db_url_settings.py feat(db): add an optional native reader pool with explicit routing (#49804) 2026-11-14 15:28:10 -08:00
test_exception_handler.py fix(proxy): retain unwritten rollups after database disconnects (#51706) 2026-11-13 13:36:12 -08:00
test_exception_handler_reconnect_retry.py
test_gateway_request_tracking.py
test_health_check_latest.py
test_log_db_metrics.py
test_log_db_metrics_service_spans.py test: deflake proxy metrics and shutdown drain (#51078) 2026-11-10 21:05:41 -08:00
test_master_key_migration.py fix(proxy): rotate all database secrets with the master key (#52998) 2026-11-20 10:02:59 -08:00
test_model_access_group_spend.py feat(proxy): enforce customer org, team and member budgets and limits on the request path (#51489) 2026-11-12 20:43:44 -08:00
test_model_insights_tasks.py
test_model_usage_rollup.py feat(alerts): detect daily changes in recorded usage (#50666) 2026-11-11 18:23:02 -08:00
test_native_database.py feat(auth): read virtual keys, jwt key mappings and model access groups through rust repositories (#52173) 2026-11-18 03:53:37 +00:00
test_object_permission_repository.py
test_pgbouncer.py test(unit): keep unix socket paths in unit tests under the macOS AF_UNIX limit (#45040) 2026-10-28 20:23:22 -07:00
test_prisma_client.py feat(proxy): replace the pre-migration row check with a rolled-back dry run of the pending migrations (#48961) 2026-10-29 09:39:26 -07:00
test_prisma_engine.py fix(proxy): start and serve the proxy with a database on Python 3.10 and prisma 0.13+ (#54416) 2026-11-26 00:09:17 +00:00
test_prisma_planned_engine_restart.py fix(proxy): start and serve the proxy with a database on Python 3.10 and prisma 0.13+ (#54416) 2026-11-26 00:09:17 +00:00
test_prisma_query_span.py test(unit): make 21 flaky unit tests deterministic (#54785) 2026-11-26 20:48:13 -08:00
test_prisma_self_heal.py fix(proxy): recover from a read replica reconnect that times out (#52592) 2026-11-18 12:03:24 -08:00
test_proxy_worker_heartbeat.py
test_query_engine_reaper.py
test_rds_iam_token_expiry.py
test_replica_identity.py
test_request_error_tracking.py
test_routing_prisma_wrapper.py fix(proxy): recover from a read replica reconnect that times out (#52592) 2026-11-18 12:03:24 -08:00
test_rust_spend_log_writer.py feat(spend-logs): rust spend log ledger writer (#52163) 2026-11-20 16:31:04 -08:00
test_scheduled_job_runs.py feat(proxy): run spend log cleanup from a DB-backed scheduled job table (#50131) 2026-11-11 18:22:02 -08:00
test_shadow_eval_funnel.py feat(shadow-eval): skip redundant reverse evaluations on opt-in (#52192) 2026-11-16 21:38:00 -08:00
test_spend_counter_reseed.py feat(proxy): support budget_limits windows on internal users (#51763) 2026-11-14 07:44:35 -05:00
test_spend_log_batching.py
test_spend_log_tool_index.py fix(proxy): stop requeueing rejected tool discovery batches to Redis (#53886) 2026-11-23 11:57:09 -08:00
test_token_auth.py
test_tool_registry_writer.py fix(proxy): stop requeueing rejected tool discovery batches to Redis (#53886) 2026-11-23 11:57:09 -08:00
test_tool_table_bulk_upsert.py
test_update_daily_tag_spend.py