|
1 | 1 | import time
|
2 | 2 | import logging
|
3 | 3 |
|
| 4 | +from tests.common.helpers.assertions import pytest_assert |
| 5 | +from tests.common.utilities import wait_until |
| 6 | + |
4 | 7 | logger = logging.getLogger(__name__)
|
5 | 8 |
|
6 | 9 | config_sources = ['config_db', 'minigraph']
|
@@ -36,7 +39,7 @@ def config_force_option_supported(duthost):
|
36 | 39 | return True
|
37 | 40 | return False
|
38 | 41 |
|
39 |
| -def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True, start_dynamic_buffer=True): |
| 42 | +def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True, start_dynamic_buffer=True, safe_reload=False): |
40 | 43 | """
|
41 | 44 | reload SONiC configuration
|
42 | 45 | :param duthost: DUT host object
|
@@ -77,4 +80,15 @@ def config_reload(duthost, config_source='config_db', wait=120, start_bgp=True,
|
77 | 80 | modular_chassis = duthost.get_facts().get("modular_chassis")
|
78 | 81 | wait = max(wait, 240) if modular_chassis else wait
|
79 | 82 |
|
80 |
| - time.sleep(wait) |
| 83 | + if safe_reload: |
| 84 | + # The wait time passed in might not be guaranteed to cover the actual |
| 85 | + # time it takes for containers to come back up. Therefore, add 5 |
| 86 | + # minutes to the maximum wait time. If it's ready sooner, then the |
| 87 | + # function will return sooner. |
| 88 | + pytest_assert(wait_until(wait + 300, 20, 0, duthost.critical_services_fully_started), |
| 89 | + "All critical services should be fully started!") |
| 90 | + if config_source == 'minigraph': |
| 91 | + pytest_assert(wait_until(300, 20, 0, chk_for_pfc_wd, duthost), |
| 92 | + "PFC_WD is missing in CONFIG-DB") |
| 93 | + else: |
| 94 | + time.sleep(wait) |
0 commit comments