Skip to content

Commit

Permalink
[VOQ Chassis] Separate out Route Consistency between upstream and dow…
Browse files Browse the repository at this point in the history
…nstream LC's (#14787)

What I did:

With recent changes were AZNG routes on upstream LC are not published 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.

Also increase sleep time by extra 1 min post route advertise/withdrawal

How I verify:

Test case passed after this change.

Signed-off-by: Abhishek Dosi <[email protected]>
  • Loading branch information
abdosi authored Oct 2, 2024
1 parent 3312543 commit a35060d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 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,19 +63,28 @@ 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] -
post_withdraw_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))
localhost.announce_routes(topo_name=topo_name, ptf_ip=ptf_ip, action="announce", path="../ansible/")
Expand Down

0 comments on commit a35060d

Please sign in to comment.