diff --git a/test/registered/bench_fn/test_bench_serving_functionality.py b/test/registered/bench_fn/test_bench_serving_functionality.py index f573319c7..4eaa74a9c 100644 --- a/test/registered/bench_fn/test_bench_serving_functionality.py +++ b/test/registered/bench_fn/test_bench_serving_functionality.py @@ -74,9 +74,13 @@ class TestBenchServingFunctionality(CustomTestCase): def _verify_multi_turn_logs(self, content: str): reqs = [] for line in content.splitlines(): - if not line.startswith("{"): + idx = line.find("{") + if idx == -1: + continue + try: + obj = json.loads(line[idx:]) + except json.JSONDecodeError: continue - obj = json.loads(line) if obj.get("event") != "request.finished": continue text = obj.get("obj", {}).get("text") diff --git a/test/registered/utils/test_request_logger.py b/test/registered/utils/test_request_logger.py index c87a88448..ae6c7e352 100644 --- a/test/registered/utils/test_request_logger.py +++ b/test/registered/utils/test_request_logger.py @@ -190,10 +190,11 @@ class TestRequestLoggerJson(BaseTestRequestLogger, CustomTestCase): received_found = False finished_found = False for line in content.splitlines(): - if not line.strip() or not line.startswith("{"): + idx = line.find("{") + if idx == -1: continue try: - data = json.loads(line) + data = json.loads(line[idx:]) except json.JSONDecodeError: continue @@ -227,10 +228,11 @@ class TestRequestLoggerJson(BaseTestRequestLogger, CustomTestCase): def _verify_openai_logs(self, content: str, source_name: str): openai_received_found = False for line in content.splitlines(): - if not line.strip() or not line.startswith("{"): + idx = line.find("{") + if idx == -1: continue try: - data = json.loads(line) + data = json.loads(line[idx:]) except json.JSONDecodeError: continue if data.get("event") != "request.received.openai": diff --git a/test/registered/utils/test_scheduler_status_logger.py b/test/registered/utils/test_scheduler_status_logger.py index 2247afbd4..d579a77e8 100644 --- a/test/registered/utils/test_scheduler_status_logger.py +++ b/test/registered/utils/test_scheduler_status_logger.py @@ -64,10 +64,15 @@ class TestSchedulerStatusLogger(CustomTestCase): def _find_log_events(log_dir: str, event_name: str): for f in Path(log_dir).glob("*.log"): for line in f.read_text().splitlines(): - if line.startswith("{"): - data = json.loads(line) - if data.get("event") == event_name: - yield data + idx = line.find("{") + if idx == -1: + continue + try: + data = json.loads(line[idx:]) + except json.JSONDecodeError: + continue + if data.get("event") == event_name: + yield data if __name__ == "__main__":