From 4111e9dc36c412c871efeaf9458465fcb2fad8bf Mon Sep 17 00:00:00 2001 From: Priyansh Tratiya Date: Mon, 23 Feb 2026 14:13:35 -0800 Subject: [PATCH] manual cherry-picking PR#15962 and PR#16532 Signed-off-by: Priyansh Tratiya --- tests/route/test_default_route.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/route/test_default_route.py b/tests/route/test_default_route.py index 2e4d00c4dc..62b6d1ba84 100644 --- a/tests/route/test_default_route.py +++ b/tests/route/test_default_route.py @@ -48,7 +48,7 @@ def is_in_neighbor(neigh_types, neigh_name): return False -def get_upstream_neigh(tb, device_neigh_metadata): +def get_upstream_neigh(tb, device_neigh_metadata, af, nexthops): """ Get the information for upstream neighbors present in the testbed @@ -73,14 +73,14 @@ def get_upstream_neigh(tb, device_neigh_metadata): ipv6_addr = None for intf, intf_cfg in list(interfaces.items()): if 'Port-Channel' in intf: - if 'ipv4' in intf_cfg: + if 'ipv4' in intf_cfg and af in intf_cfg and interfaces[intf]['ipv4'].split('/')[0] in nexthops: ipv4_addr = interfaces[intf]['ipv4'].split('/')[0] - if 'ipv6' in intf_cfg: + if 'ipv6' in intf_cfg and af in intf_cfg and interfaces[intf]['ipv6'].split('/')[0].lower() in nexthops: ipv6_addr = interfaces[intf]['ipv6'].split('/')[0] elif 'Ethernet' in intf: - if 'ipv4' in intf_cfg: + if 'ipv4' in intf_cfg and af in intf_cfg and interfaces[intf]['ipv4'].split('/')[0] in nexthops: ipv4_addr = interfaces[intf]['ipv4'] - if 'ipv6' in intf_cfg: + if 'ipv6' in intf_cfg and af in intf_cfg and interfaces[intf]['ipv6'].split('/')[0].lower() in nexthops: ipv6_addr = interfaces[intf]['ipv6'] else: continue @@ -125,10 +125,10 @@ def verify_default_route_in_app_db(duthost, tbinfo, af, uplink_ns, device_neigh_ pytest_assert(nexthops is not None, "Default route has not nexthops") logging.info("nexthops in app_db {}".format(nexthops)) - upstream_neigh = get_upstream_neigh(tbinfo, device_neigh_metadata) + upstream_neigh = get_upstream_neigh(tbinfo, device_neigh_metadata, af, nexthops) pytest_assert(upstream_neigh is not None, "No upstream neighbors in the testbed") - + upstream_neigh = {k: v for k, v in upstream_neigh.items() if any(upstream_neigh.get(k))} if af == 'ipv4': upstream_neigh_ip = set([upstream_neigh[neigh][0] for neigh in upstream_neigh])