Skip to content

Commit

Permalink
WIP New test to check logs for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ydirson committed Sep 13, 2024
1 parent 7863b42 commit 7597b94
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/system/test_checklogs.py
Original file line number Diff line number Diff line change
@@ -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", logfile)

result = host.ssh(["grep -B1 -Ei 'error|fail|fatal|critical|No such file'", LOGFILE],
check=False, simple_output=False)
assert result.returncode == 1, 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'"

0 comments on commit 7597b94

Please sign in to comment.