@@ -325,6 +325,17 @@ def build_pkt(dest_mac, ip_addr, ttl, flow_count):
325325 return pkt , exp_packet
326326
327327
328+ def validate_asic_route (duthost , route , exist = True ):
329+ logger .info (f"Checking ip route: { route } " )
330+ asic_info = duthost .shell (f'redis-cli -n 1 keys "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:*{ route } *"' ,
331+ module_ignore_errors = True )["stdout" ]
332+ if route in asic_info :
333+ logger .info (f"Matched ASIC route: { asic_info } " )
334+ return exist is True
335+ else :
336+ return exist is False
337+
338+
328339def test_nhop_group_member_count (duthost , tbinfo , loganalyzer ):
329340 """
330341 Test next hop group resource count. Steps:
@@ -535,8 +546,9 @@ def built_and_send_tcp_ip_packet():
535546 nhop .add_ip_route (ip_prefix , ips )
536547
537548 nhop .program_routes ()
538- # wait for routes to be synced and programmed
539- time .sleep (15 )
549+
550+ pytest_assert (wait_until (60 , 5 , 0 , validate_asic_route , duthost , ip_prefix ),
551+ f"Static route: { ip_prefix } is failed to be programmed!" )
540552
541553 ptfadapter .dataplane .flush ()
542554
@@ -566,6 +578,8 @@ def built_and_send_tcp_ip_packet():
566578 asic .start_service ("bgp" )
567579 time .sleep (15 )
568580 nhop .delete_routes ()
581+ pytest_assert (wait_until (60 , 5 , 0 , validate_asic_route , duthost , ip_prefix , False ),
582+ f"Static route: { ip_prefix } is failed to be removed!" )
569583 arplist .clean_up ()
570584
571585 th_asic_flow_map = {0 : 'c0:ff:ee:00:00:12' , 1 : 'c0:ff:ee:00:00:10' ,
0 commit comments