Skip to content

Commit

Permalink
With recent changes were AZNG routes on upstream LC are not published…
Browse files Browse the repository at this point in the history
… to APP DB modify route consistency

test to make sure all upstream LC;s have same route and all downstream LC's have same route.

Signed-off-by: Abhishek Dosi <[email protected]>
  • Loading branch information
abdosi committed Sep 27, 2024
1 parent 2eec910 commit 1b687e1
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/route/test_route_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ def extract_dest_ips(self, route_entries):
def get_route_prefix_snapshot_from_asicdb(self, duthosts):
prefix_snapshot = {}
max_prefix_cnt = 0
for dut in duthosts.frontend_nodes:
for idx, dut in enumerate(duthosts.frontend_nodes):
for asic in dut.asics:
dut_instance_name = dut.hostname + '-' + str(asic.asic_index)
if dut.facts['switch_type'] == "voq" and idx == 0:
dut_instance_name = dut_instance_name + "UpstreamLc"
prefix_snapshot[dut_instance_name] = \
set(self.extract_dest_ips(asic.run_sonic_db_cli_cmd('ASIC_DB KEYS *ROUTE_ENTRY*')['stdout_lines']))
logger.debug("snapshot of route table from {}: {}".format(dut_instance_name,
Expand All @@ -43,10 +45,10 @@ def setup(self, duthosts):
# take the snapshot of route table from all the DUTs
self.__class__.pre_test_route_snapshot, max_prefix_cnt = self.get_route_prefix_snapshot_from_asicdb(duthosts)
"""sleep interval is calculated based on the max number of prefixes in the route table.
Addtional 100 seconds is added to the sleep interval to account for the time taken to
Addtional 120 seconds is added to the sleep interval to account for the time taken to
withdraw and advertise the routes by peers.
"""
self.__class__.sleep_interval = math.ceil(max_prefix_cnt/3000) + 100
self.__class__.sleep_interval = math.ceil(max_prefix_cnt/3000) + 120
logger.debug("max_no_of_prefix: {} sleep_interval: {}".format(max_prefix_cnt, self.sleep_interval))

def test_route_withdraw_advertise(self, duthosts, tbinfo, localhost):
Expand All @@ -61,18 +63,26 @@ def test_route_withdraw_advertise(self, duthosts, tbinfo, localhost):
time.sleep(self.sleep_interval)

""" compare the number of routes withdrawn from all the DUTs. In working condition, the number of routes
withdrawn should be same across all the DUTs
withdrawn should be same across all the DUTs. On VOQ upstream LC's will have same route and Downstream LC will have same route.
Note: this will be noop for single asic pizzabox duts
"""
post_withdraw_route_snapshot, _ = self.get_route_prefix_snapshot_from_asicdb(duthosts)
num_routes_withdrawn = 0
num_routes_withdrawn_upstream_lc = 0
for dut_instance_name in self.pre_test_route_snapshot.keys():
if num_routes_withdrawn == 0:
if num_routes_withdrawn == 0 and not dut_instance_name.endswith("UpstreamLc"):
num_routes_withdrawn = len(self.pre_test_route_snapshot[dut_instance_name] -
post_withdraw_route_snapshot[dut_instance_name])
logger.debug("num_routes_withdrawn: {}".format(num_routes_withdrawn))
elif num_routes_withdrawn_upstream_lc == 0 and dut_instance_name.endswith("UpstreamLc"):
num_routes_withdrawn_upstream_lc = len(self.pre_test_route_snapshot[dut_instance_name] -
post_withdraw_route_snapshot[dut_instance_name])
else:
assert num_routes_withdrawn == len(self.pre_test_route_snapshot[dut_instance_name] -
if dut_instance_name.endswith("UpstreamLc"):
assert num_routes_withdrawn_upstream_lc == len(self.pre_test_route_snapshot[dut_instance_name] -
post_withdraw_route_snapshot[dut_instance_name])
else:
assert num_routes_withdrawn == len(self.pre_test_route_snapshot[dut_instance_name] -
post_withdraw_route_snapshot[dut_instance_name])

logger.info("advertise ipv4 and ipv6 routes for {}".format(topo_name))
Expand Down

0 comments on commit 1b687e1

Please sign in to comment.