Skip to content

Commit

Permalink
Restore the MAC address of VLAN at the end of test_host_vlan (sonic-n…
Browse files Browse the repository at this point in the history
  • Loading branch information
bingwang-ms authored and mssonicbld committed Aug 28, 2023
1 parent 3539831 commit dc1357c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/vlan/test_host_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -71,10 +71,16 @@ def setup_host_vlan_intf_mac(duthosts, rand_one_dut_hostname, testbed_params, ve
duthost = duthosts[rand_one_dut_hostname]
dut_vlan_mac = duthost.get_dut_iface_mac('%s' % vlan_intf["attachto"])
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("""
[{
Expand All @@ -87,8 +93,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,
Expand Down

0 comments on commit dc1357c

Please sign in to comment.