diff --git a/sgl-model-gateway/tests/api_endpoints_test.rs b/sgl-model-gateway/tests/api/api_endpoints_test.rs similarity index 99% rename from sgl-model-gateway/tests/api_endpoints_test.rs rename to sgl-model-gateway/tests/api/api_endpoints_test.rs index a16663a87..960b59ad1 100644 --- a/sgl-model-gateway/tests/api_endpoints_test.rs +++ b/sgl-model-gateway/tests/api/api_endpoints_test.rs @@ -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; diff --git a/sgl-model-gateway/tests/api/mod.rs b/sgl-model-gateway/tests/api/mod.rs new file mode 100644 index 000000000..ad3d62c59 --- /dev/null +++ b/sgl-model-gateway/tests/api/mod.rs @@ -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; diff --git a/sgl-model-gateway/tests/parser_endpoints_test.rs b/sgl-model-gateway/tests/api/parser_endpoints_test.rs similarity index 98% rename from sgl-model-gateway/tests/parser_endpoints_test.rs rename to sgl-model-gateway/tests/api/parser_endpoints_test.rs index f3953fc4a..d59147fe1 100644 --- a/sgl-model-gateway/tests/parser_endpoints_test.rs +++ b/sgl-model-gateway/tests/api/parser_endpoints_test.rs @@ -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, @@ -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), ) diff --git a/sgl-model-gateway/tests/request_formats_test.rs b/sgl-model-gateway/tests/api/request_formats_test.rs similarity index 99% rename from sgl-model-gateway/tests/request_formats_test.rs rename to sgl-model-gateway/tests/api/request_formats_test.rs index 2e83fe805..1733d04ee 100644 --- a/sgl-model-gateway/tests/request_formats_test.rs +++ b/sgl-model-gateway/tests/api/request_formats_test.rs @@ -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 { diff --git a/sgl-model-gateway/tests/responses_api_test.rs b/sgl-model-gateway/tests/api/responses_api_test.rs similarity index 98% rename from sgl-model-gateway/tests/responses_api_test.rs rename to sgl-model-gateway/tests/api/responses_api_test.rs index ba0789115..25fba57bf 100644 --- a/sgl-model-gateway/tests/responses_api_test.rs +++ b/sgl-model-gateway/tests/api/responses_api_test.rs @@ -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 diff --git a/sgl-model-gateway/tests/streaming_tests.rs b/sgl-model-gateway/tests/api/streaming_tests.rs similarity index 99% rename from sgl-model-gateway/tests/streaming_tests.rs rename to sgl-model-gateway/tests/api/streaming_tests.rs index bcfd7099c..23de87ae4 100644 --- a/sgl-model-gateway/tests/streaming_tests.rs +++ b/sgl-model-gateway/tests/api/streaming_tests.rs @@ -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] diff --git a/sgl-model-gateway/tests/api_tests.rs b/sgl-model-gateway/tests/api_tests.rs new file mode 100644 index 000000000..a46896158 --- /dev/null +++ b/sgl-model-gateway/tests/api_tests.rs @@ -0,0 +1,6 @@ +//! API integration tests + +#[path = "common/mod.rs"] +pub mod common; + +mod api; diff --git a/sgl-model-gateway/tests/multimodal/mod.rs b/sgl-model-gateway/tests/multimodal/mod.rs new file mode 100644 index 000000000..6faf571f3 --- /dev/null +++ b/sgl-model-gateway/tests/multimodal/mod.rs @@ -0,0 +1,4 @@ +//! Multimodal and vision integration tests + +mod multimodal_tracker_test; +mod vision_golden_tests; diff --git a/sgl-model-gateway/tests/multimodal_tracker_test.rs b/sgl-model-gateway/tests/multimodal/multimodal_tracker_test.rs similarity index 100% rename from sgl-model-gateway/tests/multimodal_tracker_test.rs rename to sgl-model-gateway/tests/multimodal/multimodal_tracker_test.rs diff --git a/sgl-model-gateway/tests/vision_golden_tests.rs b/sgl-model-gateway/tests/multimodal/vision_golden_tests.rs similarity index 100% rename from sgl-model-gateway/tests/vision_golden_tests.rs rename to sgl-model-gateway/tests/multimodal/vision_golden_tests.rs diff --git a/sgl-model-gateway/tests/multimodal_tests.rs b/sgl-model-gateway/tests/multimodal_tests.rs new file mode 100644 index 000000000..d1979dc5f --- /dev/null +++ b/sgl-model-gateway/tests/multimodal_tests.rs @@ -0,0 +1,6 @@ +//! Multimodal integration tests + +#[path = "common/mod.rs"] +pub mod common; + +mod multimodal; diff --git a/sgl-model-gateway/tests/header_forwarding_test.rs b/sgl-model-gateway/tests/routing/header_forwarding_test.rs similarity index 99% rename from sgl-model-gateway/tests/header_forwarding_test.rs rename to sgl-model-gateway/tests/routing/header_forwarding_test.rs index 953623323..78d82d3aa 100644 --- a/sgl-model-gateway/tests/header_forwarding_test.rs +++ b/sgl-model-gateway/tests/routing/header_forwarding_test.rs @@ -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::*; diff --git a/sgl-model-gateway/tests/routing/mod.rs b/sgl-model-gateway/tests/routing/mod.rs index a40859cbc..25293eba4 100644 --- a/sgl-model-gateway/tests/routing/mod.rs +++ b/sgl-model-gateway/tests/routing/mod.rs @@ -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; diff --git a/sgl-model-gateway/tests/payload_size_test.rs b/sgl-model-gateway/tests/routing/payload_size_test.rs similarity index 99% rename from sgl-model-gateway/tests/payload_size_test.rs rename to sgl-model-gateway/tests/routing/payload_size_test.rs index 4ba870511..cf912a07f 100644 --- a/sgl-model-gateway/tests/payload_size_test.rs +++ b/sgl-model-gateway/tests/routing/payload_size_test.rs @@ -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::*; diff --git a/sgl-model-gateway/tests/policy_registry_integration.rs b/sgl-model-gateway/tests/routing/policy_registry_integration.rs similarity index 100% rename from sgl-model-gateway/tests/policy_registry_integration.rs rename to sgl-model-gateway/tests/routing/policy_registry_integration.rs diff --git a/sgl-model-gateway/tests/service_discovery_test.rs b/sgl-model-gateway/tests/routing/service_discovery_test.rs similarity index 99% rename from sgl-model-gateway/tests/service_discovery_test.rs rename to sgl-model-gateway/tests/routing/service_discovery_test.rs index d4103d1d1..a2b8cf6b3 100644 --- a/sgl-model-gateway/tests/service_discovery_test.rs +++ b/sgl-model-gateway/tests/routing/service_discovery_test.rs @@ -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::*; diff --git a/sgl-model-gateway/tests/worker_management_test.rs b/sgl-model-gateway/tests/routing/worker_management_test.rs similarity index 98% rename from sgl-model-gateway/tests/worker_management_test.rs rename to sgl-model-gateway/tests/routing/worker_management_test.rs index aa7f43440..655f1920d 100644 --- a/sgl-model-gateway/tests/worker_management_test.rs +++ b/sgl-model-gateway/tests/routing/worker_management_test.rs @@ -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::*; diff --git a/sgl-model-gateway/tests/chat_template_format_detection.rs b/sgl-model-gateway/tests/tokenizer/chat_template_format_detection.rs similarity index 100% rename from sgl-model-gateway/tests/chat_template_format_detection.rs rename to sgl-model-gateway/tests/tokenizer/chat_template_format_detection.rs diff --git a/sgl-model-gateway/tests/chat_template_integration.rs b/sgl-model-gateway/tests/tokenizer/chat_template_integration.rs similarity index 100% rename from sgl-model-gateway/tests/chat_template_integration.rs rename to sgl-model-gateway/tests/tokenizer/chat_template_integration.rs diff --git a/sgl-model-gateway/tests/chat_template_loading.rs b/sgl-model-gateway/tests/tokenizer/chat_template_loading.rs similarity index 100% rename from sgl-model-gateway/tests/chat_template_loading.rs rename to sgl-model-gateway/tests/tokenizer/chat_template_loading.rs diff --git a/sgl-model-gateway/tests/tokenizer/mod.rs b/sgl-model-gateway/tests/tokenizer/mod.rs new file mode 100644 index 000000000..f87c34e11 --- /dev/null +++ b/sgl-model-gateway/tests/tokenizer/mod.rs @@ -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; diff --git a/sgl-model-gateway/tests/tokenizer_cache_correctness_test.rs b/sgl-model-gateway/tests/tokenizer/tokenizer_cache_correctness_test.rs similarity index 100% rename from sgl-model-gateway/tests/tokenizer_cache_correctness_test.rs rename to sgl-model-gateway/tests/tokenizer/tokenizer_cache_correctness_test.rs diff --git a/sgl-model-gateway/tests/tokenizer_integration.rs b/sgl-model-gateway/tests/tokenizer/tokenizer_integration.rs similarity index 99% rename from sgl-model-gateway/tests/tokenizer_integration.rs rename to sgl-model-gateway/tests/tokenizer/tokenizer_integration.rs index 0f05a01c8..89572652f 100644 --- a/sgl-model-gateway/tests/tokenizer_integration.rs +++ b/sgl-model-gateway/tests/tokenizer/tokenizer_integration.rs @@ -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."), diff --git a/sgl-model-gateway/tests/tokenizer_tests.rs b/sgl-model-gateway/tests/tokenizer_tests.rs new file mode 100644 index 000000000..c2d716ac7 --- /dev/null +++ b/sgl-model-gateway/tests/tokenizer_tests.rs @@ -0,0 +1,6 @@ +//! Tokenizer integration tests + +#[path = "common/mod.rs"] +pub mod common; + +mod tokenizer;