Skip to content

Commit

Permalink
[dualtor] Add mux direction checks to toggle fixtures (sonic-net#8803)
Browse files Browse the repository at this point in the history
Approach
What is the motivation for this PR?
As the subject.

Signed-off-by: Longxiang Lyu lolv@microsoft.com

How did you do it?
Use toggle function with mux direction check.

How did you verify/test it?
Run dualtor-io testcases.

Any platform specific information?
  • Loading branch information
lolyu authored and parmarkj committed Oct 3, 2023
1 parent 1fbc90f commit e96fb3a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/common/dualtor/mux_simulator_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,27 +366,37 @@ def _toggle(side):


@pytest.fixture
def toggle_all_simulator_ports_to_upper_tor(mux_server_url, tbinfo, cable_type): # noqa F811
def toggle_all_simulator_ports_to_upper_tor(active_standby_ports, duthosts, mux_server_url, tbinfo, cable_type): # noqa F811
"""
A function level fixture to toggle all active-standby ports to upper_tor
For this fixture to work properly, ICMP responder must be running. Please ensure that fixture run_icmp_responder
is imported in test script. The run_icmp_responder fixture is defined in tests.common.fixtures.ptfhost_utils
"""
# Skip on non dualtor testbed
if 'dualtor' not in tbinfo['topo']['name'] or not active_standby_ports:
logger.info('Skipping toggle on non-dualtor testbed or active-active dualtor topo.')
return

if cable_type == CableType.active_standby:
_toggle_all_simulator_ports(mux_server_url, UPPER_TOR, tbinfo)
_toggle_all_simulator_ports_to_target_dut(duthosts[0].hostname, duthosts, mux_server_url, tbinfo)


@pytest.fixture
def toggle_all_simulator_ports_to_lower_tor(mux_server_url, tbinfo, cable_type): # noqa F811
def toggle_all_simulator_ports_to_lower_tor(active_standby_ports, duthosts, mux_server_url, tbinfo, cable_type): # noqa F811
"""
A function level fixture to toggle all active-standby ports to lower_tor
For this fixture to work properly, ICMP responder must be running. Please ensure that fixture run_icmp_responder
is imported in test script. The run_icmp_responder fixture is defined in tests.common.fixtures.ptfhost_utils
"""
# Skip on non dualtor testbed
if 'dualtor' not in tbinfo['topo']['name'] or not active_standby_ports:
logger.info('Skipping toggle on non-dualtor testbed or active-active dualtor topo.')
return

if cable_type == CableType.active_standby:
_toggle_all_simulator_ports(mux_server_url, LOWER_TOR, tbinfo)
_toggle_all_simulator_ports_to_target_dut(duthosts[1].hostname, duthosts, mux_server_url, tbinfo)


def _probe_mux_ports(duthosts, ports):
Expand Down

0 comments on commit e96fb3a

Please sign in to comment.