Skip to content

Commit

Permalink
Improvising pre_checks for test_reload config (sonic-net#7953)
Browse files Browse the repository at this point in the history
* Fix for test_config_reload.py_Retry later error within a short interval after reboot, by adding a flag, by default we overwrite with plt_reboot_ctrl in inventory, this test does not overwrite, keep small interval
* Adding checks for system up before config_reload is initiated
* change to run on every sku

---------

Co-authored-by: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com>
  • Loading branch information
2 people authored and AharonMalkin committed Jan 25, 2024
1 parent 7641e4c commit 17403f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
9 changes: 5 additions & 4 deletions tests/common/reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def execute_reboot_helper():

def reboot(duthost, localhost, reboot_type='cold', delay=10,
timeout=0, wait=0, wait_for_ssh=True, wait_warmboot_finalizer=False, warmboot_finalizer_timeout=0,
reboot_helper=None, reboot_kwargs=None):
reboot_helper=None, reboot_kwargs=None, plt_reboot_ctrl_overwrite=True):
"""
reboots DUT
:param duthost: DUT host object
Expand All @@ -221,9 +221,10 @@ def reboot(duthost, localhost, reboot_type='cold', delay=10,
timeout = reboot_ctrl['timeout']
if wait == 0:
wait = reboot_ctrl['wait']
if plt_reboot_ctrl:
wait = plt_reboot_ctrl['wait']
timeout = plt_reboot_ctrl['timeout']
if plt_reboot_ctrl_overwrite and plt_reboot_ctrl:
# get 'wait' and 'timeout' from inventory if they are specified, otherwise use current values
wait = plt_reboot_ctrl.get('wait', wait)
timeout = plt_reboot_ctrl.get('timeout', timeout)
if warmboot_finalizer_timeout == 0 and 'warmboot_finalizer_timeout' in reboot_ctrl:
warmboot_finalizer_timeout = reboot_ctrl['warmboot_finalizer_timeout']
except KeyError:
Expand Down
16 changes: 11 additions & 5 deletions tests/platform_tests/test_reload_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
]


def test_reload_configuration(duthosts, rand_one_dut_hostname, conn_graph_facts, xcvr_skip_list): # noqa F811
def test_reload_configuration(duthosts, enum_rand_one_per_hwsku_hostname,
conn_graph_facts, xcvr_skip_list): # noqa F811
"""
@summary: This test case is to reload the configuration and check platform status
"""
duthost = duthosts[rand_one_dut_hostname]
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
interfaces = conn_graph_facts["device_conn"][duthost.hostname]
asic_type = duthost.facts["asic_type"]

Expand Down Expand Up @@ -78,17 +79,18 @@ def check_database_status(duthost):
return True


def test_reload_configuration_checks(duthosts, rand_one_dut_hostname,
def test_reload_configuration_checks(duthosts, enum_rand_one_per_hwsku_hostname,
localhost, conn_graph_facts, xcvr_skip_list): # noqa F811
"""
@summary: This test case is to test various system checks in config reload
"""
duthost = duthosts[rand_one_dut_hostname]
duthost = duthosts[enum_rand_one_per_hwsku_hostname]

if not config_force_option_supported(duthost):
return

reboot(duthost, localhost, reboot_type="cold", wait=5)
reboot(duthost, localhost, reboot_type="cold", wait=5,
plt_reboot_ctrl_overwrite=False)

# Check if all database containers have started
wait_until(60, 1, 0, check_database_status, duthost)
Expand All @@ -110,6 +112,10 @@ def test_reload_configuration_checks(duthosts, rand_one_dut_hostname,

# Immediately after one config reload command, another shouldn't execute and wait for system checks
logging.info("Checking config reload after system is up")
# Check if all database containers have started
wait_until(60, 1, 0, check_database_status, duthost)
# Check if interfaces-config.service is exited
wait_until(60, 1, 0, check_interfaces_config_service_status, duthost)
out = duthost.shell("sudo config reload -y",
executable="/bin/bash", module_ignore_errors=True)
assert "Retry later" in out['stdout']
Expand Down

0 comments on commit 17403f6

Please sign in to comment.