Skip to content

Add an option to do a safe config reload #5374

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

Merged
merged 3 commits into from
Apr 4, 2022
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
1 change: 0 additions & 1 deletion tests/arp/test_neighbor_mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time

from tests.common.helpers.assertions import pytest_assert
from tests.common.config_reload import config_reload

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/arp/test_neighbor_mac_noptf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def setupDutConfig(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
yield

logger.info("Reload Config DB")
config_reload(duthost, config_source='config_db', wait=120)
config_reload(duthost, config_source='config_db', safe_reload=True)

@pytest.fixture(params=[4, 6])
def ipVersion(self, request):
Expand Down
2 changes: 1 addition & 1 deletion tests/cacl/test_cacl_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def clean_scale_rules(duthosts, rand_one_dut_hostname, collect_ignored_rules):
# delete the tmp file
duthost.file(path=SCALE_ACL_FILE, state='absent')
logger.info("Reload config to recover configuration.")
config_reload(duthost)
config_reload(duthost, safe_reload=True)

def is_acl_rule_empty(duthost):
"""
Expand Down
18 changes: 16 additions & 2 deletions tests/common/config_reload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import time
import logging

from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import wait_until

logger = logging.getLogger(__name__)

config_sources = ['config_db', 'minigraph']
Expand Down Expand Up @@ -36,7 +39,7 @@ def config_force_option_supported(duthost):
return True
return False

def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True, start_dynamic_buffer=True):
def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True, start_dynamic_buffer=True, safe_reload=False):
"""
reload SONiC configuration
:param duthost: DUT host object
Expand Down Expand Up @@ -77,4 +80,15 @@ def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True,
modular_chassis = duthost.get_facts().get("modular_chassis")
wait = max(wait, 240) if modular_chassis else wait

time.sleep(wait)
if safe_reload:
# The wait time passed in might not be guaranteed to cover the actual
# time it takes for containers to come back up. Therefore, add 5
# minutes to the maximum wait time. If it's ready sooner, then the
# function will return sooner.
pytest_assert(wait_until(wait + 300, 20, 0, duthost.critical_services_fully_started),
"All critical services should be fully started!")
if config_source == 'minigraph':
pytest_assert(wait_until(300, 20, 0, chk_for_pfc_wd, duthost),
"PFC_WD is missing in CONFIG-DB")
else:
time.sleep(wait)