fix: strip "[asctime]" prefix when parsing JSON log lines in nightly tests (#25340)
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user