11import logging
22import pytest
33import time
4- from tests .common import config_reload
54from tests .common .utilities import wait_until
65
76from tests .common .helpers .assertions import pytest_assert
87from tests .common .fixtures .ptfhost_utils import copy_ptftests_directory # noqa F401
98from tests .ptf_runner import ptf_runner
109from .utils import fdb_table_has_dummy_mac_for_interface
11- from tests .common .helpers .ptf_tests_helper import upstream_links # noqa F401
1210from tests .common .dualtor .mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
1311
1412
@@ -36,8 +34,6 @@ class TestFdbMacLearning:
3634 """
3735 TestFdbMacLearning verifies that stale MAC entries are not present in MAC table after doing sonic-clear fdb all
3836 -shut down all ports
39- -config save
40- -config reload
4137 -bring up 1 port. populate fdb
4238 -bring up 3 more ports. populate fdb.
4339 -shut down 3 ports added in last step
@@ -123,7 +119,7 @@ def prepare_test(self, duthosts, rand_one_dut_hostname, ptfhost):
123119 """
124120 Select DUT ports which will be used for the testcase
125121 Get a mapping of selected DUT ports and ptf ports
126- shut down all DUT ports, congit save and config reload the DUT before starting the testcases
122+ shut down all DUT ports
127123
128124 Args:
129125 duthosts: Devices under test
@@ -173,10 +169,25 @@ def prepare_test(self, duthosts, rand_one_dut_hostname, ptfhost):
173169 logging .info ("shutdown all interfaces on DUT" )
174170 for port in dut_ports :
175171 duthost .shell ("sudo config interface shutdown {}" .format (port ))
176- duthost .command ('sudo config save -y' )
177- config_reload (duthost , config_source = 'config_db' , safe_reload = True )
172+
178173 yield target_ports_to_ptf_mapping , ptf_ports_available_in_topo , conf_facts
179174
175+ logging .info ("startup all interfaces on DUT" )
176+ for port in dut_ports :
177+ duthost .shell ("sudo config interface startup {}" .format (port ))
178+
179+ @pytest .fixture (autouse = True )
180+ def cleanup_arp_fdb (self , duthosts , rand_one_dut_hostname ):
181+ """Cleanup fdb and arp on the selected target DUT."""
182+ duthost = duthosts [rand_one_dut_hostname ]
183+ duthost .shell ("sonic-clear arp" )
184+ duthost .shell ("sonic-clear fdb all" )
185+
186+ yield
187+
188+ duthost .shell ("sonic-clear arp" )
189+ duthost .shell ("sonic-clear fdb all" )
190+
180191 def dynamic_fdb_oper (self , duthost , tbinfo , ptfhost , dut_ptf_ports ):
181192 """function to populate fdb for given dut/ptf ports"""
182193 testParams = {
@@ -205,44 +216,13 @@ def wait_for_interfaces_ready(self, duthost, tbinfo, ports):
205216 """
206217 Make sure interfaces are ready for sending traffic.
207218 """
208- if "dualtor-aa" in tbinfo ['topo' ]['name' ]:
209- pytest_assert (wait_until (300 , 5 , 0 , self .check_mux_status_consistency , duthost , ports ))
210- else :
211- time .sleep (30 )
212-
213- def bringup_uplink_ports (self , duthost , upstream_links ): # noqa F811
214- """
215- For active-active dualtor NIC simulator doesn't install OVS flows for downlink ports until the link status
216- becomes consistent which can happen in this case only if upstream connectivity is restored.
217- """
218- # Get one upstream port
219- uplink_intf = list (upstream_links .keys ())[0 ]
220- # Check if it's a LAG member
221- config_facts = duthost .config_facts (host = duthost .hostname , source = "persistent" )['ansible_facts' ]
222- portChannels = config_facts ['PORTCHANNEL_MEMBER' ]
223- portChannel = None
224- members = None
225- for intf in portChannels :
226- if uplink_intf in portChannels [intf ]:
227- portChannel = intf
228- members = list (portChannels [intf ].keys ())
229- break
230- if portChannel :
231- min_links = int (config_facts ['PORTCHANNEL' ][portChannel ]['min_links' ])
232- # Bringup minimum ports for this port channel to be up
233- for i in range (min_links ):
234- duthost .shell ("sudo config interface startup {}" .format (members [i ]))
235- else :
236- duthost .shell ("sudo config interface startup {}" .format (uplink_intf ))
219+ time .sleep (30 )
237220
238221 def testFdbMacLearning (self , ptfadapter , duthosts , rand_one_dut_hostname , ptfhost , tbinfo , request , prepare_test ,
239- upstream_links , setup_standby_ports_on_rand_unselected_tor_unconditionally , # noqa F811
240222 toggle_all_simulator_ports_to_rand_selected_tor_m ): # noqa F811
241223 """
242224 TestFdbMacLearning verifies stale MAC entries are not present in MAC table after doing sonic-clear fdb all
243225 -shut down all ports
244- -config save
245- -config reload
246226 -bring up 1 port. populate fdb
247227 -bring up 3 more ports. populate fdb.
248228 -shut down 3 ports added in last step
@@ -260,10 +240,7 @@ def testFdbMacLearning(self, ptfadapter, duthosts, rand_one_dut_hostname, ptfhos
260240 res = ptfhost .shell ('cat /sys/class/net/{}/address' .format (ptf_port ))
261241 ptf_interfaces_mac_addresses .append (res ['stdout' ].upper ())
262242
263- # Bringup uplink connectivity for muxcable status consistency to happen.
264243 duthost = duthosts [rand_one_dut_hostname ]
265- if "dualtor-aa" in tbinfo ['topo' ]['name' ]:
266- self .bringup_uplink_ports (duthost , upstream_links )
267244
268245 # unshut 1 port and populate fdb for that port. make sure fdb entry is populated in mac table
269246 target_ports = [target_ports_to_ptf_mapping [0 ][0 ]]
@@ -330,9 +307,13 @@ def testARPCompleted(self, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost,
330307 try :
331308 self .configureInterfaceIp (duthost , dut_interface , action = "add" )
332309 self .configureNeighborIp (ptfhost , ptf_ports_available_in_topo [ptf_port_index ], action = "add" )
310+ time .sleep (2 )
333311 ptfhost .shell ("ping {} -c 3 -I {}" .format (self .DUT_INTF_IP , self .PTF_HOST_IP ), module_ignore_errors = True )
334312
335313 finally :
314+ int_ip_found = any ((dut_interface in line and self .DUT_INTF_IP in line )
315+ for line in duthost .command ("show ip interface" )["stdout_lines" ])
316+ pytest_assert (int_ip_found , "%s is not configured on %s" % (self .DUT_INTF_IP , dut_interface ))
336317 show_arp = duthost .command ('show arp' )
337318 arp_found = False
338319 for arp_entry in show_arp ['stdout_lines' ]:
0 commit comments