litellm/tests/unit/test_router
yujonglee 46b5e0e4f2
refactor(rust): log from the core crates with tracing instead of host calls (#54788)
* refactor(rust): log from the core crates with tracing instead of host calls

router-core asked its host to write two model info log lines through an
awaited lookup, and the model capacity engine asked its host for every
warning and error line plus a fixed "unlicensed priority" line. A log line
is not something only the host can answer, so both crates now emit these
lines with tracing and the three host surfaces are gone from the traits,
from the native and Python hosts and from the Python answering code.

The Python proxy still gets the same lines at the same level on the same
logger. The bridge already delivers tracing events to Python logging, so
its target table now sends the capacity crate to "LiteLLM Proxy" and
router-core's model info module to "LiteLLM Router", and a model info
query runs under the calling request's logger so a level change is seen
at once.

A line logged on a runtime task is queued and handed to Python from the
blocking pool, so it can land after the call that logged it returns. The
bridge gains native_log_lines_delivered(), an awaitable that resolves once
the queued lines are delivered, and the capacity tests await it before
reading each step's lines.

* refactor(rust): name the log delivery wait rust_log_lines_delivered

The Rust workspace says "Rust", not "Native", for something written in Rust.

* fix(proxy): deliver queued Rust log lines before the proxy shuts down

A log line a Rust runtime task queued could be lost when the proxy stopped
before the queue was drained. Shutdown now waits for the queue, after the
steps that can still log.

The queue also reported its dropped-line count only when a later batch
arrived, so a drop during the last batch was never reported. It is now
reported once the queue is empty, and a delivery wait ends only after that
report.

* fix(proxy): bound the shutdown wait for queued Rust log lines

The wait had no timeout, so a log handler that stalled would hold worker
shutdown until an outside kill. It now gives up after five seconds or when
the graceful shutdown window runs out, whichever comes first. A timeout is
not logged, because a stalled handler holds its lock and the warning would
block on it too.
2026-11-27 14:53:04 +09:00
..
core test(unit): make 21 flaky unit tests deterministic (#54785) 2026-11-26 20:48:13 -08:00
__init__.py test: add __init__.py to every tests/unit directory phase 16 touches 2026-09-20 11:52:38 +00:00
test_enforce_model_rate_limits.py fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
test_io_token_rate_limits.py test(router): pin the clock in the mixed itpm and rpm limit test so a minute rollover cannot move its rpm counter (#54554) 2026-11-25 23:42:12 +00:00
test_router.py refactor(rust): log from the core crates with tracing instead of host calls (#54788) 2026-11-27 14:53:04 +09:00
test_router_callback_hook_sequence.py test: replace 61 live logging and otel tests with offline unit and integration coverage (#45362) 2026-10-08 15:55:57 -07:00
test_router_endpoints.py fix(proxy): resolve admin oidc api_key references on batch cancel, fine-tuning listing, OCR, /v1/messages and cache prediction (#53678) 2026-11-23 10:11:10 -08:00
test_router_entry_points.py feat(proxy): mixed Codex model picker and LiteLLM routing on native codex routes (#49408) 2026-11-06 11:14:47 -08:00
test_router_facade.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_router_fallbacks.py fix(router): preserve destination bearer credentials on Anthropic fallbacks (#54271) 2026-11-24 17:12:02 -08:00
test_router_fuzz_regressions_rust_only.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_router_get_deployments.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_router_helper_utils.py fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
test_router_host.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_router_max_parallel_requests.py feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
test_router_provider_endpoints.py feat(redis): serve the proxy's common Redis call with Rust stores (#50170) 2026-11-06 06:01:11 +00:00
test_router_retries.py fix(router): with pre-call checks on, retry a context window error on a group deployment serving another model (#54157) 2026-11-25 10:57:40 +00:00
test_router_surface_check.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_router_timeout.py feat(messages): serve bedrock invoke messages on rust only (#51330) 2026-11-15 16:58:31 -08:00
test_router_vector_store_endpoints.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00