@@ -115,17 +115,29 @@ def remove_acl_table(duthost):
115115 duthost .shell_cmds (cmds = cmds )
116116
117117
118+ def get_neighbor_ports (mg_facts , neighbor_name ):
119+ neighbor_ports = []
120+ for key , value in mg_facts ["minigraph_neighbors" ].items ():
121+ if neighbor_name in value ["name" ]:
122+ neighbor_ports .append (key )
123+ return neighbor_ports
124+
125+
118126@pytest .fixture (scope = "module" )
119127def create_acl_table (rand_selected_dut , tbinfo ):
120128 """
121129 Create two ACL tables on DUT for testing.
122130 """
123131 mg_facts = rand_selected_dut .get_extended_minigraph_facts (tbinfo )
124- # Get the list of LAGs
125- port_channels = "," .join (mg_facts ["minigraph_portchannels" ].keys ())
132+ if tbinfo ["topo" ]["type" ] == "mx" :
133+ neighbor_ports = get_neighbor_ports (mg_facts , "M0" )
134+ ports = "," .join (neighbor_ports )
135+ else :
136+ # Get the list of LAGs
137+ ports = "," .join (mg_facts ["minigraph_portchannels" ].keys ())
126138 cmds = [
127- "config acl add table {} L3 -p {}" .format (ACL_TABLE_NAME_V4 , port_channels ),
128- "config acl add table {} L3V6 -p {}" .format (ACL_TABLE_NAME_V6 , port_channels )
139+ "config acl add table {} L3 -p {}" .format (ACL_TABLE_NAME_V4 , ports ),
140+ "config acl add table {} L3V6 -p {}" .format (ACL_TABLE_NAME_V6 , ports )
129141 ]
130142 logger .info ("Creating ACL table for testing" )
131143 loganalyzer = LogAnalyzer (ansible_host = rand_selected_dut , marker_prefix = "null_route_helper" )
@@ -231,13 +243,17 @@ def test_null_route_helper(rand_selected_dut, tbinfo, ptfadapter, apply_pre_defi
231243 rx_port = ptf_port_info ['port' ]
232244 router_mac = rand_selected_dut .facts ["router_mac" ]
233245 mg_facts = rand_selected_dut .get_extended_minigraph_facts (tbinfo )
234- portchannel_members = []
235- for _ , v in mg_facts ["minigraph_portchannels" ].items ():
236- portchannel_members += v ['members' ]
246+ if tbinfo ["topo" ]["type" ] == "mx" :
247+ neighbor_ports = get_neighbor_ports (mg_facts , "M0" )
248+ ptf_interfaces = [mg_facts ['minigraph_ptf_indices' ][port ] for port in neighbor_ports ]
249+ else :
250+ portchannel_members = []
251+ for _ , v in mg_facts ["minigraph_portchannels" ].items ():
252+ portchannel_members += v ['members' ]
237253
238- ptf_t1_interfaces = []
239- for port in portchannel_members :
240- ptf_t1_interfaces .append (mg_facts ['minigraph_ptf_indices' ][port ])
254+ ptf_interfaces = []
255+ for port in portchannel_members :
256+ ptf_interfaces .append (mg_facts ['minigraph_ptf_indices' ][port ])
241257
242258 # Run testing as defined in TEST_DATA
243259 for test_item in TEST_DATA :
@@ -252,4 +268,4 @@ def test_null_route_helper(rand_selected_dut, tbinfo, ptfadapter, apply_pre_defi
252268 rand_selected_dut .shell (NULL_ROUTE_HELPER + " " + action )
253269 time .sleep (1 )
254270
255- send_and_verify_packet (ptfadapter , pkt , exp_pkt , random .choice (ptf_t1_interfaces ), rx_port , expected_result )
271+ send_and_verify_packet (ptfadapter , pkt , exp_pkt , random .choice (ptf_interfaces ), rx_port , expected_result )
0 commit comments