Skip to content

[MASIC] Make test_bgp_bounce.py support for multi-asic platforms#5723

Merged
wenyiz2021 merged 24 commits intomasterfrom
bgp_bounce
Jun 3, 2022
Merged

[MASIC] Make test_bgp_bounce.py support for multi-asic platforms#5723
wenyiz2021 merged 24 commits intomasterfrom
bgp_bounce

Conversation

@wenyiz2021
Copy link
Copy Markdown
Contributor

@wenyiz2021 wenyiz2021 commented May 26, 2022

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:

  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.

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012

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

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.
container_name += str(asic_id)
self.shell("sudo docker cp {}:{} {}".format(container_name, src, dst))

def restart_bgp(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to do reset_service every time ? Normally we need reset services only if services is not running properly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is refactored from original code, should I remove it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR updated, can you please review gain?

@wenyiz2021 wenyiz2021 requested a review from arlakshm May 27, 2022 19:48
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
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented May 27, 2022

This pull request introduces 1 alert when merging 1a2b810 into 901ca59 - view on LGTM.com

new alerts:

  • 1 for Unused import

Comment on lines +35 to +41
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.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this block as function in multi_asic.py ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want pyassert as original design, looks like assert in this file is a better solution.

@wenyiz2021 wenyiz2021 requested a review from arlakshm May 31, 2022 20:56
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jun 1, 2022

This pull request introduces 1 alert when merging 5d4c47c into a0c926b - view on LGTM.com

new alerts:

  • 1 for Unused import

@wenyiz2021 wenyiz2021 merged commit 0b86347 into master Jun 3, 2022
@wenyiz2021 wenyiz2021 deleted the bgp_bounce branch June 3, 2022 23:43
wangxin pushed a commit that referenced this pull request Jun 7, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants