[router] remove old/oudated/useless comments across code base (#10968)
This commit is contained in:
@@ -205,7 +205,6 @@ impl RoutingMode {
|
||||
decode_urls,
|
||||
..
|
||||
} => prefill_urls.len() + decode_urls.len(),
|
||||
// OpenAI mode represents a single upstream
|
||||
RoutingMode::OpenAI { .. } => 1,
|
||||
}
|
||||
}
|
||||
@@ -515,8 +514,6 @@ impl RouterConfig {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// ============= RouterConfig Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_router_config_default() {
|
||||
let config = RouterConfig::default();
|
||||
@@ -556,7 +553,6 @@ mod tests {
|
||||
}
|
||||
|
||||
assert!(matches!(config.policy, PolicyConfig::RoundRobin));
|
||||
// Other fields should be default
|
||||
assert_eq!(config.host, "127.0.0.1");
|
||||
assert_eq!(config.port, 3001);
|
||||
}
|
||||
@@ -583,13 +579,10 @@ mod tests {
|
||||
assert_eq!(config.max_payload_size, deserialized.max_payload_size);
|
||||
assert_eq!(config.log_dir, deserialized.log_dir);
|
||||
assert_eq!(config.log_level, deserialized.log_level);
|
||||
// discovery and metrics are None in Default implementation
|
||||
assert!(deserialized.discovery.is_none());
|
||||
assert!(deserialized.metrics.is_none());
|
||||
}
|
||||
|
||||
// ============= RoutingMode Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_routing_mode_is_pd_mode() {
|
||||
let regular = RoutingMode::Regular {
|
||||
@@ -640,7 +633,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_routing_mode_serialization() {
|
||||
// Test Regular mode
|
||||
let regular = RoutingMode::Regular {
|
||||
worker_urls: vec!["http://worker1".to_string()],
|
||||
};
|
||||
@@ -648,7 +640,6 @@ mod tests {
|
||||
assert!(json.contains("\"type\":\"regular\""));
|
||||
assert!(json.contains("\"worker_urls\""));
|
||||
|
||||
// Test PrefillDecode mode
|
||||
let pd = RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![("http://prefill1".to_string(), Some(8001))],
|
||||
decode_urls: vec!["http://decode1".to_string()],
|
||||
@@ -661,8 +652,6 @@ mod tests {
|
||||
assert!(json.contains("\"decode_urls\""));
|
||||
}
|
||||
|
||||
// ============= PolicyConfig Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_policy_config_name() {
|
||||
assert_eq!(PolicyConfig::Random.name(), "random");
|
||||
@@ -685,12 +674,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_policy_config_serialization() {
|
||||
// Test Random
|
||||
let random = PolicyConfig::Random;
|
||||
let json = serde_json::to_string(&random).unwrap();
|
||||
assert_eq!(json, r#"{"type":"random"}"#);
|
||||
|
||||
// Test CacheAware with all parameters
|
||||
let cache_aware = PolicyConfig::CacheAware {
|
||||
cache_threshold: 0.8,
|
||||
balance_abs_threshold: 10,
|
||||
@@ -703,7 +690,6 @@ mod tests {
|
||||
assert!(json.contains("\"cache_threshold\":0.8"));
|
||||
assert!(json.contains("\"balance_abs_threshold\":10"));
|
||||
|
||||
// Test PowerOfTwo
|
||||
let power_of_two = PolicyConfig::PowerOfTwo {
|
||||
load_check_interval_secs: 60,
|
||||
};
|
||||
@@ -756,8 +742,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// ============= DiscoveryConfig Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_discovery_config_default() {
|
||||
let config = DiscoveryConfig::default();
|
||||
@@ -798,14 +782,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_discovery_config_namespace() {
|
||||
// Test None namespace (all namespaces)
|
||||
let config = DiscoveryConfig {
|
||||
namespace: None,
|
||||
..Default::default()
|
||||
};
|
||||
assert!(config.namespace.is_none());
|
||||
|
||||
// Test specific namespace
|
||||
let config = DiscoveryConfig {
|
||||
namespace: Some("production".to_string()),
|
||||
..Default::default()
|
||||
@@ -813,8 +795,6 @@ mod tests {
|
||||
assert_eq!(config.namespace, Some("production".to_string()));
|
||||
}
|
||||
|
||||
// ============= MetricsConfig Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_metrics_config_default() {
|
||||
let config = MetricsConfig::default();
|
||||
@@ -834,8 +814,6 @@ mod tests {
|
||||
assert_eq!(config.host, "0.0.0.0");
|
||||
}
|
||||
|
||||
// ============= RouterConfig Utility Methods Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_mode_type() {
|
||||
let config = RouterConfig {
|
||||
@@ -894,8 +872,6 @@ mod tests {
|
||||
assert!(config.has_metrics());
|
||||
}
|
||||
|
||||
// ============= Edge Cases =============
|
||||
|
||||
#[test]
|
||||
fn test_large_worker_lists() {
|
||||
let large_urls: Vec<String> = (0..1000).map(|i| format!("http://worker{}", i)).collect();
|
||||
@@ -906,7 +882,6 @@ mod tests {
|
||||
|
||||
assert_eq!(mode.worker_count(), 1000);
|
||||
|
||||
// Test serialization with large list
|
||||
let config = RouterConfig {
|
||||
mode,
|
||||
..Default::default()
|
||||
@@ -961,8 +936,6 @@ mod tests {
|
||||
assert_eq!(config.log_level, Some("".to_string()));
|
||||
}
|
||||
|
||||
// ============= Complex Configuration Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_full_pd_mode_config() {
|
||||
let config = RouterConfig {
|
||||
@@ -1149,7 +1122,6 @@ mod tests {
|
||||
assert!(config.has_metrics());
|
||||
assert_eq!(config.mode_type(), "regular");
|
||||
|
||||
// Test round-trip serialization
|
||||
let json = serde_json::to_string_pretty(&config).unwrap();
|
||||
let deserialized: RouterConfig = serde_json::from_str(&json).unwrap();
|
||||
|
||||
@@ -1161,11 +1133,8 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
// ============= Policy Fallback Tests =============
|
||||
|
||||
#[test]
|
||||
fn test_pd_policy_fallback_both_specified() {
|
||||
// When both prefill and decode policies are specified, they should be used
|
||||
let pd = RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![("http://prefill1".to_string(), None)],
|
||||
decode_urls: vec!["http://decode1".to_string()],
|
||||
@@ -1183,21 +1152,19 @@ mod tests {
|
||||
|
||||
let main_policy = PolicyConfig::Random;
|
||||
|
||||
// Both specific policies should be used
|
||||
match pd.get_prefill_policy(&main_policy) {
|
||||
PolicyConfig::CacheAware { .. } => {} // Success
|
||||
PolicyConfig::CacheAware { .. } => {}
|
||||
_ => panic!("Expected CacheAware for prefill"),
|
||||
}
|
||||
|
||||
match pd.get_decode_policy(&main_policy) {
|
||||
PolicyConfig::PowerOfTwo { .. } => {} // Success
|
||||
PolicyConfig::PowerOfTwo { .. } => {}
|
||||
_ => panic!("Expected PowerOfTwo for decode"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pd_policy_fallback_only_prefill() {
|
||||
// When only prefill policy is specified, decode should use main policy
|
||||
let pd = RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![("http://prefill1".to_string(), None)],
|
||||
decode_urls: vec!["http://decode1".to_string()],
|
||||
@@ -1213,22 +1180,19 @@ mod tests {
|
||||
|
||||
let main_policy = PolicyConfig::RoundRobin;
|
||||
|
||||
// Prefill should use specific policy
|
||||
match pd.get_prefill_policy(&main_policy) {
|
||||
PolicyConfig::CacheAware { .. } => {} // Success
|
||||
PolicyConfig::CacheAware { .. } => {}
|
||||
_ => panic!("Expected CacheAware for prefill"),
|
||||
}
|
||||
|
||||
// Decode should fall back to main policy
|
||||
match pd.get_decode_policy(&main_policy) {
|
||||
PolicyConfig::RoundRobin => {} // Success
|
||||
PolicyConfig::RoundRobin => {}
|
||||
_ => panic!("Expected RoundRobin for decode"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pd_policy_fallback_only_decode() {
|
||||
// When only decode policy is specified, prefill should use main policy
|
||||
let pd = RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![("http://prefill1".to_string(), None)],
|
||||
decode_urls: vec!["http://decode1".to_string()],
|
||||
@@ -1240,22 +1204,19 @@ mod tests {
|
||||
|
||||
let main_policy = PolicyConfig::Random;
|
||||
|
||||
// Prefill should fall back to main policy
|
||||
match pd.get_prefill_policy(&main_policy) {
|
||||
PolicyConfig::Random => {} // Success
|
||||
PolicyConfig::Random => {}
|
||||
_ => panic!("Expected Random for prefill"),
|
||||
}
|
||||
|
||||
// Decode should use specific policy
|
||||
match pd.get_decode_policy(&main_policy) {
|
||||
PolicyConfig::PowerOfTwo { .. } => {} // Success
|
||||
PolicyConfig::PowerOfTwo { .. } => {}
|
||||
_ => panic!("Expected PowerOfTwo for decode"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pd_policy_fallback_none_specified() {
|
||||
// When no specific policies are specified, both should use main policy
|
||||
let pd = RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![("http://prefill1".to_string(), None)],
|
||||
decode_urls: vec!["http://decode1".to_string()],
|
||||
@@ -1271,7 +1232,6 @@ mod tests {
|
||||
max_tree_size: 2000,
|
||||
};
|
||||
|
||||
// Both should fall back to main policy
|
||||
match pd.get_prefill_policy(&main_policy) {
|
||||
PolicyConfig::CacheAware {
|
||||
cache_threshold, ..
|
||||
@@ -1293,21 +1253,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_regular_mode_policy_fallback() {
|
||||
// For regular mode, the helper methods should just return the main policy
|
||||
let regular = RoutingMode::Regular {
|
||||
worker_urls: vec!["http://worker1".to_string()],
|
||||
};
|
||||
|
||||
let main_policy = PolicyConfig::RoundRobin;
|
||||
|
||||
// Both methods should return main policy for regular mode
|
||||
match regular.get_prefill_policy(&main_policy) {
|
||||
PolicyConfig::RoundRobin => {} // Success
|
||||
PolicyConfig::RoundRobin => {}
|
||||
_ => panic!("Expected RoundRobin for regular mode"),
|
||||
}
|
||||
|
||||
match regular.get_decode_policy(&main_policy) {
|
||||
PolicyConfig::RoundRobin => {} // Success
|
||||
PolicyConfig::RoundRobin => {}
|
||||
_ => panic!("Expected RoundRobin for regular mode"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,7 +670,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_validate_pd_mode_with_separate_policies() {
|
||||
// Test PD mode with different policies for prefill and decode
|
||||
let config = RouterConfig::new(
|
||||
RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![
|
||||
@@ -701,7 +700,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_validate_pd_mode_power_of_two_insufficient_workers() {
|
||||
// Test that power-of-two policy requires at least 2 workers
|
||||
let config = RouterConfig::new(
|
||||
RoutingMode::PrefillDecode {
|
||||
prefill_urls: vec![("http://prefill1:8000".to_string(), None)], // Only 1 prefill
|
||||
@@ -726,7 +724,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_validate_grpc_requires_tokenizer() {
|
||||
// Test that gRPC connection mode requires tokenizer configuration
|
||||
let mut config = RouterConfig::new(
|
||||
RoutingMode::Regular {
|
||||
worker_urls: vec!["grpc://worker:50051".to_string()],
|
||||
@@ -748,7 +745,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_validate_grpc_with_model_path() {
|
||||
// Test that gRPC works with model_path
|
||||
let mut config = RouterConfig::new(
|
||||
RoutingMode::Regular {
|
||||
worker_urls: vec!["grpc://worker:50051".to_string()],
|
||||
@@ -765,7 +761,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_validate_grpc_with_tokenizer_path() {
|
||||
// Test that gRPC works with tokenizer_path
|
||||
let mut config = RouterConfig::new(
|
||||
RoutingMode::Regular {
|
||||
worker_urls: vec!["grpc://worker:50051".to_string()],
|
||||
|
||||
Reference in New Issue
Block a user