diff --git a/tests/vlan/test_host_vlan.py b/tests/vlan/test_host_vlan.py index 81c859bd07..8519c9685f 100644 --- a/tests/vlan/test_host_vlan.py +++ b/tests/vlan/test_host_vlan.py @@ -13,7 +13,7 @@ from tests.common.utilities import is_ipv4_address from tests.common.utilities import wait_until, delete_running_config from tests.common.utilities import skip_release - +from tests.common.helpers.assertions import pytest_assert pytestmark = [ pytest.mark.topology("t0", "m0", "mx") @@ -94,10 +94,16 @@ def setup_host_vlan_intf_mac(duthosts, rand_one_dut_hostname, testbed_params, ve if duthost.get_facts()['asic_type'] == 'mellanox': DUT_VLAN_INTF_MAC = get_new_vlan_intf_mac_mellanox(dut_vlan_mac) duthost.shell('redis-cli -n 4 hmset "VLAN|%s" mac %s' % (vlan_intf["attachto"], DUT_VLAN_INTF_MAC)) - wait_until(10, 2, 2, lambda: duthost.get_dut_iface_mac(vlan_intf["attachto"]) == DUT_VLAN_INTF_MAC) + pytest_assert(wait_until(10, 2, 2, lambda: duthost.get_dut_iface_mac(vlan_intf["attachto"]) == DUT_VLAN_INTF_MAC), + "Failed to set mac address for vlan interface %s" % vlan_intf["attachto"]) yield + # Restore the original mac address of the vlan interface + duthost.shell('redis-cli -n 4 hmset "VLAN|%s" mac %s' % (vlan_intf["attachto"], dut_vlan_mac)) + pytest_assert(wait_until(10, 2, 2, lambda: duthost.get_dut_iface_mac(vlan_intf["attachto"]) == dut_vlan_mac), + "Failed to restore mac address for vlan interface %s" % vlan_intf["attachto"]) + if "dualtor" not in tbinfo["topo"]["name"]: del_vlan_json = json.loads(""" [{ @@ -110,8 +116,6 @@ def setup_host_vlan_intf_mac(duthosts, rand_one_dut_hostname, testbed_params, ve """ % (vlan_intf["attachto"], dut_vlan_mac)) delete_running_config(del_vlan_json, duthost) - wait_until(10, 2, 2, lambda: duthost.get_dut_iface_mac(vlan_intf["attachto"]) == dut_vlan_mac) - def test_host_vlan_no_floodling( duthosts,