From 607cc90bb30d619440e0ca13789ea2d79931b7fc Mon Sep 17 00:00:00 2001 From: Drew Newberry Date: Thu, 19 Mar 2026 13:19:51 -0700 Subject: [PATCH] fix(e2e): update log-reading helpers for rolling file appender (#480) The rolling file appender introduced in PR #431 writes date-stamped files (openshell.YYYY-MM-DD.log) instead of a single openshell.log. Update _read_openshell_log() and _verify_sandbox_functional() to glob for all matching log files so the tests work with both layouts. Signed-off-by: Drew Newberry --- e2e/python/test_sandbox_policy.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/e2e/python/test_sandbox_policy.py b/e2e/python/test_sandbox_policy.py index 25d70359..fdb8a1d0 100644 --- a/e2e/python/test_sandbox_policy.py +++ b/e2e/python/test_sandbox_policy.py @@ -168,14 +168,25 @@ def fn(host, port, method="GET", path="/"): def _read_openshell_log(): - """Return a closure that reads the openshell log file.""" + """Return a closure that reads the openshell log file(s). + + Since the sandbox uses a rolling file appender, logs are written to + date-stamped files like ``/var/log/openshell.YYYY-MM-DD.log`` instead + of a single ``/var/log/openshell.log``. This helper globs for all + matching files so tests work with both the legacy and rolling layouts. + """ def fn(): - try: - with open("/var/log/openshell.log") as f: - return f.read() - except FileNotFoundError: - return "" + import glob + + logs = [] + for path in sorted(glob.glob("/var/log/openshell*.log*")): + try: + with open(path) as f: + logs.append(f.read()) + except (FileNotFoundError, PermissionError): + pass + return "\n".join(logs) return fn @@ -1542,8 +1553,10 @@ def fn(): os.unlink(sb_path) except Exception as e: checks["sandbox_write"] = str(e) - # Can read openshell log - checks["var_log"] = os.path.exists("/var/log/openshell.log") + # Can read openshell log (rolling appender writes date-stamped files) + import glob + + checks["var_log"] = len(glob.glob("/var/log/openshell*.log*")) > 0 return json.dumps(checks) return fn