Skip to content

Commit

Permalink
Check for determine-reboot-cause service status (#14607)
Browse files Browse the repository at this point in the history
* Check for determine-reboot-cause service status

* Remove additional step to check dmesg for errors
  • Loading branch information
vvolam authored Oct 18, 2024
1 parent bc5e7e3 commit c3544f4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/common/reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,23 @@ def check_reboot_cause_history(dut, reboot_type_history_queue):
logger.error("The number of expected reboot-cause:{} is more than that of actual reboot-cuase:{}".format(
reboot_type_history_len, len(reboot_type_history_queue)))
return False


def check_determine_reboot_cause_service(dut):
"""
@summary: This function verifies the status of the 'determine-reboot-cause' service on the device under test (DUT).
It checks the service's ActiveState and SubState using systemctl.
@param dut: The AnsibleHost object of DUT.
"""
# Check the 'determine-reboot-cause' service status
logger.info("Checking 'determine-reboot-cause' service status using systemctl")
service_state = dut.get_service_props("determine-reboot-cause.service")

# Validate service is active
active_state = service_state.get("ActiveState", "")
sub_state = service_state.get("SubState", "")
logger.info(f"'determine-reboot-cause' ActiveState: {active_state}, SubState: {sub_state}")

assert active_state == "active", f"Service 'determine-reboot-cause' is not active. Current state: {active_state}"
assert sub_state == "exited", f"Service 'determine-reboot-cause' did not exit cleanly. \
Current sub-state: {sub_state}"
12 changes: 10 additions & 2 deletions tests/platform_tests/test_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from tests.common.fixtures.conn_graph_facts import conn_graph_facts # noqa F401
from tests.common.utilities import wait_until, get_plt_reboot_ctrl
from tests.common.reboot import sync_reboot_history_queue_with_dut, reboot, check_reboot_cause,\
check_reboot_cause_history, reboot_ctrl_dict, wait_for_startup,\
REBOOT_TYPE_HISTOYR_QUEUE, REBOOT_TYPE_COLD,\
check_reboot_cause_history, check_determine_reboot_cause_service, reboot_ctrl_dict,\
wait_for_startup, REBOOT_TYPE_HISTOYR_QUEUE, REBOOT_TYPE_COLD,\
REBOOT_TYPE_SOFT, REBOOT_TYPE_FAST, REBOOT_TYPE_WARM, REBOOT_TYPE_WATCHDOG
from tests.common.platform.transceiver_utils import check_transceiver_basic
from tests.common.platform.interface_utils import check_all_interface_information, get_port_map
Expand Down Expand Up @@ -149,6 +149,14 @@ def check_interfaces_and_services(dut, interfaces, xcvr_skip_list,
check_sysfs(dut)

if reboot_type is not None:
logging.info("Check the determine-reboot-cause service")
os_version = dut.os_version.split(".")[0]
if os_version < "202106":
logging.info("DUT has OS version {}, skip the check determine-reboot-cause service \
for release before 202106" .format(os_version))
else:
check_determine_reboot_cause_service(dut)

logging.info("Check reboot cause")
assert wait_until(MAX_WAIT_TIME_FOR_REBOOT_CAUSE, 20, 30, check_reboot_cause, dut, reboot_type), \
"got reboot-cause failed after rebooted by %s" % reboot_type
Expand Down

0 comments on commit c3544f4

Please sign in to comment.