Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/common/dualtor/dual_tor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,3 +1513,56 @@ def check_active_active_port_status(duthost, ports, status):
)

return


@pytest.fixture
def config_active_active_dualtor_active_standby(
duthosts, active_active_ports, tbinfo, validate_active_active_dualtor_setup # noqa F811
):
"""Config the active-active dualtor that one ToR as active and the other as standby."""
if not ('dualtor' in tbinfo['topo']['name'] and active_active_ports):
yield
return

def check_active_active_port_status(duthost, ports, status):
logging.debug("Check mux status for ports {} is {}".format(ports, status))
show_mux_status_ret = show_muxcable_status(duthost)
logging.debug("show_mux_status_ret: {}".format(json.dumps(show_mux_status_ret, indent=4)))
for port in ports:
if port not in show_mux_status_ret:
return False
elif show_mux_status_ret[port]['status'] != status:
return False
return True

def _config_the_active_active_dualtor(active_tor, standby_tor, ports):
active_side_commands = []
standby_side_commands = []
for port in ports:
if port not in active_active_ports:
raise ValueError("Port {} is not in the active-active ports".format(port))
active_side_commands.append("config mux mode active {}".format(port))
standby_side_commands.append("config mux mode standby {}".format(port))

if not check_active_active_port_status(active_tor, ports, 'active'):
active_tor.shell_cmds(cmds=active_side_commands)
standby_tor.shell_cmds(cmds=standby_side_commands)

pt_assert(wait_until(30, 5, 0, check_active_active_port_status, active_tor, ports, 'active'),
"Could not config ports {} to active on {}".format(ports, active_tor.hostname))
pt_assert(wait_until(30, 5, 0, check_active_active_port_status, standby_tor, ports, 'standby'),
"Could not config ports {} to standby on {}".format(ports, standby_tor.hostname))

ports_to_restore.extend(ports)

ports_to_restore = []

yield _config_the_active_active_dualtor

if ports_to_restore:
restore_cmds = []
for port in ports_to_restore:
restore_cmds.append("config mux mode auto {}".format(port))

for duthost in duthosts:
duthost.shell_cmds(cmds=restore_cmds)
5 changes: 3 additions & 2 deletions tests/common/dualtor/mux_simulator_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tests.common import utilities
from tests.common.dualtor.dual_tor_common import cable_type # noqa F401
from tests.common.dualtor.dual_tor_common import mux_config # noqa F401
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa F401
from tests.common.dualtor.dual_tor_common import CableType
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa F401
from tests.common.helpers.assertions import pytest_assert
Expand Down Expand Up @@ -507,8 +508,8 @@ def toggle_all_simulator_ports_to_rand_selected_tor_m(duthosts, mux_server_url,
Before toggling, this fixture firstly sets all muxcables to 'manual' mode on all ToRs.
After test is done, restore all mux cables to 'auto' mode on all ToRs in teardown phase.
"""
# Skip on non dualtor testbed
if 'dualtor' not in tbinfo['topo']['name']:
# Skip on non dualtor testbed or dualtor testbed without active-standby ports
if 'dualtor' not in tbinfo['topo']['name'] or not active_standby_ports:
yield
return

Expand Down
29 changes: 26 additions & 3 deletions tests/fdb/test_fdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
from tests.common.fixtures.duthost_utils import disable_fdb_aging # noqa F401
from tests.common.dualtor.dual_tor_utils import config_active_active_dualtor_active_standby # noqa F401
from tests.common.dualtor.dual_tor_utils import validate_active_active_dualtor_setup # noqa F401
from tests.common.dualtor.mux_simulator_control import mux_server_url, \
toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
from .utils import fdb_cleanup, send_eth, send_arp_request, send_arp_reply, send_recv_eth

pytestmark = [
Expand Down Expand Up @@ -271,10 +274,31 @@ def record_mux_status(request, rand_selected_dut, tbinfo):
logger.warning("fdb test failed. Mux status are \n {}".format(mux_status))


@pytest.fixture(params=PKT_TYPES)
def pkt_type(request):
"""Packet type to test."""
return request.param


@pytest.fixture
def setup_active_active_ports(active_active_ports, rand_selected_dut, rand_unselected_dut, # noqa F811
pkt_type, config_active_active_dualtor_active_standby, # noqa F811
validate_active_active_dualtor_setup): # noqa F811
if active_active_ports and pkt_type == "ethernet":
# for active-active dualtor, the upstream traffic is ECMPed to both ToRs, so let's
# config the unselected ToR as standby to ensure all ethernet type packets are
# forwarded to the selected ToR.
logger.info("Configuring {} as active".format(rand_selected_dut.hostname))
logger.info("Configuring {} as standby".format(rand_unselected_dut.hostname))
config_active_active_dualtor_active_standby(rand_selected_dut, rand_unselected_dut, active_active_ports)

return


@pytest.mark.bsl
@pytest.mark.parametrize("pkt_type", PKT_TYPES)
def test_fdb(ansible_adhoc, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost, pkt_type,
toggle_all_simulator_ports_to_rand_selected_tor_m, record_mux_status, get_dummay_mac_count): # noqa F811
toggle_all_simulator_ports_to_rand_selected_tor_m, record_mux_status, # noqa F811
setup_active_active_ports, get_dummay_mac_count): # noqa F811

# Perform FDB clean up before each test and at the end of the final test
fdb_cleanup(duthosts, rand_one_dut_hostname)
Expand Down Expand Up @@ -368,7 +392,6 @@ def test_fdb(ansible_adhoc, ptfadapter, duthosts, rand_one_dut_hostname, ptfhost
assert dummy_mac_count == configured_dummay_mac_count * vlan_member_count


@pytest.mark.parametrize("pkt_type", PKT_TYPES)
def test_self_mac_not_learnt(ptfadapter, rand_selected_dut, pkt_type,
toggle_all_simulator_ports_to_rand_selected_tor_m, tbinfo): # noqa F811
"""
Expand Down