[router] add ipv6 support across all components (#11219)
This commit is contained in:
@@ -5,7 +5,6 @@ mod test_pd_routing {
|
||||
CircuitBreakerConfig, ConnectionMode, PolicyConfig, RetryConfig, RouterConfig, RoutingMode,
|
||||
};
|
||||
use sglang_router_rs::core::{BasicWorkerBuilder, Worker, WorkerType};
|
||||
use sglang_router_rs::routers::http::pd_types::get_hostname;
|
||||
use sglang_router_rs::routers::http::pd_types::PDSelectionPolicy;
|
||||
use sglang_router_rs::routers::RouterFactory;
|
||||
|
||||
@@ -286,7 +285,7 @@ mod test_pd_routing {
|
||||
_ => None,
|
||||
};
|
||||
|
||||
single_json["bootstrap_host"] = json!(get_hostname(prefill_worker.url()));
|
||||
single_json["bootstrap_host"] = json!(prefill_worker.bootstrap_host());
|
||||
single_json["bootstrap_port"] = json!(bootstrap_port);
|
||||
single_json["bootstrap_room"] = json!(12345u64); // Random room ID
|
||||
|
||||
@@ -301,7 +300,7 @@ mod test_pd_routing {
|
||||
});
|
||||
|
||||
let batch_size = 3;
|
||||
let hostname = get_hostname(prefill_worker.url());
|
||||
let hostname = prefill_worker.bootstrap_host();
|
||||
batch_json["bootstrap_host"] = json!(vec![hostname; batch_size]);
|
||||
batch_json["bootstrap_port"] = json!(vec![bootstrap_port; batch_size]);
|
||||
batch_json["bootstrap_room"] = json!(vec![111u64, 222u64, 333u64]);
|
||||
@@ -343,22 +342,6 @@ mod test_pd_routing {
|
||||
assert_eq!(parsed["bootstrap_room"], 12345);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hostname_extraction() {
|
||||
let test_cases = vec![
|
||||
("http://localhost:8080", "localhost"),
|
||||
("http://10.0.0.1:8080", "10.0.0.1"),
|
||||
("https://api.example.com:443", "api.example.com"),
|
||||
("http://prefill-server", "prefill-server"),
|
||||
("http://[::1]:8080", "["), // IPv6 edge case
|
||||
("prefill:8080", "prefill"), // No protocol
|
||||
];
|
||||
|
||||
for (url, expected_hostname) in test_cases {
|
||||
assert_eq!(get_hostname(url), expected_hostname);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pd_request_edge_cases() {
|
||||
let empty_json = json!({});
|
||||
@@ -644,7 +627,7 @@ mod test_pd_routing {
|
||||
_ => None,
|
||||
};
|
||||
let batch_size = 16;
|
||||
let hostname = get_hostname(prefill_worker.url());
|
||||
let hostname = prefill_worker.bootstrap_host();
|
||||
|
||||
benchmark_request["bootstrap_host"] = json!(vec![hostname; batch_size]);
|
||||
benchmark_request["bootstrap_port"] = json!(vec![bootstrap_port; batch_size]);
|
||||
@@ -769,7 +752,7 @@ mod test_pd_routing {
|
||||
WorkerType::Prefill { bootstrap_port } => bootstrap_port,
|
||||
_ => None,
|
||||
};
|
||||
let hostname = get_hostname(prefill_worker.url());
|
||||
let hostname = prefill_worker.bootstrap_host();
|
||||
|
||||
large_batch_request["bootstrap_host"] = json!(vec![hostname; batch_size]);
|
||||
large_batch_request["bootstrap_port"] = json!(vec![bootstrap_port; batch_size]);
|
||||
|
||||
Reference in New Issue
Block a user