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

fix arp_neighbor_noptf for multi asic devices #3672

Merged
merged 2 commits into from
Jun 20, 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
31 changes: 21 additions & 10 deletions tests/arp/test_neighbor_mac_noptf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,33 @@ class TestNeighborMacNoPtf:
6: {"intfIp": "fe00::1/64", "NeighborIp": "fe00::2"},
}

def count_routes(self, host, prefix):
def count_routes(self, asichost, 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),
num = asichost.shell(
'{} ASIC_DB eval "return #redis.call(\'keys\', \'{}:{{\\"dest\\":\\"{}*\')" 0'.format(asichost.sonic_db_cli,ROUTE_TABLE_NAME, prefix),
arlakshm marked this conversation as resolved.
Show resolved Hide resolved
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
def _check_no_bgp_routes_asic(self, asichost):
arlakshm marked this conversation as resolved.
Show resolved Hide resolved
# Checks that there are no routes installed by BGP in ASIC_DB by filtering out all local routes installed on asic
localv6 = self.count_routes(asichost, "fc") + self.count_routes(asichost, "fe")
localv4 = self.count_routes(asichost, "10.") + self.count_routes(asichost, "192.168.0.")
#these routes are present only on multi asic device, on single asic platform they will be zero
internal = self.count_routes(asichost, "8.") + self.count_routes(asichost, "2603")
allroutes = self.count_routes(asichost, "")
logger.info("asic[{}] localv4 routes {} localv6 routes {} internalv4 {} allroutes {}".format(asichost.asic_index, localv4, localv6, internal, allroutes))
bgp_routes_asic = allroutes - localv6 - localv4 - internal - DEFAULT_ROUTE_NUM

return bgproutes == 0
return bgp_routes_asic

def _check_no_bgp_routes(self, duthost):
bgp_routes = 0
# Checks that there are no routes installed by BGP in ASIC_DB by filtering out all local routes installed on testbed
for asic in duthost.asics:
bgp_routes += self._check_no_bgp_routes_asic(asic)

return bgp_routes == 0

@pytest.fixture(scope="module", autouse=True)
def setupDutConfig(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""
Expand Down