Skip to content

Commit

Permalink
[202205 cherry pick] test_route_flap for voq_chassis (#8971)
Browse files Browse the repository at this point in the history
This is cherry-pick PR of #8908
  • Loading branch information
wenyiz2021 authored Jul 14, 2023
1 parent 0201d70 commit d440721
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/common/devices/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,29 @@ def get_internal_bgp_peers(self):
)
return bgp_internal_neighbors

def get_voq_inband_interfaces(self):
"""
This Function is only applicable on VOQ Chassis.
Get VOQ Internal Inband Interfaces. API iterates through frontend ASIC
index to get the VOQ Inband Interfaces from running configuration.
Not using BGP_VOQ_CHASSIS_NEIGHBOUR peer ips since they are not referenced in
next hops of route.
Returns:
List of [voq_inband_interfaces]
"""
if not self.sonichost.is_multi_asic:
return {}
voq_inband_interfaces = {}
for asic in self.frontend_asics:
config_facts = self.config_facts(
host=self.hostname, source="running",
namespace=asic.namespace
)['ansible_facts']
voq_inband_interfaces.update(
config_facts.get("VOQ_INBAND_INTERFACE", {})
)
return voq_inband_interfaces.keys()

def docker_cmds_on_all_asics(self, cmd, container_name):
"""This function iterate for ALL asics and execute cmds"""
duthost = self.sonichost
Expand Down
8 changes: 8 additions & 0 deletions tests/route/test_route_flap.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def is_dualtor(tbinfo):
def get_dev_port_and_route(duthost, asichost, dst_prefix_set):
# Get internal bgp ips for later filtering
internal_bgp_ips = duthost.get_internal_bgp_peers().keys()
# Get voq inband interface for later filtering
voq_inband_interfaces = duthost.get_voq_inband_interfaces()
dev_port = None
route_to_ping = None
for dst_prefix in dst_prefix_set:
Expand All @@ -219,17 +221,23 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set):
continue
if per_hop['ip'] in internal_bgp_ips:
continue
if per_hop['interfaceName'] in voq_inband_interfaces:
continue
if 'IB' in per_hop['interfaceName'] or 'BP' in per_hop['interfaceName']:
continue
dev_port = per_hop['interfaceName']
break
else:
dev = json.loads(asichost.run_vtysh(cmd)['stdout'])
for per_hop in dev[route_to_ping][0]['nexthops']:
if 'interfaceName' not in per_hop.keys():
continue
if per_hop['interfaceName'] in voq_inband_interfaces:
continue
if 'IB' in per_hop['interfaceName'] or 'BP' in per_hop['interfaceName']:
continue
dev_port = per_hop['interfaceName']
break
pytest_assert(dev_port, "dev_port not exist")
return dev_port, route_to_ping

Expand Down

0 comments on commit d440721

Please sign in to comment.