Commit 52d3771
Restore configuration after vxlan module (#18714)
What is the motivation for this PR?
Move the configuration restoration from each test case level to the common conftest.py which is module level.
It also saves time to do config reload one by one, each config reload may take 5 mins.
Module level configuration restore is more reasonable.
How did you do it?
Call the existing function backup_and_restore_config_db_on_duts in conftest.py and do config reload after config_db.json restoration.
Make sure if vxlan module run, the configuration will be restored after the test.
How did you verify/test it?
Run test_vxlan_crm on dut and check the log.
Backup config file before running tests
29/05/2025 08:48:01 conftest.restore_config_by_config_reload L0356 INFO | Prepare backup config before running tests
29/05/2025 08:48:01 duthost_utils._backup_and_restore_config L0043 INFO | Backup /etc/sonic/config_db.json to /host/config_db.json.before_test_module on <bound method DutHosts._Nodes._run_on_nodes of [<MultiAsicSonicHost bjw2-can-8101-2>]>
29/05/2025 08:48:01 base._run L0071 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell, args=["cp /etc/sonic/config_db.json /host/config_db.json.before_test_module"], kwargs={}
29/05/2025 08:48:02 base._run L0108 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell Result => {"changed": true, "stdout": "", "stderr": "", "rc": 0, "cmd": "cp /etc/sonic/config_db.json /host/config_db.json.before_test_module", "start": "2025-05-29 08:48:02.236422", "end": "2025-05-29 08:48:02.242861", "delta": "0:00:00.006439", "msg": "", "invocation": {"module_args": {"_raw_params": "cp /etc/sonic/config_db.json /host/config_db.json.before_test_module", "_uses_shell": true, "warn": false, "stdin_add_newline": true, "strip_empty_ends": true, "argv": null, "chdir": null, "executable": null, "creates": null, "removes": null, "stdin": null}}, "stdout_lines": [], "stderr_lines": [], "_ansible_no_log": null, "failed": false}
Restore configuration file, then do config reload after running tests
29/05/2025 09:24:15 conftest.restore_config_by_config_reload L0359 INFO | Restore config after running tests
29
9/05/2025 09:24:15 __init__._fixture_generator_decorator L0102 INFO | -------------------- fixture fixture_setUp teardown ends --------------------
29/05/2025 09:24:15 duthost_utils._backup_and_restore_config L0049 INFO | Restore /etc/sonic/config_db.json with /host/config_db.json.before_test_module on <bound method DutHosts._Nodes._run_on_nodes of [<MultiAsicSonicHost bjw2-can-8101-2>]>
29/05/2025 09:24:15 base._run L0071 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell, args=["mv /host/config_db.json.before_test_module /etc/sonic/config_db.json"], kwargs={}
29/05/2025 09:24:15 base._run L0108 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell Result => {"changed": true, "stdout": "", "stderr": "", "rc": 0, "cmd": "mv /host/config_db.json.before_test_module /etc/sonic/config_db.json", "start": "2025-05-29 09:24:15.369677", "end": "2025-05-29 09:24:15.374489", "delta": "0:00:00.004812", "msg": "", "invocation": {"module_args": {"_raw_params": "mv /host/config_db.json.before_test_module /etc/sonic/config_db.json", "_uses_shell": true, "warn": false, "stdin_add_newline": true, "strip_empty_ends": true, "argv": null, "chdir": null, "executable": null, "creates": null, "removes": null, "stdin": null}}, "stdout_lines": [], "stderr_lines": [], "_ansible_no_log": null, "failed": false}
29/05/2025 09:24:15 conftest.restore_config_by_config_reload L0359 INFO | Restore config after running tests
29/05/2025 09:24:15 config_reload.config_reload L0145 INFO | reloading config_db
29/05/2025 09:24:15 base._run L0071 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell, args=["config reload -h"], kwargs={"executable": "/bin/bash"}
29/05/2025 09:24:17 base._run L0108 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell Result => {"changed": true, "stdout": "Usage: config reload [OPTIONS] [FILENAME]\n\n Clear current configuration and import a previous saved config DB dump\n file. <filename> : Names of configuration file(s) to load, separated by\n comma with no spaces in between\n\nOptions:\n -y, --yes\n -l, --load-sysinfo load system default information (mac,\n portmap etc) first.\n -n, --no_service_restart Do not restart docker services\n -f, --force Force config reload without system checks\n -t, --file_format [config_yang|config_db]\n specify the file format [default:\n config_db]\n -b, --bypass-lock Do reload without acquiring lock\n -h, -?, --help Show this message and exit.", "stderr": "", "rc": 0, "cmd": "config reload -h", "start": "2025-05-29 09:24:15.830852", "end": "2025-05-29 09:24:17.219753", "delta": "0:00:01.388901", "msg": "", "invocation": {"module_args": {"executable": "/bin/bash", "_raw_params": "config reload -h", "_uses_shell": true, "warn": false, "stdin_add_newline": true, "strip_empty_ends": true, "argv": null, "chdir": null, "creates": null, "removes": null, "stdin": null}}, "stdout_lines": ["Usage: config reload [OPTIONS] [FILENAME]", "", " Clear current configuration and import a previous saved config DB dump", " file. <filename> : Names of configuration file(s) to load, separated by", " comma with no spaces in between", "", "Options:", " -y, --yes", " -l, --load-sysinfo load system default information (mac,", " portmap etc) first.", " -n, --no_service_restart Do not restart docker services", " -f, --force Force config reload without system checks", " -t, --file_format [config_yang|config_db]", " specify the file format [default:", " config_db]", " -b, --bypass-lock Do reload without acquiring lock", " -h, -?, --help Show this message and exit."], "stderr_lines": [], "_ansible_no_log": null, "failed": false}
29/05/2025 09:24:47 base._run L0071 DEBUG | /data/sonic-mgmt-int/tests/common/devices/multi_asic.py::_run_on_asics#136: [bjw2-can-8101-2] AnsibleModule::shell, args=["config reload -y -f &>/dev/null"], kwargs={"executable": "/bin/bash"}
29/05/2025 09:25:28 base._run L01 parent 3d0922f commit 52d3771
File tree
3 files changed
+14
-25
lines changed- tests/vxlan
3 files changed
+14
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
310 | | - | |
| 312 | + | |
311 | 313 | | |
312 | 314 | | |
313 | 315 | | |
| |||
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | | - | |
74 | | - | |
| 72 | + | |
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
| |||
233 | 231 | | |
234 | 232 | | |
235 | 233 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | 234 | | |
245 | 235 | | |
246 | 236 | | |
247 | 237 | | |
248 | 238 | | |
249 | 239 | | |
250 | 240 | | |
251 | | - | |
| 241 | + | |
252 | 242 | | |
253 | 243 | | |
254 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
145 | | - | |
146 | | - | |
| 143 | + | |
147 | 144 | | |
148 | 145 | | |
149 | 146 | | |
| |||
342 | 339 | | |
343 | 340 | | |
344 | 341 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | 342 | | |
354 | 343 | | |
355 | 344 | | |
| |||
0 commit comments