Skip to content

Commit

Permalink
enhance restore_bgp_suppress_fib to check status first (#10612)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
In current test, it will set the bgp suppress to disabled no matter what's the value in the config_db. If it is enabled before the test, it should honor it, and don't change it after the test.
In this PR, will add a check logic to restore only it is needed.

How did you do it?
To read back the config db before test, then do the restore when it is needed.

How did you verify/test it?
enable the fib suppress.
run bgp suppress fib test.
check the config, if it is same as before.
  • Loading branch information
StormLiangMS authored and mssonicbld committed Nov 3, 2023
1 parent f6881cd commit d49930b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/bgp/test_bgp_suppress_fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,27 @@ def ignore_expected_loganalyzer_errors(duthosts, rand_one_dut_hostname, loganaly

@pytest.fixture(scope="function")
def restore_bgp_suppress_fib(duthost):
"""
Record the configuration before test only restore bgp suppress fib
if it is not enabled before test
"""
suppress_fib = False
rets = duthost.shell('show suppress-fib-pending')
if rets['rc'] != 0:
logger.info("Failed to get suppress-fib-pending configuration")
else:
logger.info("Get suppress-fib-pending configuration: {}".format(rets['stdout']))
if rets['stdout'] == 'Enabled':
suppress_fib = True

"""
Restore bgp suppress fib pending function
"""
yield

config_bgp_suppress_fib(duthost, False)
logger.info("Save configuration")
duthost.shell('sudo config save -y')
if not suppress_fib:
config_bgp_suppress_fib(duthost, False)
logger.info("Save configuration")
duthost.shell('sudo config save -y')


@pytest.fixture(scope="module")
Expand Down

0 comments on commit d49930b

Please sign in to comment.