From 8cc300f536c111f767ff5bccef3d2623fc063d39 Mon Sep 17 00:00:00 2001 From: Byron Hsu Date: Sun, 16 Mar 2025 22:49:47 -0700 Subject: [PATCH] Fix router test (#4483) --- python/sglang/test/test_utils.py | 9 ++++++++- sgl-router/py_test/run_suite.py | 5 +++-- sgl-router/src/router.rs | 17 +++++++++-------- test/lang/run_suite.py | 10 +--------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index 3fe5d2a0f..a88698b96 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -10,6 +10,7 @@ import threading import time import unittest from concurrent.futures import ThreadPoolExecutor +from dataclasses import dataclass from functools import partial from types import SimpleNamespace from typing import Callable, List, Optional, Tuple @@ -453,7 +454,13 @@ def run_with_timeout( return ret_value[0] -def run_unittest_files(files: List, timeout_per_file: float): +@dataclass +class TestFile: + name: str + estimated_time: float = 60 + + +def run_unittest_files(files: List[TestFile], timeout_per_file: float): tic = time.time() success = True diff --git a/sgl-router/py_test/run_suite.py b/sgl-router/py_test/run_suite.py index 0f012b751..e1434b0e8 100644 --- a/sgl-router/py_test/run_suite.py +++ b/sgl-router/py_test/run_suite.py @@ -1,7 +1,7 @@ import argparse import glob -from sglang.test.test_utils import run_unittest_files +from sglang.test.test_utils import TestFile, run_unittest_files if __name__ == "__main__": arg_parser = argparse.ArgumentParser() @@ -15,5 +15,6 @@ if __name__ == "__main__": files = glob.glob("**/test_*.py", recursive=True) - exit_code = run_unittest_files(files, args.timeout_per_file) + test_files = [TestFile(name=file) for file in files] + exit_code = run_unittest_files(test_files, args.timeout_per_file) exit(exit_code) diff --git a/sgl-router/src/router.rs b/sgl-router/src/router.rs index f03682698..e722732c7 100644 --- a/sgl-router/src/router.rs +++ b/sgl-router/src/router.rs @@ -267,19 +267,20 @@ impl Router { match sync_client.get(&format!("{}/health", url)).send() { Ok(res) => { if !res.status().is_success() { - info!( - "Worker {} health check is pending with status: {}.", - url, + let msg = format!( + "Worker heatlh check is pending with status {}", res.status() ); + info!("{}", msg); all_healthy = false; - unhealthy_workers.push((url, format!("Status: {}", res.status()))); + unhealthy_workers.push((url, msg)); } } - Err(e) => { - info!("Worker {} health check is pending with error: {}", url, e); + Err(_) => { + let msg = format!("Worker is not ready yet"); + info!("{}", msg); all_healthy = false; - unhealthy_workers.push((url, format!("Error: {}", e))); + unhealthy_workers.push((url, msg)); } } } @@ -288,7 +289,7 @@ impl Router { info!("All workers are healthy"); return Ok(()); } else { - info!("Unhealthy workers:"); + info!("Initializing workers:"); for (url, reason) in &unhealthy_workers { info!(" {} - {}", url, reason); } diff --git a/test/lang/run_suite.py b/test/lang/run_suite.py index e4e11ca4f..04efba51f 100644 --- a/test/lang/run_suite.py +++ b/test/lang/run_suite.py @@ -1,15 +1,7 @@ import argparse import glob -from dataclasses import dataclass - -from sglang.test.test_utils import run_unittest_files - - -@dataclass -class TestFile: - name: str - estimated_time: float = 60 +from sglang.test.test_utils import TestFile, run_unittest_files suites = { "per-commit": [