litellm/litellm-rust/crates/inference-testing
Yujong Lee e632b7d05e
Some checks failed
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
test(rust): add live Bedrock Messages contract cases
2026-10-10 10:21:21 -07:00
..
src test(rust): add Messages live provider harness 2026-10-10 10:21:20 -07:00
Cargo.toml test(rust): add Messages live provider harness 2026-10-10 10:21:20 -07:00
README.md test(rust): add live Bedrock Messages contract cases 2026-10-10 10:21:21 -07:00

Live provider route tests

Each route crate owns tests/live.rs. Use named rstest provider cases for the behaviors that route supports. Shared setup lives in litellm_inference_testing::live, with production HTTP settings, authentication services, environment secrets and a deadline

These tests execute the Rust route against a real provider. They do not prove Python parity, proxy authorization, billing persistence or agent compatibility. Those belong in the corresponding boundary and gateway suites

All live cases use #[ignore = "calls a real provider, requires credentials and a live model"]. Normal Cargo runs report them as ignored. An explicitly selected case fails on missing credentials, unavailable models, provider errors or timeouts. Never return early and count missing coverage as a pass

Set LITELLM_LIVE_<ROUTE>_<PROVIDER>_MODEL to the latest model available to the test account. The model has no compiled default because vendor availability changes independently of LiteLLM. Credentials use the provider's existing configuration rather than a second test-only key convention. Export credentials in the shell before running tests. The harness does not load .env or modify process environment while tests run

Messages

Completion checks text and usage. Streaming consumes SSE to completion and checks text, usage and the terminal event. Tool round trips request a tool call and send its returned ID back with a result. Each case checks provider execution facts and rejects cache results

Messages setup and assertions live in inference-messages/tests/live/support.rs. Provider modules under tests/live/ select their payloads and tool policy. The shared helpers consume streams completely and reconstruct text, thinking signatures and tool arguments for the follow-up request

The initial provider cases are vertex_ai and bedrock. A registered ignored case is available coverage, not evidence that it passed against that provider

Run one provider's cases explicitly

LITELLM_LIVE_MESSAGES_VERTEX_AI_MODEL=<claude-model-on-vertex> \
  cargo test --manifest-path litellm-rust/Cargo.toml \
  -p litellm-inference-messages --test live vertex_ai \
  -- --ignored --nocapture --test-threads=1

For Vertex AI, set LITELLM_LIVE_MESSAGES_VERTEX_AI_MODEL to a Claude model published in the project's location. Credentials, project and location resolve through the production Rust GCP authentication, from GOOGLE_APPLICATION_CREDENTIALS or VERTEXAI_CREDENTIALS, with VERTEXAI_PROJECT and VERTEXAI_LOCATION

Vertex AI cases live in inference-messages/tests/live/vertex_ai.rs. They cover plain and system messages, text streaming, and complete and streaming tool round trips

For Bedrock, set LITELLM_LIVE_MESSAGES_BEDROCK_MODEL to a supported Claude Invoke model or inference profile. Configure AWS credentials through the existing credential chain, or AWS_BEARER_TOKEN_BEDROCK, and the required region.

Bedrock cases live in inference-messages/tests/live/bedrock.rs. They cover completion with plain and system messages, unknown field filtering, plain and explicit Invoke model paths, text streaming, and complete and streaming tool round trips. Streaming checks the returned SSE content type, terminal event, usage and tool argument reconstruction

Export AWS_BEARER_TOKEN_BEDROCK, AWS_REGION_NAME and the model before running the Bedrock cases. An optional endpoint override uses AWS_BEDROCK_RUNTIME_ENDPOINT, not AWS_BEDROCK_ENDPOINT

cargo test --manifest-path litellm-rust/Cargo.toml \
  -p litellm-inference-messages --test live bedrock \
  -- --ignored --nocapture --test-threads=1

Tool cases require a model that supports forced tool_choice, except where a provider's section says otherwise. A provider rejection fails the selected case instead of skipping it

Select one behavior by its test name, for example completion::case_1_basic. To list every available cell without contacting any provider

cargo test --manifest-path litellm-rust/Cargo.toml \
  -p litellm-inference-messages --test live -- --list

For another route, reuse LiveResources, model and within_deadline. Keep payload construction and response assertions in that route's test file. Add only supported provider behaviors, and document any gap instead of substituting mocks or skipping failures. Run cases serially to keep spending and rate limits predictable