Skip to content

Commit 3e91b51

Browse files
authored
Checking DMesg logs for Panics/Errors post test case execution (#3674)
* changes to check kernel errors using function call * assign default false to assert_kernel_error * addressing node reference issue * Adding kernel panic check as well in the after_case * Fixing Nox Null Item access error * Variable and Function Renaming with minor fixes * Fixing flake8 long line error
1 parent 64d6cef commit 3e91b51

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

lisa/node.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from lisa.nic import Nics, NicsBSD
2525
from lisa.operating_system import OperatingSystem
2626
from lisa.secret import add_secret
27-
from lisa.tools import Chmod, Df, Echo, Lsblk, Mkfs, Mount, Reboot, Uname, Wsl
27+
from lisa.tools import Chmod, Df, Dmesg, Echo, Lsblk, Mkfs, Mount, Reboot, Uname, Wsl
2828
from lisa.tools.mkfs import FileSystem
2929
from lisa.util import (
3030
ContextMixin,
@@ -110,6 +110,7 @@ def __init__(
110110
self._support_sudo: Optional[bool] = None
111111
self._is_dirty: bool = False
112112
self.capture_boot_time: bool = False
113+
self.assert_kernel_error_after_test: bool = False
113114
self.capture_azure_information: bool = False
114115
self.capture_kernel_config: bool = False
115116
self.has_checked_bash_prompt: bool = False
@@ -501,6 +502,12 @@ def get_information(self) -> Dict[str, str]:
501502

502503
return final_information
503504

505+
def check_kernel_error(self) -> None:
506+
# Check if the kernel is in a healthy state without errors or panics.
507+
dmesg = self.tools[Dmesg]
508+
dmesg.check_kernel_errors(force_run=True, throw_error=True)
509+
self.check_kernel_panic()
510+
504511
def expand_env_path(self, raw_path: str) -> str:
505512
echo = self.tools[Echo]
506513
result = echo.run(raw_path, shell=True)

lisa/platform_.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ def deploy_environment(self, environment: Environment) -> None:
195195
node.features = Features(node, self)
196196
node.capture_azure_information = platform_runbook.capture_azure_information
197197
node.capture_boot_time = platform_runbook.capture_boot_time
198+
node.assert_kernel_error_after_test = (
199+
platform_runbook.assert_kernel_error_after_test
200+
)
198201
node.capture_kernel_config = (
199202
platform_runbook.capture_kernel_config_information
200203
)

lisa/schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,8 @@ class Platform(TypedSchema, ExtendableSchemaMixin):
14441444
capture_azure_information: bool = False
14451445
# capture boot time info or not
14461446
capture_boot_time: bool = False
1447+
# to check if dmesg logs need to be analyzed after each test case
1448+
assert_kernel_error_after_test: bool = False
14471449
# capture kernel config info or not
14481450
capture_kernel_config_information: bool = False
14491451
capture_vm_information: bool = True

lisa/testsuite.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,11 @@ def __run_case(
856856
timeout=timeout,
857857
test_kwargs=test_kwargs,
858858
)
859+
if case_result.environment is not None:
860+
nodes = case_result.environment.nodes
861+
for node in nodes.list():
862+
if node.assert_kernel_error_after_test:
863+
node.check_kernel_error()
859864
case_result.set_status(TestStatus.PASSED, "")
860865
except Exception as identifier:
861866
case_result.handle_exception(exception=identifier, log=log)

0 commit comments

Comments
 (0)