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

Disable BGP when running test_neighbor_mac_noptf #3369

Merged
merged 4 commits into from
May 10, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Implement waiting for BGP routes to go down.
alexrallen committed May 7, 2021

Verified

This commit was signed with the committer’s verified signature.
svc-excavator-bot Excavator Bot
commit 0fc66272c3d9f43eca0055acc6faf3701a0eea53
24 changes: 23 additions & 1 deletion tests/arp/test_neighbor_mac_noptf.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import pytest
import time

from tests.common.utilities import wait_until
from tests.common.helpers.assertions import pytest_assert
from tests.common.config_reload import config_reload

@@ -10,7 +11,11 @@
pytestmark = [
pytest.mark.topology('any')
]

REDIS_NEIGH_ENTRY_MAC_ATTR ="SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS"
ROUTE_TABLE_NAME = 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY'
DEFAULT_ROUTE_NUM = 2

class TestNeighborMacNoPtf:
"""
Test handling of neighbor MAC in SONiC switch
@@ -25,6 +30,21 @@ class TestNeighborMacNoPtf:
6: {"intfIp": "fe00::1/64", "NeighborIp": "fe00::2"},
}

def count_routes(self, host, prefix):
# Counts routes in ASIC_DB with a given prefix
num = host.shell(
'sonic-db-cli ASIC_DB eval "return #redis.call(\'keys\', \'{}:{{\\"dest\\":\\"{}*\')" 0'.format(ROUTE_TABLE_NAME, prefix),
module_ignore_errors=True, verbose=True)['stdout']
return int(num)

def _check_no_bgp_routes(self, duthost):
# Checks that there are no routes installed by BGP in ASIC_DB by filtering out all local routes installed on testbeds
localv6 = self.count_routes(duthost, "fc") + self.count_routes(duthost, "fe")
localv4 = self.count_routes(duthost, "10.") + self.count_routes(duthost, "192.168.0.")
allroutes = self.count_routes(duthost, "")
bgproutes = allroutes - localv6 - localv4 - DEFAULT_ROUTE_NUM

return bgproutes == 0

@pytest.fixture(scope="module", autouse=True)
def setupDutConfig(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
@@ -39,7 +59,9 @@ def setupDutConfig(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
duthost.command("sudo config bgp shutdown all")
time.sleep(120)
if not wait_until(120, 2.0, self._check_no_bgp_routes, duthost):
pytest.fail('BGP Shutdown Timeout: BGP route removal exceeded 120 seconds.')

yield

logger.info("Reload Config DB")