[Router]fix: fix get_load missing api_key (#10385)

This commit is contained in:
Jimmy
2025-09-22 03:28:38 +08:00
committed by GitHub
parent 12d6cf18f0
commit 56321e9fc2
21 changed files with 378 additions and 111 deletions

View File

@@ -18,6 +18,7 @@ fn test_backward_compatibility_with_empty_model_id() {
// Create workers with empty model_id (simulating existing routers)
let worker1 = BasicWorkerBuilder::new("http://worker1:8080")
.worker_type(WorkerType::Regular)
.api_key("test_api_key")
.build();
// No model_id label - should default to "unknown"
@@ -25,6 +26,7 @@ fn test_backward_compatibility_with_empty_model_id() {
labels2.insert("model_id".to_string(), "unknown".to_string());
let worker2 = BasicWorkerBuilder::new("http://worker2:8080")
.worker_type(WorkerType::Regular)
.api_key("test_api_key")
.labels(labels2)
.build();
@@ -59,6 +61,7 @@ fn test_mixed_model_ids() {
// Create workers with different model_id scenarios
let worker1 = BasicWorkerBuilder::new("http://worker1:8080")
.worker_type(WorkerType::Regular)
.api_key("test_api_key")
.build();
// No model_id label - defaults to "unknown" which goes to "default" tree
@@ -67,6 +70,7 @@ fn test_mixed_model_ids() {
let worker2 = BasicWorkerBuilder::new("http://worker2:8080")
.worker_type(WorkerType::Regular)
.labels(labels2)
.api_key("test_api_key")
.build();
let mut labels3 = HashMap::new();
@@ -123,10 +127,12 @@ fn test_remove_worker_by_url_backward_compat() {
let worker1 = BasicWorkerBuilder::new("http://worker1:8080")
.worker_type(WorkerType::Regular)
.labels(labels1)
.api_key("test_api_key")
.build();
let worker2 = BasicWorkerBuilder::new("http://worker2:8080")
.worker_type(WorkerType::Regular)
.api_key("test_api_key")
.build();
// No model_id label - defaults to "unknown"

View File

@@ -41,6 +41,7 @@ async fn test_policy_registry_with_router_manager() {
let _worker1_config = WorkerConfigRequest {
url: "http://worker1:8000".to_string(),
model_id: Some("llama-3".to_string()),
api_key: Some("test_api_key".to_string()),
worker_type: None,
priority: None,
cost: None,
@@ -66,6 +67,7 @@ async fn test_policy_registry_with_router_manager() {
let _worker2_config = WorkerConfigRequest {
url: "http://worker2:8000".to_string(),
model_id: Some("llama-3".to_string()),
api_key: Some("test_api_key".to_string()),
worker_type: None,
priority: None,
cost: None,
@@ -86,6 +88,7 @@ async fn test_policy_registry_with_router_manager() {
let _worker3_config = WorkerConfigRequest {
url: "http://worker3:8000".to_string(),
model_id: Some("gpt-4".to_string()),
api_key: Some("test_api_key".to_string()),
worker_type: None,
priority: None,
cost: None,

View File

@@ -54,6 +54,7 @@ mod test_pd_routing {
.worker_type(WorkerType::Prefill {
bootstrap_port: Some(9000),
})
.api_key("test_api_key")
.build(),
);
assert_eq!(prefill_worker.url(), "http://prefill:8080");
@@ -68,6 +69,7 @@ mod test_pd_routing {
let decode_worker: Box<dyn Worker> = Box::new(
BasicWorkerBuilder::new("http://decode:8080")
.worker_type(WorkerType::Decode)
.api_key("test_api_key")
.build(),
);
assert_eq!(decode_worker.url(), "http://decode:8080");
@@ -80,6 +82,7 @@ mod test_pd_routing {
let regular_worker: Box<dyn Worker> = Box::new(
BasicWorkerBuilder::new("http://regular:8080")
.worker_type(WorkerType::Regular)
.api_key("test_api_key")
.build(),
);
assert_eq!(regular_worker.url(), "http://regular:8080");
@@ -297,6 +300,7 @@ mod test_pd_routing {
.worker_type(WorkerType::Prefill {
bootstrap_port: Some(9000),
})
.api_key("test_api_key")
.build(),
);
@@ -700,6 +704,7 @@ mod test_pd_routing {
.worker_type(WorkerType::Prefill {
bootstrap_port: Some(9000),
})
.api_key("test_api_key")
.build(),
);
@@ -836,6 +841,7 @@ mod test_pd_routing {
.worker_type(WorkerType::Prefill {
bootstrap_port: Some(9000),
})
.api_key("test_api_key")
.build(),
);