From 878ba39e7c69c68b133591c7a03bbb8e778675cf Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 16:33:06 +0000 Subject: [PATCH] refactor(rust): extract inference-testing crate (#44873) Move the shared test helpers out of litellm-inference's test-support feature into a publish = false litellm-inference-testing crate used only as a dev dependency by the format crates. Also drop the dead src/constants.rs (OPENAI_DEFAULT_API_BASE had no users) and declare the litellm-http/litellm-llms test-support features on the crates that actually use them instead of relying on feature unification through litellm-inference's dev-dependencies. Co-authored-by: Yujong Lee Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm-rust/Cargo.lock | 16 +++++++++++++++- litellm-rust/Cargo.toml | 1 + litellm-rust/crates/inference-chat/Cargo.toml | 3 ++- .../crates/inference-chat/tests/support/mod.rs | 2 +- .../crates/inference-messages/Cargo.toml | 3 ++- .../inference-messages/tests/messages/host.rs | 2 +- .../inference-messages/tests/messages/main.rs | 2 +- .../tests/messages/response.rs | 4 ++-- .../inference-messages/tests/messages/secrets.rs | 2 +- .../inference-messages/tests/messages/stream.rs | 2 +- .../inference-messages/tests/support/mod.rs | 2 +- litellm-rust/crates/inference-ocr/Cargo.toml | 3 ++- .../crates/inference-ocr/tests/ocr/documents.rs | 2 +- .../crates/inference-ocr/tests/ocr/main.rs | 2 +- .../crates/inference-ocr/tests/ocr/mistral.rs | 2 +- .../crates/inference-ocr/tests/resources.rs | 2 +- .../crates/inference-responses/Cargo.toml | 2 +- .../inference-responses/tests/responses.rs | 2 +- .../inference-responses/tests/support/mod.rs | 2 +- litellm-rust/crates/inference-testing/Cargo.toml | 13 +++++++++++++ .../src/lib.rs} | 3 +-- .../crates/inference-transcription/Cargo.toml | 2 +- .../inference-transcription/tests/support/mod.rs | 2 +- litellm-rust/crates/inference/AGENTS.md | 2 +- litellm-rust/crates/inference/Cargo.toml | 4 ---- litellm-rust/crates/inference/src/constants.rs | 1 - litellm-rust/crates/inference/src/lib.rs | 3 --- 27 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 litellm-rust/crates/inference-testing/Cargo.toml rename litellm-rust/crates/{inference/src/test_support.rs => inference-testing/src/lib.rs} (94%) delete mode 100644 litellm-rust/crates/inference/src/constants.rs diff --git a/litellm-rust/Cargo.lock b/litellm-rust/Cargo.lock index a8f69829cd5..a3ec1f5150c 100644 --- a/litellm-rust/Cargo.lock +++ b/litellm-rust/Cargo.lock @@ -4013,7 +4013,6 @@ dependencies = [ "litellm-framer", "litellm-host", "litellm-http", - "litellm-inference", "litellm-llms", "litellm-secrets", "litellm-tracing", @@ -4042,6 +4041,7 @@ dependencies = [ "litellm-host-native", "litellm-http", "litellm-inference", + "litellm-inference-testing", "litellm-llms", "litellm-llms-types", "litellm-secrets", @@ -4068,6 +4068,7 @@ dependencies = [ "litellm-host-native", "litellm-http", "litellm-inference", + "litellm-inference-testing", "litellm-llms", "litellm-llms-types", "litellm-secrets", @@ -4096,6 +4097,7 @@ dependencies = [ "litellm-host-native", "litellm-http", "litellm-inference", + "litellm-inference-testing", "litellm-llms", "litellm-llms-types", "litellm-secrets", @@ -4125,6 +4127,7 @@ dependencies = [ "litellm-host-native", "litellm-http", "litellm-inference", + "litellm-inference-testing", "litellm-llms", "litellm-llms-types", "litellm-secrets", @@ -4138,6 +4141,16 @@ dependencies = [ "wiremock", ] +[[package]] +name = "litellm-inference-testing" +version = "0.1.0" +dependencies = [ + "futures-util", + "litellm-http", + "litellm-inference", + "litellm-secrets", +] + [[package]] name = "litellm-inference-transcription" version = "0.1.0" @@ -4147,6 +4160,7 @@ dependencies = [ "litellm-core-utils", "litellm-http", "litellm-inference", + "litellm-inference-testing", "litellm-llms", "litellm-secrets", "litellm-tracing", diff --git a/litellm-rust/Cargo.toml b/litellm-rust/Cargo.toml index 377cd8dd09f..051082329f3 100644 --- a/litellm-rust/Cargo.toml +++ b/litellm-rust/Cargo.toml @@ -22,6 +22,7 @@ litellm-inference-responses = { path = "crates/inference-responses" } litellm-inference-messages = { path = "crates/inference-messages" } litellm-inference-chat = { path = "crates/inference-chat" } litellm-inference-ocr = { path = "crates/inference-ocr" } +litellm-inference-testing = { path = "crates/inference-testing" } litellm-gateway-mcp = { path = "crates/gateway-mcp" } litellm-gateway = { path = "crates/gateway" } litellm-gateway-inference = { path = "crates/gateway-inference" } diff --git a/litellm-rust/crates/inference-chat/Cargo.toml b/litellm-rust/crates/inference-chat/Cargo.toml index 89178917a4d..130786e788d 100644 --- a/litellm-rust/crates/inference-chat/Cargo.toml +++ b/litellm-rust/crates/inference-chat/Cargo.toml @@ -22,7 +22,8 @@ tracing.workspace = true [dev-dependencies] litellm-cache-memory.workspace = true litellm-host-native.workspace = true -litellm-inference = { workspace = true, features = ["test-support"] } +litellm-http = { workspace = true, features = ["test-support"] } +litellm-inference-testing.workspace = true litellm-tracing.workspace = true rstest.workspace = true tokio.workspace = true diff --git a/litellm-rust/crates/inference-chat/tests/support/mod.rs b/litellm-rust/crates/inference-chat/tests/support/mod.rs index bb3c5daa54f..74098bf21a2 100644 --- a/litellm-rust/crates/inference-chat/tests/support/mod.rs +++ b/litellm-rust/crates/inference-chat/tests/support/mod.rs @@ -8,7 +8,7 @@ use std::{ sync::{Arc, Mutex}, }; -use litellm_inference::test_support::{http_config, no_secrets, provider_http, resources}; +use litellm_inference_testing::{http_config, no_secrets, provider_http, resources}; use serde_json::Value; use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any}; diff --git a/litellm-rust/crates/inference-messages/Cargo.toml b/litellm-rust/crates/inference-messages/Cargo.toml index 4d8cc17c94a..8dd516732d0 100644 --- a/litellm-rust/crates/inference-messages/Cargo.toml +++ b/litellm-rust/crates/inference-messages/Cargo.toml @@ -27,7 +27,8 @@ tracing.workspace = true [dev-dependencies] litellm-cache-memory.workspace = true litellm-host-native.workspace = true -litellm-inference = { workspace = true, features = ["test-support"] } +litellm-http = { workspace = true, features = ["test-support"] } +litellm-inference-testing.workspace = true rstest.workspace = true tokio.workspace = true wiremock.workspace = true diff --git a/litellm-rust/crates/inference-messages/tests/messages/host.rs b/litellm-rust/crates/inference-messages/tests/messages/host.rs index 063df469b56..e2adf04a6c0 100644 --- a/litellm-rust/crates/inference-messages/tests/messages/host.rs +++ b/litellm-rust/crates/inference-messages/tests/messages/host.rs @@ -5,8 +5,8 @@ use litellm_host::{ interceptors::{ExecutionFacts, RequestContext, ResultSource, WireRequest}, lifecycle::CallEvent, }; -use litellm_inference::test_support::{RecordingSecrets, no_secrets}; use litellm_inference_messages::{MessagesCallResponse, route::Messages}; +use litellm_inference_testing::{RecordingSecrets, no_secrets}; use litellm_llms::base_llm::messages::context::MessagesModelCapabilities as AnthropicModelCapabilities; use rstest::rstest; diff --git a/litellm-rust/crates/inference-messages/tests/messages/main.rs b/litellm-rust/crates/inference-messages/tests/messages/main.rs index beacf217ab6..a9e4a881c0a 100644 --- a/litellm-rust/crates/inference-messages/tests/messages/main.rs +++ b/litellm-rust/crates/inference-messages/tests/messages/main.rs @@ -4,11 +4,11 @@ use std::{ }; use litellm_http::{HttpSettings, Resolution}; -use litellm_inference::test_support::RecordingSecrets; use litellm_inference_messages::{ Error, MessagesCall, MessagesShaping, route::{Messages, MessagesMachine, MessagesOutput}, }; +use litellm_inference_testing::RecordingSecrets; use litellm_llms_types::formats::messages::{MessagesRequest, MessagesResponse}; use litellm_secrets::source::SecretSource; use rstest::fixture; diff --git a/litellm-rust/crates/inference-messages/tests/messages/response.rs b/litellm-rust/crates/inference-messages/tests/messages/response.rs index 183f8462c1d..13b99d45241 100644 --- a/litellm-rust/crates/inference-messages/tests/messages/response.rs +++ b/litellm-rust/crates/inference-messages/tests/messages/response.rs @@ -3,10 +3,10 @@ use litellm_host::{ lifecycle::ExecutionEvent, }; use litellm_http::transport::Error as TransportError; -use litellm_inference::test_support::{ +use litellm_inference_messages::{MessagesCallResponse, messages_body}; +use litellm_inference_testing::{ RecordingSecrets, http_config, no_secrets, provider_http, resources, }; -use litellm_inference_messages::{MessagesCallResponse, messages_body}; use rstest::rstest; use super::*; diff --git a/litellm-rust/crates/inference-messages/tests/messages/secrets.rs b/litellm-rust/crates/inference-messages/tests/messages/secrets.rs index 6d32fbed595..c565edac9dc 100644 --- a/litellm-rust/crates/inference-messages/tests/messages/secrets.rs +++ b/litellm-rust/crates/inference-messages/tests/messages/secrets.rs @@ -1,4 +1,4 @@ -use litellm_inference::test_support::RecordingSecrets; +use litellm_inference_testing::RecordingSecrets; use rstest::rstest; use super::*; diff --git a/litellm-rust/crates/inference-messages/tests/messages/stream.rs b/litellm-rust/crates/inference-messages/tests/messages/stream.rs index 88913bc6632..4dec4de2c02 100644 --- a/litellm-rust/crates/inference-messages/tests/messages/stream.rs +++ b/litellm-rust/crates/inference-messages/tests/messages/stream.rs @@ -5,11 +5,11 @@ use std::{ use bytes::Bytes; use futures_util::{StreamExt, TryStreamExt}; -use litellm_inference::test_support::{RecordingSecrets, no_secrets}; use litellm_inference_messages::{ MessagesCallResponse, route::{Messages, MessagesStreamHead}, }; +use litellm_inference_testing::{RecordingSecrets, no_secrets}; use litellm_tracing::{Logger, Metadata, Record, Sink}; use rstest::rstest; use tokio::{ diff --git a/litellm-rust/crates/inference-messages/tests/support/mod.rs b/litellm-rust/crates/inference-messages/tests/support/mod.rs index 8e702df7a55..3cecc865070 100644 --- a/litellm-rust/crates/inference-messages/tests/support/mod.rs +++ b/litellm-rust/crates/inference-messages/tests/support/mod.rs @@ -8,7 +8,7 @@ use std::{ sync::{Arc, Mutex}, }; -use litellm_inference::test_support::{http_config, provider_http, resources}; +use litellm_inference_testing::{http_config, provider_http, resources}; use litellm_secrets::source::SecretSource; use serde_json::Value; use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any}; diff --git a/litellm-rust/crates/inference-ocr/Cargo.toml b/litellm-rust/crates/inference-ocr/Cargo.toml index 0b8247637ee..21ec013f873 100644 --- a/litellm-rust/crates/inference-ocr/Cargo.toml +++ b/litellm-rust/crates/inference-ocr/Cargo.toml @@ -29,7 +29,8 @@ litellm-auth-aws.workspace = true litellm-auth-gcp.workspace = true litellm-host-native.workspace = true litellm-http = { workspace = true, features = ["test-support"] } -litellm-inference = { workspace = true, features = ["test-support"] } +litellm-inference-testing.workspace = true +litellm-llms = { workspace = true, features = ["test-support"] } rand.workspace = true rstest.workspace = true time.workspace = true diff --git a/litellm-rust/crates/inference-ocr/tests/ocr/documents.rs b/litellm-rust/crates/inference-ocr/tests/ocr/documents.rs index 53731d17dce..338a47c5f57 100644 --- a/litellm-rust/crates/inference-ocr/tests/ocr/documents.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/documents.rs @@ -1,7 +1,7 @@ use base64::Engine; use litellm_host::interceptors::WireRequest; -use litellm_inference::test_support::{http_config, no_secrets, resources}; use litellm_inference_ocr::types::OcrDocumentInput; +use litellm_inference_testing::{http_config, no_secrets, resources}; use rstest::rstest; use wiremock::{Mock, matchers::any}; diff --git a/litellm-rust/crates/inference-ocr/tests/ocr/main.rs b/litellm-rust/crates/inference-ocr/tests/ocr/main.rs index 436f11b24c9..5a905f907d2 100644 --- a/litellm-rust/crates/inference-ocr/tests/ocr/main.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/main.rs @@ -2,7 +2,6 @@ use litellm_host::{ interceptors::{RequestContext, WireRequest}, lifecycle::CallEvent, }; -use litellm_inference::test_support::{http_config, no_secrets, resources}; use litellm_inference_ocr::{ OcrRoute, document::prepare_document, @@ -10,6 +9,7 @@ use litellm_inference_ocr::{ types::{LiteLLMOcrRequest, OcrDocumentInput}, wire::{OcrWireRequest, decode_request}, }; +use litellm_inference_testing::{http_config, no_secrets, resources}; use litellm_llms::base_llm::ocr::{error::Error, settings::OcrSettings}; use litellm_llms_types::formats::ocr::{LiteLLMOcrResponse, OcrDocument}; use serde_json::{Map, Value, json}; diff --git a/litellm-rust/crates/inference-ocr/tests/ocr/mistral.rs b/litellm-rust/crates/inference-ocr/tests/ocr/mistral.rs index 39baafffa9b..528adc7feaf 100644 --- a/litellm-rust/crates/inference-ocr/tests/ocr/mistral.rs +++ b/litellm-rust/crates/inference-ocr/tests/ocr/mistral.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use litellm_http::{HttpSettings, Resolution}; -use litellm_inference::test_support::{RecordingSecrets, http_config, no_secrets, resources}; +use litellm_inference_testing::{RecordingSecrets, http_config, no_secrets, resources}; use litellm_llms::{ base_llm::ocr::transformation::{BaseOcrConfig, OCR_RESPONSE_MAX_BYTES}, mistral::ocr::transformation::MistralOcrConfig, diff --git a/litellm-rust/crates/inference-ocr/tests/resources.rs b/litellm-rust/crates/inference-ocr/tests/resources.rs index 1a9cc35db32..8a5090bf54c 100644 --- a/litellm-rust/crates/inference-ocr/tests/resources.rs +++ b/litellm-rust/crates/inference-ocr/tests/resources.rs @@ -11,8 +11,8 @@ use litellm_auth_gcp::{ }; use litellm_http::{HttpSettings, Resolution}; use litellm_inference::resources::CoreResources; -use litellm_inference::test_support::{RecordingSecrets, http_pool}; use litellm_inference_ocr::wire::{OcrWireRequest, decode_request}; +use litellm_inference_testing::{RecordingSecrets, http_pool}; use litellm_llms::base_llm::ocr::settings::OcrSettings; use rstest::{fixture, rstest}; use serde_json::json; diff --git a/litellm-rust/crates/inference-responses/Cargo.toml b/litellm-rust/crates/inference-responses/Cargo.toml index f4622ba5db9..1beab5cb822 100644 --- a/litellm-rust/crates/inference-responses/Cargo.toml +++ b/litellm-rust/crates/inference-responses/Cargo.toml @@ -26,7 +26,7 @@ tracing.workspace = true litellm-cache.workspace = true litellm-cache-memory.workspace = true litellm-host-native.workspace = true -litellm-inference = { workspace = true, features = ["test-support"] } +litellm-inference-testing.workspace = true litellm-tracing.workspace = true rstest.workspace = true wiremock.workspace = true diff --git a/litellm-rust/crates/inference-responses/tests/responses.rs b/litellm-rust/crates/inference-responses/tests/responses.rs index 969b650106a..f5181aca2b1 100644 --- a/litellm-rust/crates/inference-responses/tests/responses.rs +++ b/litellm-rust/crates/inference-responses/tests/responses.rs @@ -6,11 +6,11 @@ use std::sync::Arc; use futures_util::TryStreamExt; use litellm_host::{call::HostedCompletion, lifecycle::CallEvent}; -use litellm_inference::test_support::{RecordingSecrets, no_secrets}; use litellm_inference_responses::{ route::Responses, types::{ResponsesCall, ResponsesOutput}, }; +use litellm_inference_testing::{RecordingSecrets, no_secrets}; use rstest::{fixture, rstest}; use serde_json::json; use wiremock::ResponseTemplate; diff --git a/litellm-rust/crates/inference-responses/tests/support/mod.rs b/litellm-rust/crates/inference-responses/tests/support/mod.rs index 5e8de46e12d..81f133a0471 100644 --- a/litellm-rust/crates/inference-responses/tests/support/mod.rs +++ b/litellm-rust/crates/inference-responses/tests/support/mod.rs @@ -8,7 +8,7 @@ use std::{ sync::{Arc, Mutex}, }; -use litellm_inference::test_support::{http_config, provider_http, resources}; +use litellm_inference_testing::{http_config, provider_http, resources}; use litellm_secrets::source::SecretSource; use serde_json::Value; use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any}; diff --git a/litellm-rust/crates/inference-testing/Cargo.toml b/litellm-rust/crates/inference-testing/Cargo.toml new file mode 100644 index 00000000000..b4b9d6df79a --- /dev/null +++ b/litellm-rust/crates/inference-testing/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "litellm-inference-testing" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true +publish = false + +[dependencies] +futures-util.workspace = true +litellm-http.workspace = true +litellm-inference.workspace = true +litellm-secrets.workspace = true diff --git a/litellm-rust/crates/inference/src/test_support.rs b/litellm-rust/crates/inference-testing/src/lib.rs similarity index 94% rename from litellm-rust/crates/inference/src/test_support.rs rename to litellm-rust/crates/inference-testing/src/lib.rs index 65f5eb1fe0e..c42a032e1d8 100644 --- a/litellm-rust/crates/inference/src/test_support.rs +++ b/litellm-rust/crates/inference-testing/src/lib.rs @@ -7,7 +7,7 @@ use litellm_http::{ }; use litellm_secrets::{SecretValue, source::SecretSource}; -use crate::resources::CoreResources; +use litellm_inference::resources::CoreResources; pub fn http_pool() -> HttpClientPool { HttpClientPool::new(Arc::new(PublicDnsResolver)) @@ -32,7 +32,6 @@ pub fn http_config() -> HttpClientConfig { Resolution::from(&HttpSettings::default()).config } -/// A secret source that answers from a fixed table and records every name it was asked for. pub struct RecordingSecrets { values: Vec<(String, String)>, fails: bool, diff --git a/litellm-rust/crates/inference-transcription/Cargo.toml b/litellm-rust/crates/inference-transcription/Cargo.toml index 62522161737..c501d329852 100644 --- a/litellm-rust/crates/inference-transcription/Cargo.toml +++ b/litellm-rust/crates/inference-transcription/Cargo.toml @@ -17,7 +17,7 @@ serde_json.workspace = true tracing.workspace = true [dev-dependencies] -litellm-inference = { workspace = true, features = ["test-support"] } +litellm-inference-testing.workspace = true litellm-tracing.workspace = true rstest.workspace = true tokio.workspace = true diff --git a/litellm-rust/crates/inference-transcription/tests/support/mod.rs b/litellm-rust/crates/inference-transcription/tests/support/mod.rs index 0d42b099fb4..8ce6a99439a 100644 --- a/litellm-rust/crates/inference-transcription/tests/support/mod.rs +++ b/litellm-rust/crates/inference-transcription/tests/support/mod.rs @@ -5,7 +5,7 @@ use std::sync::{Arc, Mutex}; -use litellm_inference::test_support::{http_config, no_secrets, provider_http, resources}; +use litellm_inference_testing::{http_config, no_secrets, provider_http, resources}; use serde_json::Value; use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any}; diff --git a/litellm-rust/crates/inference/AGENTS.md b/litellm-rust/crates/inference/AGENTS.md index ad8e24e35c0..e36faad2905 100644 --- a/litellm-rust/crates/inference/AGENTS.md +++ b/litellm-rust/crates/inference/AGENTS.md @@ -5,7 +5,7 @@ - `RouteError` (`src/error.rs`), `CallOptions` (`src/lib.rs`), `CallContext` (`src/context.rs`) - diagnostic spans (`src/diagnostic.rs`), outbound send and signing (`src/outbound.rs`), provider resolution (`src/provider.rs`), `CoreResources` (`src/resources.rs`) - response caching (`src/caching.rs`): `Cachable`, `StreamCachable`, `CacheRequest`, `CallCache`, `execute_unary`, `execute_streaming`, stream capture - - shared test helpers behind the `test-support` feature (`src/test_support.rs`) + - Shared test helpers belong in litellm-inference-testing, used only as a dev dependency - Nothing here names an API format; format-specific code, constants, tests and test builders live in their `inference-` crate - Never depend on an `inference-*` crate from here diff --git a/litellm-rust/crates/inference/Cargo.toml b/litellm-rust/crates/inference/Cargo.toml index 0484749a349..acc211f214b 100644 --- a/litellm-rust/crates/inference/Cargo.toml +++ b/litellm-rust/crates/inference/Cargo.toml @@ -5,9 +5,6 @@ edition.workspace = true license.workspace = true repository.workspace = true -[features] -test-support = [] - [dependencies] litellm-cache.workspace = true litellm-cache-response.workspace = true @@ -32,7 +29,6 @@ time.workspace = true url.workspace = true [dev-dependencies] -litellm-inference = { workspace = true, features = ["test-support"] } litellm-cache-memory.workspace = true litellm-http = { workspace = true, features = ["test-support"] } litellm-llms = { workspace = true, features = ["test-support"] } diff --git a/litellm-rust/crates/inference/src/constants.rs b/litellm-rust/crates/inference/src/constants.rs deleted file mode 100644 index f8d3a045408..00000000000 --- a/litellm-rust/crates/inference/src/constants.rs +++ /dev/null @@ -1 +0,0 @@ -pub const OPENAI_DEFAULT_API_BASE: &str = "https://api.openai.com"; diff --git a/litellm-rust/crates/inference/src/lib.rs b/litellm-rust/crates/inference/src/lib.rs index 01787d3be08..a168802e7ec 100644 --- a/litellm-rust/crates/inference/src/lib.rs +++ b/litellm-rust/crates/inference/src/lib.rs @@ -2,13 +2,10 @@ pub mod context; pub mod diagnostic; pub mod caching; -pub mod constants; pub mod error; pub mod outbound; pub mod provider; pub mod resources; -#[cfg(feature = "test-support")] -pub mod test_support; pub use error::RouteError;