Skip to content

Commit de454d5

Browse files
lolyumssonicbld
authored andcommitted
[testARPCompleted] Cleanup ptf ip after test failure (sonic-net#18170)
* [testARPCompleted] Cleanup ptf ip after test failure Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
1 parent 4a3d1d9 commit de454d5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

tests/fdb/test_fdb_mac_learning.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import pytest
33
import time
4+
from tests.common import config_reload
45
from tests.common.utilities import wait_until
56

67
from tests.common.helpers.assertions import pytest_assert
@@ -172,9 +173,8 @@ def prepare_test(self, duthosts, rand_one_dut_hostname, ptfhost):
172173

173174
yield target_ports_to_ptf_mapping, ptf_ports_available_in_topo, conf_facts
174175

175-
logging.info("startup all interfaces on DUT")
176-
for port in dut_ports:
177-
duthost.shell("sudo config interface startup {}".format(port))
176+
logging.info("reload device %s to recover", duthost.hostname)
177+
config_reload(duthost, config_source='running_golden_config', safe_reload=True)
178178

179179
@pytest.fixture(autouse=True)
180180
def cleanup_arp_fdb(self, duthosts, rand_one_dut_hostname):
@@ -309,8 +309,6 @@ def testARPCompleted(self, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost,
309309
self.configureNeighborIp(ptfhost, ptf_ports_available_in_topo[ptf_port_index], action="add")
310310
time.sleep(2)
311311
ptfhost.shell("ping {} -c 3 -I {}".format(self.DUT_INTF_IP, self.PTF_HOST_IP), module_ignore_errors=True)
312-
313-
finally:
314312
int_ip_found = any((dut_interface in line and self.DUT_INTF_IP in line)
315313
for line in duthost.command("show ip interface")["stdout_lines"])
316314
pytest_assert(int_ip_found, "%s is not configured on %s" % (self.DUT_INTF_IP, dut_interface))
@@ -323,5 +321,6 @@ def testARPCompleted(self, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost,
323321
pytest_assert(items[2] == dut_interface, "ARP entry for ip address {}"
324322
" is incomplete. Interface is missing".format(self.PTF_HOST_IP))
325323
pytest_assert(arp_found, "ARP entry not found for ip address {}".format(self.PTF_HOST_IP))
324+
finally:
326325
self.configureInterfaceIp(duthost, dut_interface, action="remove")
327326
self.configureNeighborIp(ptfhost, ptf_ports_available_in_topo[ptf_port_index], action="del")

0 commit comments

Comments
 (0)