[MASIC] Make test_bgp_bounce.py support for multi-asic platforms#5723
[MASIC] Make test_bgp_bounce.py support for multi-asic platforms#5723wenyiz2021 merged 24 commits intomasterfrom
Conversation
To support multi-asic on test_bgp_bounce.py
Move restart_bgp() from bgp_helpers.py to multi_asic.py, to make it work for multi-asic device.
tests/common/devices/multi_asic.py
Outdated
| container_name += str(asic_id) | ||
| self.shell("sudo docker cp {}:{} {}".format(container_name, src, dst)) | ||
|
|
||
| def restart_bgp(self): |
There was a problem hiding this comment.
why do we need to do reset_service every time ? Normally we need reset services only if services is not running properly
There was a problem hiding this comment.
This is refactored from original code, should I remove it?
tests/bgp/bgp_helpers.py
Outdated
| else: | ||
| pytest_assert(wait_until(100, 10, 0, duthost.is_service_fully_started, "bgp"), "BGP not started.") | ||
|
|
||
| def restart_bgp(duthost, asic_index=DEFAULT_ASIC_ID): |
There was a problem hiding this comment.
in this file in some places we use restart_bgp and in some places we use duthost.restart_bgp. Can we use one function everywhere
There was a problem hiding this comment.
I have thought of this, is it ok to check is_fully_started inside multi_asic.py or need to make it in bgp_helpers.py each time?
There was a problem hiding this comment.
PR updated, can you please review gain?
Change restart_bgp_on_asic to restart_service_on_asic to make it more flexible to call
Change restart_bgp_on_asic to restart_service_on_asic
|
This pull request introduces 1 alert when merging 1a2b810 into 901ca59 - view on LGTM.com new alerts:
|
tests/bgp/bgp_helpers.py
Outdated
| if duthost.is_multi_asic: | ||
| for asic_index in range(duthost.facts["num_asic"]): | ||
| docker_name = duthost.asic_instance(asic_index).get_docker_name("bgp") | ||
| pytest_assert(wait_until(100, 10, 0, duthost.is_service_fully_started, docker_name), "BGP not started.") | ||
| else: | ||
| pytest_assert(wait_until(100, 10, 0, duthost.is_service_fully_started, "bgp"), "BGP not started.") | ||
|
|
There was a problem hiding this comment.
Can we add this block as function in multi_asic.py ?
There was a problem hiding this comment.
in multi_asic.py it is calling itself or the function in sonic_asic.py, to achieve that will need to add assert in the 2 restart_service() in the 2 files, but other functions do not have these checks, wonder if it is needed here?
def restart_service(self, service):
if service in self._DEFAULT_SERVICES:
return self.sonichost.restart_service(service, service)
for asic in self.asics:
asic.restart_service(service)
There was a problem hiding this comment.
if we want pyassert as original design, looks like assert in this file is a better solution.
Call is_service_fully_started_per_asic_or_host in pyassert
|
This pull request introduces 1 alert when merging 5d4c47c into a0c926b - view on LGTM.com new alerts:
|
For test introduced from #2866, test_bgp_bounce.py calls 'docker cp' cmd from host to bgp(s), via bgp_helpers.py, which does not consider multi-asic scenario, where we want to copy bgp config files to all BGPs. This PR does the following change: 1. For multi-asic, copy to all BGPs, as well as restart all BGPs and make sure all BGPs come back. For single-asic remains the same behavior. 2. Add restart_bgp() in multi_asic.py to do consideration for multi-asic/single-asic all in this file, and leave the wait_until() in bgp_helpers.py to let know if all BGPs are back up. 3. Original restart_bgp(asic_index) moved to restart_service_on_asic in multi_asic.py to work on one asic. How did you verify/test it? ./run_tests.sh-n {multi_asic testbed} -i ../ansible/xxx,../ansible/veos -f ../ansible/testbed.csv -u -e "--skip_sanity --disable_loganalyzer" -c bgp/test_bgp_bounce.py
Description of PR
for test introduced from #2866, test_bgp_bounce.py calls 'docker cp' cmd from host to bgp(s), via bgp_helpers.py, which does not consider multi-asic scenario, where we want to copy bgp config files to all BGPs.
This PR does the following change:
Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
Support test_bgp_bounce.py on multi-asic platform and some refactor.
How did you do it?
under sonic-mgmt/tests, do:
./run_tests.sh-n {multi_asic testbed} -i ../ansible/xxx,../ansible/veos -f ../ansible/testbed.csv -u -e "--skip_sanity --disable_loganalyzer" -c bgp/test_bgp_bounce.py
How did you verify/test it?
Before:
2022-05-13T02:18:37.5367742Z E "stderr": "Error: No such container:path: bgp:/usr/share/sonic/templates/bgpd/bgpd.conf.j2",
2022-05-13T02:18:37.5370441Z E "stderr_lines": [
2022-05-13T02:18:37.5373090Z E "Error: No such container:path: bgp:/usr/share/sonic/templates/bgpd/bgpd.conf.j2"
2022-05-13T02:18:37.5375680Z E ],
After:
bgp/test_bgp_bounce.py::test_bgp_bounce PASSED [ 10%]
metadata-scripts/test_metadata_upgrade_path.py::test_cancelled_upgrade_path[warm-svcstr-n-acs-1] SKIPPED [ 20%]
metadata-scripts/test_metadata_upgrade_path.py::test_upgrade_path[warm-svcstr-n-acs-1] SKIPPED [ 30%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-sad-svcstr-n-acs-1] SKIPPED [ 40%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-multi_sad-svcstr-n-acs-1] SKIPPED [ 50%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-sad_bgp-svcstr-n-acs-1] SKIPPED [ 60%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-sad_lag_member-svcstr-n-acs-1] SKIPPED [ 70%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-sad_lag-svcstr-n-acs-1] SKIPPED [ 80%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-sad_vlan_port-svcstr-n=-acs-1] SKIPPED [ 90%]
metadata-scripts/test_metadata_upgrade_path.py::test_warm_upgrade_sad_path[warm-sad_inboot-svcstr-n-acs-1] SKIPPED [100%]
--------------------------------------------------------------------------------------------- generated xml file: /var/src/sonic-mgmt-int/tests/logs/tr.xml ----------------------------------------------------------------------------------------------
================================================================================================================ short test summary info =================================================================================================================
SKIPPED [9] /var/src/sonic-mgmt-int/tests/metadata-scripts/test_metadata_upgrade_path.py:39: base_image_list or target_image_list is empty
========================================================================================================= 1 passed, 9 skipped in 369.93 seconds ==========================================================================================================
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation