Skip to content

Commit de9dcaa

Browse files
authored
fix(e2e): update log-reading helpers for rolling file appender (#480) (#481)
1 parent 564c411 commit de9dcaa

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

e2e/python/test_sandbox_policy.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,25 @@ def fn(host, port, method="GET", path="/"):
168168

169169

170170
def _read_openshell_log():
171-
"""Return a closure that reads the openshell log file."""
171+
"""Return a closure that reads the openshell log file(s).
172+
173+
Since the sandbox uses a rolling file appender, logs are written to
174+
date-stamped files like ``/var/log/openshell.YYYY-MM-DD.log`` instead
175+
of a single ``/var/log/openshell.log``. This helper globs for all
176+
matching files so tests work with both the legacy and rolling layouts.
177+
"""
172178

173179
def fn():
174-
try:
175-
with open("/var/log/openshell.log") as f:
176-
return f.read()
177-
except FileNotFoundError:
178-
return ""
180+
import glob
181+
182+
logs = []
183+
for path in sorted(glob.glob("/var/log/openshell*.log*")):
184+
try:
185+
with open(path) as f:
186+
logs.append(f.read())
187+
except (FileNotFoundError, PermissionError):
188+
pass
189+
return "\n".join(logs)
179190

180191
return fn
181192

@@ -1542,8 +1553,10 @@ def fn():
15421553
os.unlink(sb_path)
15431554
except Exception as e:
15441555
checks["sandbox_write"] = str(e)
1545-
# Can read openshell log
1546-
checks["var_log"] = os.path.exists("/var/log/openshell.log")
1556+
# Can read openshell log (rolling appender writes date-stamped files)
1557+
import glob
1558+
1559+
checks["var_log"] = len(glob.glob("/var/log/openshell*.log*")) > 0
15471560
return json.dumps(checks)
15481561

15491562
return fn

0 commit comments

Comments
 (0)