11#!/usr/bin/env python
22
33import logging
4+
45import pytest
56
67from tests .common .helpers .assertions import pytest_assert
78from tests .common .utilities import wait_until
8- from utils import get_crm_resources , check_queue_status , sleep_to_wait , LOOP_TIMES_LEVEL_MAP
9+ from utils import get_crm_resource_status , check_queue_status , sleep_to_wait , LOOP_TIMES_LEVEL_MAP
910
1011ALLOW_ROUTES_CHANGE_NUMS = 5
1112CRM_POLLING_INTERVAL = 1
1415logger = logging .getLogger (__name__ )
1516
1617pytestmark = [
17- pytest .mark .topology ('t0' , 't1' , 'm0' , 'mx' )
18+ pytest .mark .topology ('t0' , 't1' , 'm0' , 'mx' , 't2' )
1819]
1920
2021
21- def announce_withdraw_routes (duthost , localhost , ptf_ip , topo_name ):
22+ def announce_withdraw_routes (duthost , namespace , localhost , ptf_ip , topo_name ):
2223 logger .info ("announce ipv4 and ipv6 routes" )
2324 localhost .announce_routes (topo_name = topo_name , ptf_ip = ptf_ip , action = "announce" , path = "../ansible/" )
2425
2526 wait_until (MAX_WAIT_TIME , CRM_POLLING_INTERVAL , 0 , lambda : check_queue_status (duthost , "outq" ) is True )
2627
27- logger .info ("ipv4 route used {}" .format (get_crm_resources (duthost , "ipv4_route" , "used" )))
28- logger .info ("ipv6 route used {}" .format (get_crm_resources (duthost , "ipv6_route" , "used" )))
28+ logger .info ("ipv4 route used {}" .format (get_crm_resource_status (duthost , "ipv4_route" , "used" , namespace )))
29+ logger .info ("ipv6 route used {}" .format (get_crm_resource_status (duthost , "ipv6_route" , "used" , namespace )))
2930 sleep_to_wait (CRM_POLLING_INTERVAL * 5 )
3031
3132 logger .info ("withdraw ipv4 and ipv6 routes" )
3233 localhost .announce_routes (topo_name = topo_name , ptf_ip = ptf_ip , action = "withdraw" , path = "../ansible/" )
3334
3435 wait_until (MAX_WAIT_TIME , CRM_POLLING_INTERVAL , 0 , lambda : check_queue_status (duthost , "inq" ) is True )
3536 sleep_to_wait (CRM_POLLING_INTERVAL * 5 )
36- logger .info ("ipv4 route used {}" .format (get_crm_resources (duthost , "ipv4_route" , "used" )))
37- logger .info ("ipv6 route used {}" .format (get_crm_resources (duthost , "ipv6_route" , "used" )))
37+ logger .info ("ipv4 route used {}" .format (get_crm_resource_status (duthost , "ipv4_route" , "used" , namespace )))
38+ logger .info ("ipv6 route used {}" .format (get_crm_resource_status (duthost , "ipv6_route" , "used" , namespace )))
3839
3940
40- def test_announce_withdraw_route (duthost , localhost , tbinfo , get_function_conpleteness_level ,
41- withdraw_and_announce_existing_routes , loganalyzer ):
41+ def test_announce_withdraw_route (duthosts , localhost , tbinfo , get_function_conpleteness_level ,
42+ withdraw_and_announce_existing_routes , loganalyzer ,
43+ enum_rand_one_per_hwsku_frontend_hostname , enum_rand_one_frontend_asic_index ):
4244 ptf_ip = tbinfo ["ptf_ip" ]
4345 topo_name = tbinfo ["topo" ]["name" ]
46+ duthost = duthosts [enum_rand_one_per_hwsku_frontend_hostname ]
47+ asichost = duthost .asic_instance (enum_rand_one_frontend_asic_index )
48+ namespace = asichost .namespace
49+
4450 if loganalyzer :
4551 ignoreRegex = [
4652 ".*ERR route_check.py:.*" ,
@@ -57,13 +63,13 @@ def test_announce_withdraw_route(duthost, localhost, tbinfo, get_function_conple
5763 loop_times = LOOP_TIMES_LEVEL_MAP [normalized_level ]
5864
5965 while loop_times > 0 :
60- announce_withdraw_routes (duthost , localhost , ptf_ip , topo_name )
66+ announce_withdraw_routes (duthost , namespace , localhost , ptf_ip , topo_name )
6167 loop_times -= 1
6268
6369 sleep_to_wait (CRM_POLLING_INTERVAL * 100 )
6470
65- ipv4_route_used_after = get_crm_resources (duthost , "ipv4_route" , "used" )
66- ipv6_route_used_after = get_crm_resources (duthost , "ipv6_route" , "used" )
71+ ipv4_route_used_after = get_crm_resource_status (duthost , "ipv4_route" , "used" , namespace )
72+ ipv6_route_used_after = get_crm_resource_status (duthost , "ipv6_route" , "used" , namespace )
6773
6874 pytest_assert (abs (ipv4_route_used_after - ipv4_route_used_before ) < ALLOW_ROUTES_CHANGE_NUMS ,
6975 "ipv4 route used after is not equal to it used before" )
0 commit comments