[model-gateway] reorganize integration tests into logical subdirectories (#16451)

This commit is contained in:
Simo Lin
2026-01-04 21:49:20 -08:00
committed by GitHub
parent 4ea6a11c83
commit e53160bb31
24 changed files with 99 additions and 65 deletions

View File

@@ -1,18 +1,17 @@
mod common;
use axum::{
body::Body,
extract::Request,
http::{header::CONTENT_TYPE, StatusCode},
};
use common::{
mock_worker::{HealthStatus, MockWorker, MockWorkerConfig, WorkerType},
AppTestContext,
};
use serde_json::json;
use smg::{config::RouterConfig, routers::RouterFactory};
use tower::ServiceExt;
use crate::common::{
mock_worker::{HealthStatus, MockWorker, MockWorkerConfig, WorkerType},
AppTestContext,
};
#[cfg(test)]
mod health_tests {
use super::*;
@@ -1391,7 +1390,7 @@ mod pd_mode_tests {
.build_unchecked();
// Create app context
let app_context = common::create_test_context(config).await;
let app_context = crate::common::create_test_context(config).await;
// Create router - this might fail due to health check issues
let router_result = RouterFactory::create_router(&app_context).await;

View File

@@ -0,0 +1,7 @@
//! API endpoint integration tests
mod api_endpoints_test;
mod parser_endpoints_test;
mod request_formats_test;
mod responses_api_test;
mod streaming_tests;

View File

@@ -1,5 +1,3 @@
mod common;
use std::sync::Arc;
use axum::{
@@ -7,7 +5,6 @@ use axum::{
extract::Request,
http::{header::CONTENT_TYPE, StatusCode},
};
use common::mock_worker::{MockWorker, MockWorkerConfig};
use reqwest::Client;
use serde_json::json;
use smg::{
@@ -17,6 +14,8 @@ use smg::{
};
use tower::ServiceExt;
use crate::common::mock_worker::{MockWorker, MockWorkerConfig};
/// Test context that manages mock workers and app
struct ParserTestContext {
workers: Vec<MockWorker>,
@@ -89,7 +88,7 @@ impl ParserTestContext {
.unwrap();
// Create app context with parser factories initialized
let app_context = common::create_test_context_with_parsers(config.clone()).await;
let app_context = crate::common::create_test_context_with_parsers(config.clone()).await;
// Create router
let router = RouterFactory::create_router(&app_context).await.unwrap();
@@ -105,7 +104,7 @@ impl ParserTestContext {
}
async fn create_app(&self) -> axum::Router {
common::test_app::create_test_app_with_context(
crate::common::test_app::create_test_app_with_context(
Arc::clone(&self.router),
Arc::clone(&self.app_context),
)

View File

@@ -1,10 +1,9 @@
mod common;
use serde_json::json;
use common::{
use crate::common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
WorkerTestContext,
};
use serde_json::json;
#[cfg(test)]
mod request_format_tests {

View File

@@ -1,24 +1,23 @@
// Integration test for Responses API
use axum::http::StatusCode;
use smg::protocols::{
common::{GenerationRequest, ToolChoice, ToolChoiceValue, UsageInfo},
responses::{
ReasoningEffort, ResponseInput, ResponseReasoningParam, ResponseTool, ResponseToolType,
ResponsesRequest, ServiceTier, Truncation,
},
};
mod common;
use common::{
mock_mcp_server::MockMCPServer,
mock_worker::{HealthStatus, MockWorker, MockWorkerConfig, WorkerType},
};
use smg::{
config::RouterConfig,
protocols::{
common::{GenerationRequest, ToolChoice, ToolChoiceValue, UsageInfo},
responses::{
ReasoningEffort, ResponseInput, ResponseReasoningParam, ResponseTool, ResponseToolType,
ResponsesRequest, ServiceTier, Truncation,
},
},
routers::{conversations, RouterFactory},
};
use crate::common::{
mock_mcp_server::MockMCPServer,
mock_worker::{HealthStatus, MockWorker, MockWorkerConfig, WorkerType},
};
#[tokio::test]
async fn test_non_streaming_mcp_minimal_e2e_with_persistence() {
// Start mock MCP server
@@ -60,7 +59,8 @@ async fn test_non_streaming_mcp_minimal_e2e_with_persistence() {
// Create router and context with MCP config from file
let ctx =
common::create_test_context_with_mcp_config(router_cfg, cfg_path.to_str().unwrap()).await;
crate::common::create_test_context_with_mcp_config(router_cfg, cfg_path.to_str().unwrap())
.await;
let router = RouterFactory::create_router(&ctx).await.expect("router");
// Build a simple ResponsesRequest that will trigger the tool call
@@ -236,7 +236,7 @@ async fn test_conversations_crud_basic() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let _router = RouterFactory::create_router(&ctx).await.expect("router");
// Create
@@ -550,7 +550,7 @@ async fn test_multi_turn_loop_with_mcp() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let router = RouterFactory::create_router(&ctx).await.expect("router");
// Build request with MCP tools
@@ -702,7 +702,7 @@ async fn test_max_tool_calls_limit() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let router = RouterFactory::create_router(&ctx).await.expect("router");
let req = ResponsesRequest {
@@ -821,7 +821,8 @@ async fn setup_streaming_mcp_test() -> (
.build_unchecked();
let ctx =
common::create_test_context_with_mcp_config(router_cfg, cfg_path.to_str().unwrap()).await;
crate::common::create_test_context_with_mcp_config(router_cfg, cfg_path.to_str().unwrap())
.await;
let router = RouterFactory::create_router(&ctx).await.expect("router");
(mcp, worker, router, dir)
@@ -1239,7 +1240,7 @@ async fn test_conversation_items_create_and_get() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let _router = RouterFactory::create_router(&ctx).await.expect("router");
// Create conversation
@@ -1325,7 +1326,7 @@ async fn test_conversation_items_delete() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let _router = RouterFactory::create_router(&ctx).await.expect("router");
// Create conversation
@@ -1433,7 +1434,7 @@ async fn test_conversation_items_max_limit() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let _router = RouterFactory::create_router(&ctx).await.expect("router");
// Create conversation
@@ -1490,7 +1491,7 @@ async fn test_conversation_items_unsupported_type() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let _router = RouterFactory::create_router(&ctx).await.expect("router");
// Create conversation
@@ -1546,7 +1547,7 @@ async fn test_conversation_items_multi_conversation_sharing() {
.queue_timeout_secs(5)
.build_unchecked();
let ctx = common::create_test_context(router_cfg).await;
let ctx = crate::common::create_test_context(router_cfg).await;
let _router = RouterFactory::create_router(&ctx).await.expect("router");
// Create two conversations

View File

@@ -1,13 +1,12 @@
mod common;
use serde_json::json;
use common::{
use crate::common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
WorkerTestContext,
};
use serde_json::json;
#[cfg(test)]
mod streaming_tests {
mod tests {
use super::*;
#[tokio::test]

View File

@@ -0,0 +1,6 @@
//! API integration tests
#[path = "common/mod.rs"]
pub mod common;
mod api;

View File

@@ -0,0 +1,4 @@
//! Multimodal and vision integration tests
mod multimodal_tracker_test;
mod vision_golden_tests;

View File

@@ -0,0 +1,6 @@
//! Multimodal integration tests
#[path = "common/mod.rs"]
pub mod common;
mod multimodal;

View File

@@ -2,21 +2,20 @@
//!
//! Tests for header propagation through the router to workers.
mod common;
use axum::{
body::Body,
extract::Request,
http::{header::CONTENT_TYPE, StatusCode},
};
use common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
AppTestContext,
};
use serde_json::json;
use smg::config::RouterConfig;
use tower::ServiceExt;
use crate::common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
AppTestContext,
};
#[cfg(test)]
mod header_forwarding_tests {
use super::*;

View File

@@ -1,9 +1,14 @@
//! Routing integration tests
pub mod cache_aware_backward_compat_test;
pub mod header_forwarding_test;
pub mod load_balancing_test;
pub mod manual_routing_test;
pub mod payload_size_test;
pub mod pd_routing_test;
pub mod policy_registry_integration;
pub mod power_of_two_test;
pub mod service_discovery_test;
pub mod test_openai_routing;
pub mod test_pd_routing;
pub mod worker_management_test;

View File

@@ -2,21 +2,20 @@
//!
//! Tests for request payload size limits and handling.
mod common;
use axum::{
body::Body,
extract::Request,
http::{header::CONTENT_TYPE, StatusCode},
};
use common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
AppTestContext,
};
use serde_json::json;
use smg::config::RouterConfig;
use tower::ServiceExt;
use crate::common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
AppTestContext,
};
#[cfg(test)]
mod payload_size_tests {
use super::*;

View File

@@ -2,21 +2,20 @@
//!
//! Tests for service discovery shim functionality for dynamic worker registration.
mod common;
use axum::{
body::Body,
extract::Request,
http::{header::CONTENT_TYPE, StatusCode},
};
use common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
AppTestContext,
};
use serde_json::json;
use smg::config::RouterConfig;
use tower::ServiceExt;
use crate::common::{
mock_worker::{HealthStatus, MockWorkerConfig, WorkerType},
AppTestContext,
};
#[cfg(test)]
mod service_discovery_tests {
use super::*;

View File

@@ -6,17 +6,16 @@
//! - GET /workers - list workers
//! - DELETE /workers/{worker_id} - remove a worker
mod common;
use axum::{
body::Body,
extract::Request,
http::{header::CONTENT_TYPE, StatusCode},
};
use common::{AppTestContext, TestRouterConfig, TestWorkerConfig};
use serde_json::json;
use tower::ServiceExt;
use crate::common::{AppTestContext, TestRouterConfig, TestWorkerConfig};
#[cfg(test)]
mod worker_management_tests {
use super::*;

View File

@@ -0,0 +1,7 @@
//! Tokenizer and chat template integration tests
mod chat_template_format_detection;
mod chat_template_integration;
mod chat_template_loading;
mod tokenizer_cache_correctness_test;
mod tokenizer_integration;

View File

@@ -3,15 +3,15 @@
//! These tests download the TinyLlama tokenizer from HuggingFace to verify our tokenizer
//! implementation works correctly with real-world tokenizer files.
mod common;
use std::sync::Arc;
use common::{ensure_tokenizer_cached, EXPECTED_HASHES, TEST_PROMPTS};
use smg::tokenizer::{
factory, huggingface::HuggingFaceTokenizer, sequence::Sequence, stop::*, stream::DecodeStream,
traits::*,
};
use crate::common::{ensure_tokenizer_cached, EXPECTED_HASHES, TEST_PROMPTS};
const LONG_TEST_PROMPTS: [(&str, &str); 6] = [
("Tell me about the following text.", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."),
("Tell me about the following text.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."),

View File

@@ -0,0 +1,6 @@
//! Tokenizer integration tests
#[path = "common/mod.rs"]
pub mod common;
mod tokenizer;