@@ -393,7 +393,7 @@ def get_default_vrf_oid(self):
393
393
assert len (oids ) == 1 , "Wrong # of default vrfs: %d, expected #: 1." % (len (oids ))
394
394
return oids [0 ]
395
395
396
- def get_ip_prefix_nhg_oid (self , ip_prefix , vrf_oid = None ):
396
+ def get_ip_prefix_nhg_oid (self , ip_prefix , vrf_oid = None , prefix_present = True ):
397
397
if vrf_oid is None :
398
398
vrf_oid = self .default_vrf_oid
399
399
@@ -407,18 +407,24 @@ def _access_function():
407
407
route_entry_found = True
408
408
assert route_entry_key ["vr" ] == vrf_oid
409
409
break
410
-
411
- return (route_entry_found , raw_route_entry_key )
410
+ if prefix_present :
411
+ return (route_entry_found , raw_route_entry_key )
412
+ else :
413
+ return (not route_entry_found , None )
412
414
413
415
(route_entry_found , raw_route_entry_key ) = wait_for_result (_access_function )
414
416
415
- fvs = self .asic_db .get_entry (ASIC_ROUTE_ENTRY_TABLE , raw_route_entry_key )
417
+ if not prefix_present :
418
+ assert raw_route_entry_key == None
419
+ return None
420
+ else :
421
+ fvs = self .asic_db .get_entry (ASIC_ROUTE_ENTRY_TABLE , raw_route_entry_key )
416
422
417
- nhg_oid = fvs .get ("SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID" , "" )
418
- assert nhg_oid != ""
419
- assert nhg_oid != "oid:0x0"
423
+ nhg_oid = fvs .get ("SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID" , "" )
424
+ assert nhg_oid != ""
425
+ assert nhg_oid != "oid:0x0"
420
426
421
- return nhg_oid
427
+ return nhg_oid
422
428
423
429
def check_sub_port_intf_key_existence (self , db , table_name , key ):
424
430
db .wait_for_matching_keys (table_name , [key ])
@@ -1543,21 +1549,26 @@ def _test_sub_port_intf_oper_down_with_pending_neigh_route_tasks(self, dvs, sub_
1543
1549
self .add_route_appl_db (ip_prefix , nhop_ips , ifnames , vrf_name )
1544
1550
1545
1551
# Verify route entry created in ASIC_DB and get next hop group oid
1546
- nhg_oid = self .get_ip_prefix_nhg_oid (ip_prefix , vrf_oid )
1547
-
1548
- # Verify next hop group of the specified oid created in ASIC_DB
1549
- self .check_sub_port_intf_key_existence (self .asic_db , ASIC_NEXT_HOP_GROUP_TABLE , nhg_oid )
1552
+ nhg_oid = self .get_ip_prefix_nhg_oid (ip_prefix , vrf_oid , prefix_present = i < (nhop_num - 1 ))
1550
1553
1551
- # Verify next hop group member # created in ASIC_DB
1552
- nhg_member_oids = self . asic_db . wait_for_n_keys ( ASIC_NEXT_HOP_GROUP_MEMBER_TABLE ,
1553
- ( nhop_num - 1 ) - i if create_intf_on_parent_port == False else (( nhop_num - 1 ) - i ) * 2 )
1554
+ if i < ( nhop_num - 1 ):
1555
+ # Verify next hop group of the specified oid created in ASIC_DB
1556
+ self . check_sub_port_intf_key_existence ( self . asic_db , ASIC_NEXT_HOP_GROUP_TABLE , nhg_oid )
1554
1557
1555
- # Verify that next hop group members all belong to the next hop group of the specified oid
1556
- fv_dict = {
1557
- "SAI_NEXT_HOP_GROUP_MEMBER_ATTR_NEXT_HOP_GROUP_ID" : nhg_oid ,
1558
- }
1559
- for nhg_member_oid in nhg_member_oids :
1560
- self .check_sub_port_intf_fvs (self .asic_db , ASIC_NEXT_HOP_GROUP_MEMBER_TABLE , nhg_member_oid , fv_dict )
1558
+ # Verify next hop group member # created in ASIC_DB
1559
+ nhg_member_oids = self .asic_db .wait_for_n_keys (ASIC_NEXT_HOP_GROUP_MEMBER_TABLE ,
1560
+ (nhop_num - 1 ) - i if create_intf_on_parent_port == False \
1561
+ else ((nhop_num - 1 ) - i ) * 2 )
1562
+
1563
+ # Verify that next hop group members all belong to the next hop group of the specified oid
1564
+ fv_dict = {
1565
+ "SAI_NEXT_HOP_GROUP_MEMBER_ATTR_NEXT_HOP_GROUP_ID" : nhg_oid ,
1566
+ }
1567
+ for nhg_member_oid in nhg_member_oids :
1568
+ self .check_sub_port_intf_fvs (self .asic_db , ASIC_NEXT_HOP_GROUP_MEMBER_TABLE , nhg_member_oid , fv_dict )
1569
+ else :
1570
+ assert nhg_oid == None
1571
+ self .asic_db .wait_for_n_keys (ASIC_NEXT_HOP_GROUP_MEMBER_TABLE , 0 )
1561
1572
1562
1573
nhop_cnt = len (self .asic_db .get_keys (ASIC_NEXT_HOP_TABLE ))
1563
1574
# Remove next hop objects on sub port interfaces
0 commit comments