Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify_serial_console_is_enabled: Verify tty0 in journalctl log #2865

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lisa/tools/journalctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ def logs_for_unit(self, unit_name: str, sudo: bool = True) -> str:
)

return result.stdout

def first_n_logs_from_boot(self, boot_id: str = "", no_of_lines: int = 1000) -> str:
result = self.run(
f"-b {boot_id} | head -n {no_of_lines} ",
force_run=True,
shell=True,
sudo=True,
expected_exit_code=0,
)
return result.stdout
16 changes: 12 additions & 4 deletions microsoft/testsuites/core/azure_image_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)
from lisa.sut_orchestrator import AZURE, READY
from lisa.sut_orchestrator.azure.features import AzureDiskOptionSettings
from lisa.tools import Cat, Dmesg, Ls, Lsblk, Lscpu, Pgrep, Ssh
from lisa.tools import Cat, Dmesg, Journalctl, Ls, Lsblk, Lscpu, Pgrep, Ssh
from lisa.util import (
LisaException,
PassedException,
Expand Down Expand Up @@ -763,17 +763,25 @@ def verify_serial_console_is_enabled(self, node: Node) -> None:
isinstance(node.os, Ubuntu) and node.os.information.version >= "22.10.0"
):
log_output = node.tools[Dmesg].get_output()
log_file = "dmesg"
else:
cat = node.tools[Cat]
if node.shell.exists(node.get_pure_path("/var/log/messages")):
log_file = "/var/log/messages"
log_output = cat.read(log_file, force_run=True, sudo=True)
elif node.shell.exists(node.get_pure_path("/var/log/syslog")):
log_file = "/var/log/syslog"
log_output = cat.read(log_file, force_run=True, sudo=True)
else:
log_file = "journalctl"
journalctl = node.tools[Journalctl]
log_output = journalctl.first_n_logs_from_boot()
if not log_output:
raise LisaException(
"Neither /var/log/messages nor /var/log/syslog found"
"Neither /var/log/messages nor /var/log/syslog found."
"and journal ctl log is empty."
)
cat = node.tools[Cat]
log_output = cat.read(log_file, force_run=True, sudo=True)

lscpu = node.tools[Lscpu]
arch = lscpu.get_architecture()
current_console_device = console_device[CpuArchitecture(arch)]
Expand Down
Loading