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):
|
def _verify_multi_turn_logs(self, content: str):
|
||||||
reqs = []
|
reqs = []
|
||||||
for line in content.splitlines():
|
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
|
continue
|
||||||
obj = json.loads(line)
|
|
||||||
if obj.get("event") != "request.finished":
|
if obj.get("event") != "request.finished":
|
||||||
continue
|
continue
|
||||||
text = obj.get("obj", {}).get("text")
|
text = obj.get("obj", {}).get("text")
|
||||||
|
|||||||
@@ -190,10 +190,11 @@ class TestRequestLoggerJson(BaseTestRequestLogger, CustomTestCase):
|
|||||||
received_found = False
|
received_found = False
|
||||||
finished_found = False
|
finished_found = False
|
||||||
for line in content.splitlines():
|
for line in content.splitlines():
|
||||||
if not line.strip() or not line.startswith("{"):
|
idx = line.find("{")
|
||||||
|
if idx == -1:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
data = json.loads(line)
|
data = json.loads(line[idx:])
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -227,10 +228,11 @@ class TestRequestLoggerJson(BaseTestRequestLogger, CustomTestCase):
|
|||||||
def _verify_openai_logs(self, content: str, source_name: str):
|
def _verify_openai_logs(self, content: str, source_name: str):
|
||||||
openai_received_found = False
|
openai_received_found = False
|
||||||
for line in content.splitlines():
|
for line in content.splitlines():
|
||||||
if not line.strip() or not line.startswith("{"):
|
idx = line.find("{")
|
||||||
|
if idx == -1:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
data = json.loads(line)
|
data = json.loads(line[idx:])
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
continue
|
continue
|
||||||
if data.get("event") != "request.received.openai":
|
if data.get("event") != "request.received.openai":
|
||||||
|
|||||||
@@ -64,8 +64,13 @@ class TestSchedulerStatusLogger(CustomTestCase):
|
|||||||
def _find_log_events(log_dir: str, event_name: str):
|
def _find_log_events(log_dir: str, event_name: str):
|
||||||
for f in Path(log_dir).glob("*.log"):
|
for f in Path(log_dir).glob("*.log"):
|
||||||
for line in f.read_text().splitlines():
|
for line in f.read_text().splitlines():
|
||||||
if line.startswith("{"):
|
idx = line.find("{")
|
||||||
data = json.loads(line)
|
if idx == -1:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
data = json.loads(line[idx:])
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
continue
|
||||||
if data.get("event") == event_name:
|
if data.get("event") == event_name:
|
||||||
yield data
|
yield data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user