From 1fe68833484c53d7453db5a300809422fed143c4 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Fri, 13 Sep 2024 15:17:54 +0200 Subject: [PATCH] WIP New test to check logs for errors --- tests/system/test_checklogs.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/system/test_checklogs.py diff --git a/tests/system/test_checklogs.py b/tests/system/test_checklogs.py new file mode 100644 index 000000000..8f8fb7061 --- /dev/null +++ b/tests/system/test_checklogs.py @@ -0,0 +1,25 @@ +import os + +import pytest + +from lib.commands import ssh + +# tests meant to check system logs for error right after installation +# (not after other tests which may willingly cause such errors) + +@pytest.mark.parametrize("logfile", ("xensource.log", "daemon.log", "SMlog")) +def test_logs(host, logfile): + LOGFILE = os.path.join("/var/log/installer", logfile) + + result = host.ssh(["grep -B1 -Ei 'error|fail|fatal|critical|No such file'", LOGFILE], + check=False, simple_output=False) + assert result.returncode == 0, f"Errors in {logfile}, see debug output" + +# FIXME too many false positives to be a real test, essentially useful +# to get the matches extracted and archived for manual verification +def test_install_logs(host): + LOGFILE = "/var/log/installer/install-log" + + result = host.ssh(["grep -B1 -Ei 'error|fail|fatal|critical|No such file'", LOGFILE], + check=False, simple_output=False) + assert result.returncode in (0, 1), "error in 'ssh grep'"