|
| 1 | +import os |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from lib.commands import ssh |
| 6 | + |
| 7 | +# tests meant to check system logs for error right after installation |
| 8 | +# (not after other tests which may willingly cause such errors) |
| 9 | + |
| 10 | +@pytest.mark.parametrize("logfile", ("xensource.log", "daemon.log", "SMlog")) |
| 11 | +def test_logs(host, logfile): |
| 12 | + LOGFILE = os.path.join("/var/log", logfile) |
| 13 | + |
| 14 | + result = host.ssh(["grep -B1 -Ei 'error|fail|fatal|critical|No such file'", LOGFILE], |
| 15 | + check=False, simple_output=False) |
| 16 | + assert result.returncode in (0, 1), "error in 'ssh grep'" |
| 17 | + # assert result.returncode == 1, f"Errors in {logfile}, see debug output" |
| 18 | + assert result.returncode == 0, f"It is NOT NORMAL AT ALL to have no error in {logfile}" |
| 19 | + |
| 20 | +# FIXME too many false positives to be a real test, essentially useful |
| 21 | +# to get the matches extracted and archived for manual verification |
| 22 | +def test_install_logs(host): |
| 23 | + LOGFILE = "/var/log/installer/install-log" |
| 24 | + |
| 25 | + result = host.ssh(["grep -B1 -Ei 'error|fail|fatal|critical|No such file'", LOGFILE], |
| 26 | + check=False, simple_output=False) |
| 27 | + assert result.returncode in (0, 1), "error in 'ssh grep'" |
| 28 | + # assert result.returncode == 1, f"Errors in {LOGFILE}, see debug output" |
| 29 | + assert result.returncode == 0, f"It is NOT NORMAL AT ALL to have no error in {LOGFILE}" |
0 commit comments