fix: strip "[asctime]" prefix when parsing JSON log lines in nightly tests (#25340)

This commit is contained in:
Kangyan-Zhou
2026-05-14 20:17:13 -07:00
committed by GitHub
parent d89b678d69
commit 974948a701
3 changed files with 21 additions and 10 deletions
+6 -4
View File
@@ -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":
@@ -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__":