From 34708d786f6f57409fefeb2163dcaf4da97bf95d Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:50:57 -0700 Subject: [PATCH 1/7] Update multi_asic.py --- tests/common/devices/multi_asic.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/common/devices/multi_asic.py b/tests/common/devices/multi_asic.py index 57f24fdf8b..0076e19148 100644 --- a/tests/common/devices/multi_asic.py +++ b/tests/common/devices/multi_asic.py @@ -685,6 +685,28 @@ def get_voq_inband_interfaces(self): ) return voq_inband_interfaces.keys() + def get_portchannel_member(self): + """ + This Function is applicable on packet Chassis, or + any dut that has PORTCHANNEL_MEMBER in config dbs. + Get PORTCHANNEL_MEMBER from config db of all asics. + Returns: + List of [portchannel]. e.g. ["PortChannel101|Ethernet104", "PortChannel01|EthernetBPxx", ...] + {} if VOQ chassis or other dut that doesn't have PORTCHANNEL_MEMBER + """ + if not self.sonichost.is_multi_asic: + return {} + pcs = {} + for asic in self.frontend_asics: + config_facts = self.config_facts( + host=self.hostname, source="running", + namespace=asic.namespace + )['ansible_facts'] + pcs.update( + config_facts.get("PORTCHANNEL_MEMBER", {}) + ) + return pcs.keys() + def docker_cmds_on_all_asics(self, cmd, container_name): """This function iterate for ALL asics and execute cmds""" duthost = self.sonichost From 032074d9d1890821940395ada0355596ffbdd285 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:10:39 -0700 Subject: [PATCH 2/7] Update test_route_flap.py --- tests/route/test_route_flap.py | 43 ++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/tests/route/test_route_flap.py b/tests/route/test_route_flap.py index f1cafc876f..9ed6379e84 100644 --- a/tests/route/test_route_flap.py +++ b/tests/route/test_route_flap.py @@ -208,11 +208,31 @@ def is_dualtor(tbinfo): return "dualtor" in tbinfo["topo"]["name"] -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 +def get_internal_interfaces(duthost): + """ + This function returns internal interfaces for any + multi-asic dut, including voq/packet chassis + """ + internal_intfs = [] + + # First check for packet chassis, or any dut that has PORTCHANNEL_MEMBER in config db + pcs = duthost.get_portchannel_member() + for pc in pcs: + """ + For packet chassis, 'pcs' looks like: + ["PortChannel101|Ethernet104", "PortChannel01|Ethernet-BPxx",...] + """ + if 'IB' in pc or 'BP' in pc: + internal_intfs.append(pc) + + # Then check for voq chassis: get voq inband interface for later filtering voq_inband_interfaces = duthost.get_voq_inband_interfaces() + internal_intfs.append([voq_inband_interfaces]) + + return internal_intfs + + +def get_dev_port_and_route(duthost, asichost, dst_prefix_set): dev_port = None route_to_ping = None for dst_prefix in dst_prefix_set: @@ -221,6 +241,8 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set): route_to_ping = dst_prefix.route cmd = ' -c "show ip route {} json"'.format(route_to_ping) if duthost.is_multi_asic: + # Get internal interfaces for later filtering + internal_intfs = get_internal_interfaces(duthost) for asic in duthost.frontend_asics: if dev_port: break @@ -230,13 +252,14 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set): continue if 'ip' not in per_hop.keys(): 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']: + if per_hop['interfaceName'] in internal_intfs: continue - dev_port = per_hop['interfaceName'] + port = per_hop['interfaceName'] + neigh = duthost.shell("show ip int | grep -w {}".format(port))['stdout'] + if neigh == '': + logger.info("{} is still internal interface, skipping".format(port)) + else: + dev_port = port break else: dev = json.loads(asichost.run_vtysh(cmd)['stdout']) From d067279380d3d9db7fcdd03c3b8a2be8381a1bdf Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Mon, 2 Oct 2023 13:50:17 -0700 Subject: [PATCH 3/7] remove internal link check for single-asic --- tests/route/test_route_flap.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/route/test_route_flap.py b/tests/route/test_route_flap.py index 9ed6379e84..5e0998608c 100644 --- a/tests/route/test_route_flap.py +++ b/tests/route/test_route_flap.py @@ -266,9 +266,7 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set): 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']: + if 'ip' not in per_hop.keys(): continue dev_port = per_hop['interfaceName'] break From c174a1fb5bd5af7892d3207f3fd569ad4d6db9d0 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:06:17 -0700 Subject: [PATCH 4/7] fix pre-commit --- tests/common/devices/multi_asic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common/devices/multi_asic.py b/tests/common/devices/multi_asic.py index 370c711cb9..a043185509 100644 --- a/tests/common/devices/multi_asic.py +++ b/tests/common/devices/multi_asic.py @@ -684,7 +684,7 @@ def get_voq_inband_interfaces(self): config_facts.get("VOQ_INBAND_INTERFACE", {}) ) return voq_inband_interfaces.keys() - + def get_portchannel_member(self): """ This Function is applicable on packet Chassis, or From 7f9b9d90158ef11f905ecd62f94710ab236948e5 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:47:18 -0700 Subject: [PATCH 5/7] Update test_route_flap.py --- tests/route/test_route_flap.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/route/test_route_flap.py b/tests/route/test_route_flap.py index 5e0998608c..2c4c34d145 100644 --- a/tests/route/test_route_flap.py +++ b/tests/route/test_route_flap.py @@ -235,14 +235,14 @@ def get_internal_interfaces(duthost): def get_dev_port_and_route(duthost, asichost, dst_prefix_set): dev_port = None route_to_ping = None + # Get internal interfaces for later filtering + internal_intfs = get_internal_interfaces(duthost) for dst_prefix in dst_prefix_set: if dev_port: break route_to_ping = dst_prefix.route cmd = ' -c "show ip route {} json"'.format(route_to_ping) if duthost.is_multi_asic: - # Get internal interfaces for later filtering - internal_intfs = get_internal_interfaces(duthost) for asic in duthost.frontend_asics: if dev_port: break @@ -268,6 +268,12 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set): continue if 'ip' not in per_hop.keys(): continue + if per_hop['ip'] in internal_bgp_ips: + continue + if per_hop['interfaceName'] in internal_intfs: + 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") From 1816d2ba83e589f6ff011ee561cf9ff8a6eacf27 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:49:45 -0700 Subject: [PATCH 6/7] Update test_route_flap.py --- tests/route/test_route_flap.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/route/test_route_flap.py b/tests/route/test_route_flap.py index 2c4c34d145..2563236dff 100644 --- a/tests/route/test_route_flap.py +++ b/tests/route/test_route_flap.py @@ -266,12 +266,7 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set): for per_hop in dev[route_to_ping][0]['nexthops']: if 'interfaceName' not in per_hop.keys(): continue - if 'ip' not in per_hop.keys(): - continue - if per_hop['ip'] in internal_bgp_ips: - continue - if per_hop['interfaceName'] in internal_intfs: - continue + # For chassis, even single-asic linecard could have internal interface if 'IB' in per_hop['interfaceName'] or 'BP' in per_hop['interfaceName']: continue dev_port = per_hop['interfaceName'] From edcf21dd2359e5bf96b241d879faef187916e3b4 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:51:02 -0700 Subject: [PATCH 7/7] Update test_route_flap.py --- tests/route/test_route_flap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/route/test_route_flap.py b/tests/route/test_route_flap.py index 2563236dff..1f268bff76 100644 --- a/tests/route/test_route_flap.py +++ b/tests/route/test_route_flap.py @@ -267,6 +267,8 @@ def get_dev_port_and_route(duthost, asichost, dst_prefix_set): if 'interfaceName' not in per_hop.keys(): continue # For chassis, even single-asic linecard could have internal interface + if per_hop['interfaceName'] in internal_intfs: + continue if 'IB' in per_hop['interfaceName'] or 'BP' in per_hop['interfaceName']: continue dev_port = per_hop['interfaceName']