Skip to content
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

[action] [PR:11223] Config bgp bbr by GCU cmd in test_bgp_bbr test #11248

Merged
merged 1 commit into from
Jan 11, 2024
Merged
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
72 changes: 68 additions & 4 deletions tests/bgp/test_bgp_bbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from tests.common.helpers.parallel import reset_ansible_local_tmp
from tests.common.helpers.parallel import parallel_run
from tests.common.utilities import wait_until, delete_running_config
from tests.generic_config_updater.gu_utils import apply_patch, expect_op_success
from tests.generic_config_updater.gu_utils import generate_tmpfile, delete_tmpfile


pytestmark = [
Expand Down Expand Up @@ -59,16 +61,74 @@ def bbr_default_state(setup):
return setup['bbr_default_state']


def add_bbr_config_to_running_config(duthost, status):
logger.info('Add BGP_BBR config to running config')
json_patch = [
{
"op": "add",
"path": "/BGP_BBR",
"value": {
"all": {
"status": "{}".format(status)
}
}
}
]

tmpfile = generate_tmpfile(duthost)
logger.info("tmpfile {}".format(tmpfile))

try:
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
expect_op_success(duthost, output)
finally:
delete_tmpfile(duthost, tmpfile)

time.sleep(3)


def config_bbr_by_gcu(duthost, status):
logger.info('Config BGP_BBR by GCU cmd')
json_patch = [
{
"op": "replace",
"path": "/BGP_BBR/all/status",
"value": "{}".format(status)
}
]

tmpfile = generate_tmpfile(duthost)
logger.info("tmpfile {}".format(tmpfile))

try:
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
expect_op_success(duthost, output)
finally:
delete_tmpfile(duthost, tmpfile)

time.sleep(3)


def enable_bbr(duthost, namespace):
logger.info('Enable BGP_BBR')
duthost.shell('sonic-cfggen {} -j /tmp/enable_bbr.json -w '.format('-n ' + namespace if namespace else ''))
time.sleep(3)
# gcu doesn't support multi-asic for now, use sonic-cfggen instead
if namespace:
logger.info('Enable BGP_BBR in namespace {}'.format(namespace))
duthost.shell('sonic-cfggen {} -j /tmp/enable_bbr.json -w '.format('-n ' + namespace))
time.sleep(3)
else:
config_bbr_by_gcu(duthost, "enabled")


def disable_bbr(duthost, namespace):
logger.info('Disable BGP_BBR')
duthost.shell('sonic-cfggen {} -j /tmp/disable_bbr.json -w'.format('-n ' + namespace if namespace else ''))
time.sleep(3)
# gcu doesn't support multi-asic for now, use sonic-cfggen instead
if namespace:
logger.info('Disable BGP_BBR in namespace {}'.format(namespace))
duthost.shell('sonic-cfggen {} -j /tmp/disable_bbr.json -w '.format('-n ' + namespace))
time.sleep(3)
else:
config_bbr_by_gcu(duthost, "disabled")


@pytest.fixture
Expand Down Expand Up @@ -173,6 +233,10 @@ def setup(duthosts, rand_one_dut_hostname, tbinfo, nbrhosts):
'bbr_route_v6_dual_dut_asn': bbr_route_v6_dual_dut_asn
}

if not setup_info['tor1_namespace']:
logger.info('non multi-asic environment, add bbr config to running config using gcu cmd')
add_bbr_config_to_running_config(duthost, bbr_default_state)

logger.info('setup_info: {}'.format(json.dumps(setup_info, indent=2)))

return setup_info
Expand Down