From e80445f7fc59bbb010ceddac355620269dd7248e Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Wed, 18 May 2022 10:51:37 -0700 Subject: [PATCH] [dualtor][non-functional] add test template for `active-active` cable type (#5545) ### Description of PR Summary: Fixes # (issue) Submitting this PR to re-add test template for `active-active` cable type. The change (#5424) was reverted earlier due to regression. sign-off: Jing Zhang zhangjing@microsoft.com ### Type of change - [x] Test case(new/improvement) #### What is the motivation for this PR? Re-add the roadmap for supporting `active-active` dualtor_io testcases. #### How did you do it? 1. Pick the commit from the original PR. 2. Import `cable_type` fixture where the modified fixtures are requested. 3. Update `data_plane_utils.py` to re-use `DualtorIO` object. #### How did you verify/test it? Tested `test_normal_op` and `test_link_failure`, all passed. --- tests/common/dualtor/__init__.py | 1 + tests/common/dualtor/control_plane_utils.py | 62 ++++++++++++++----- tests/common/dualtor/data_plane_utils.py | 33 +++++++--- tests/common/dualtor/dual_tor_common.py | 14 +++++ tests/common/dualtor/dual_tor_io.py | 25 ++++++-- tests/common/dualtor/mux_simulator_control.py | 18 ++++-- tests/common/dualtor/nic_simulator_control.py | 57 +++++++++++++++++ tests/dualtor/test_orchagent_slb.py | 1 + tests/dualtor/test_tunnel_memory_leak.py | 1 + tests/dualtor_io/test_heartbeat_failure.py | 1 + tests/dualtor_io/test_link_drop.py | 1 + tests/dualtor_io/test_link_failure.py | 1 + tests/dualtor_io/test_normal_op.py | 18 ++++-- tests/dualtor_io/test_tor_bgp_failure.py | 1 + tests/dualtor_io/test_tor_failure.py | 1 + tests/radv/test_radv_ipv6_ra.py | 1 + 16 files changed, 196 insertions(+), 40 deletions(-) create mode 100644 tests/common/dualtor/dual_tor_common.py create mode 100644 tests/common/dualtor/nic_simulator_control.py diff --git a/tests/common/dualtor/__init__.py b/tests/common/dualtor/__init__.py index bf9bb1d375..92dfae0730 100644 --- a/tests/common/dualtor/__init__.py +++ b/tests/common/dualtor/__init__.py @@ -1,2 +1,3 @@ from tests.common.dualtor.dual_tor_utils import * from tests.common.dualtor.mux_simulator_control import * +from tests.common.dualtor.nic_simulator_control import * diff --git a/tests/common/dualtor/control_plane_utils.py b/tests/common/dualtor/control_plane_utils.py index 3b41cd1074..ee254d1c82 100644 --- a/tests/common/dualtor/control_plane_utils.py +++ b/tests/common/dualtor/control_plane_utils.py @@ -1,7 +1,9 @@ """Contains functions used to verify control plane(APP_DB, STATE_DB) values.""" +import collections import json import logging +from tests.common.dualtor.dual_tor_common import CableType from tests.common.helpers.assertions import pytest_assert from tests.common.utilities import wait_until @@ -39,7 +41,7 @@ class DBChecker: - def __init__(self, duthost, state, health, intf_names='all'): + def __init__(self, duthost, state, health, intf_names='all', cable_type=CableType.active_standby): """ Create a DBChecker object Args: @@ -51,11 +53,14 @@ def __init__(self, duthost, state, health, intf_names='all'): MUX_LINKMGR_TABLE table (only needed for STATE_DB) intf_names: A list of the PORTNAME to check in each table, or 'all' (by default) to check all MUX_CABLE interfaces + cable_type: Select ports with specified cable_type to check. """ self.duthost = duthost self.state = state self.health = health self.intf_names = intf_names + self.cable_type = cable_type + self._parse_intf_names() self.mismatch_ports = {} def _dump_db(self, db, key_pattern): @@ -77,6 +82,19 @@ def verify_db(self, db): indent=4, sort_keys=True))) + def _parse_intf_names(self): + mux_cable_table = self.duthost.get_running_config_facts()['MUX_CABLE'] + selected_intfs = set( + _ for _ in mux_cable_table if mux_cable_table[_].get("cable_type", CableType.active_standby) == self.cable_type + ) + if self.intf_names == 'all': + self.intf_names = selected_intfs + else: + for intf in self.intf_names: + if intf not in selected_intfs: + raise ValueError("Interface %s not in %s cable type" % (intf, self.cable_type)) + self.intf_names = set(self.intf_names) + def get_mismatched_ports(self, db): """ Query db on `tor_host` and check if the mux-related fields match the @@ -91,10 +109,6 @@ def get_mismatched_ports(self, db): logger.info("Verifying {} values on {}: " "expected state = {}, expected health = {}".format( DB_NAME_MAP[db], self.duthost, self.state, self.health)) - if self.intf_names == 'all': - mux_intfs = self.duthost.get_running_config_facts()['MUX_CABLE'].keys() - else: - mux_intfs = self.intf_names mismatch_ports = {} separator = DB_SEPARATOR_MAP[db] @@ -112,7 +126,7 @@ def get_mismatched_ports(self, db): else: target_value = self.state - for intf_name in mux_intfs: + for intf_name in self.intf_names: table_key = '{}{}{}'.format(table, separator, intf_name) if db_dump[table_key]['value'][field] != target_value: @@ -123,17 +137,33 @@ def get_mismatched_ports(self, db): return not bool(mismatch_ports) -def verify_tor_states(expected_active_host, expected_standby_host, - expected_standby_health='healthy', intf_names='all'): +def verify_tor_states( + expected_active_host, expected_standby_host, + expected_standby_health='healthy', intf_names='all', + cable_type=CableType.active_standby +): """ Verifies that the expected states for active and standby ToRs are reflected in APP_DB and STATE_DB on each device """ - - active_db_checker = DBChecker(expected_active_host, 'active', 'healthy', intf_names=intf_names) - standby_db_checker = DBChecker(expected_standby_host, 'standby', expected_standby_health, intf_names=intf_names) - - active_db_checker.verify_db(APP_DB) - active_db_checker.verify_db(STATE_DB) - standby_db_checker.verify_db(APP_DB) - standby_db_checker.verify_db(STATE_DB) + if isinstance(expected_active_host, collections.Iterable): + for duthost in expected_active_host: + db_checker = DBChecker(duthost, 'active', 'healthy', intf_names=intf_names, cable_type=cable_type) + db_checker.verify_db(APP_DB) + db_checker.verify_db(STATE_DB) + elif expected_active_host is not None: + duthost = expected_active_host + db_checker = DBChecker(duthost, 'active', 'healthy', intf_names=intf_names, cable_type=cable_type) + db_checker.verify_db(APP_DB) + db_checker.verify_db(STATE_DB) + + if isinstance(expected_standby_host, collections.Iterable): + for duthost in expected_standby_host: + db_checker = DBChecker(duthost, 'standby', expected_standby_health, intf_names=intf_names, cable_type=cable_type) + db_checker.verify_db(APP_DB) + db_checker.verify_db(STATE_DB) + elif expected_standby_host is not None: + duthost = expected_standby_host + db_checker = DBChecker(duthost, 'standby', expected_standby_health, intf_names=intf_names) + db_checker.verify_db(APP_DB) + db_checker.verify_db(STATE_DB) diff --git a/tests/common/dualtor/data_plane_utils.py b/tests/common/dualtor/data_plane_utils.py index 932713c9bc..71eda0e9cd 100644 --- a/tests/common/dualtor/data_plane_utils.py +++ b/tests/common/dualtor/data_plane_utils.py @@ -1,6 +1,10 @@ +import collections import pytest import json import time + +from tests.common.dualtor.dual_tor_common import cable_type # lgtm[py/unused-import] +from tests.common.dualtor.dual_tor_common import CableType from tests.common.dualtor.dual_tor_io import DualTorIO from tests.common.helpers.assertions import pytest_assert from tests.common.utilities import InterruptableThread @@ -13,7 +17,7 @@ logger = logging.getLogger(__name__) -def get_standbyhost(duthosts, activehost): +def get_peerhost(duthosts, activehost): if duthosts[0] == activehost: return duthosts[1] else: @@ -127,12 +131,19 @@ def verify_and_report(tor_IO, verify, delay, allowed_disruption): return tor_IO.get_test_results() -def run_test(duthosts, activehost, ptfhost, ptfadapter, action, - tbinfo, tor_vlan_port, send_interval, traffic_direction, stop_after): +def run_test( + duthosts, activehost, ptfhost, ptfadapter, action, + tbinfo, tor_vlan_port, send_interval, traffic_direction, + stop_after, cable_type=CableType.active_standby +): io_ready = threading.Event() - standbyhost = get_standbyhost(duthosts, activehost) - tor_IO = DualTorIO(activehost, standbyhost, ptfhost, ptfadapter, tbinfo, - io_ready, tor_vlan_port=tor_vlan_port, send_interval=send_interval) + + peerhost = get_peerhost(duthosts, activehost) + tor_IO = DualTorIO( + activehost, peerhost, ptfhost, ptfadapter, tbinfo, + io_ready, tor_vlan_port=tor_vlan_port, send_interval=send_interval, cable_type=cable_type + ) + if traffic_direction == "server_to_t1": traffic_generator = tor_IO.generate_from_server_to_t1 elif traffic_direction == "t1_to_server": @@ -177,7 +188,7 @@ def cleanup(ptfadapter, duthosts_list): @pytest.fixture -def send_t1_to_server_with_action(duthosts, ptfhost, ptfadapter, tbinfo): +def send_t1_to_server_with_action(duthosts, ptfhost, ptfadapter, tbinfo, cable_type): """ Starts IO test from T1 router to server. As part of IO test the background thread sends and sniffs packets. @@ -226,7 +237,8 @@ def t1_to_server_io_test(activehost, tor_vlan_port=None, tor_IO = run_test(duthosts, activehost, ptfhost, ptfadapter, action, tbinfo, tor_vlan_port, send_interval, - traffic_direction="t1_to_server", stop_after=stop_after) + traffic_direction="t1_to_server", stop_after=stop_after, + cable_type=cable_type) # If a delay is allowed but no numebr of allowed disruptions # is specified, default to 1 allowed disruption @@ -241,7 +253,7 @@ def t1_to_server_io_test(activehost, tor_vlan_port=None, @pytest.fixture -def send_server_to_t1_with_action(duthosts, ptfhost, ptfadapter, tbinfo): +def send_server_to_t1_with_action(duthosts, ptfhost, ptfadapter, tbinfo, cable_type): """ Starts IO test from server to T1 router. As part of IO test the background thread sends and sniffs packets. @@ -290,7 +302,8 @@ def server_to_t1_io_test(activehost, tor_vlan_port=None, tor_IO = run_test(duthosts, activehost, ptfhost, ptfadapter, action, tbinfo, tor_vlan_port, send_interval, - traffic_direction="server_to_t1", stop_after=stop_after) + traffic_direction="server_to_t1", stop_after=stop_after, + cable_type=cable_type) # If a delay is allowed but no numebr of allowed disruptions # is specified, default to 1 allowed disruption diff --git a/tests/common/dualtor/dual_tor_common.py b/tests/common/dualtor/dual_tor_common.py new file mode 100644 index 0000000000..0f7ba65462 --- /dev/null +++ b/tests/common/dualtor/dual_tor_common.py @@ -0,0 +1,14 @@ +"""DualToR related common utilities for other modules.""" +import pytest + + +class CableType(object): + """Dualtor cable type.""" + active_active = "active-active" + active_standby = "active-standby" + + +@pytest.fixture(params=[CableType.active_standby]) +def cable_type(request): + """Dualtor cable type.""" + return request.param diff --git a/tests/common/dualtor/dual_tor_io.py b/tests/common/dualtor/dual_tor_io.py index ecfb052df7..d57d5aa4c6 100644 --- a/tests/common/dualtor/dual_tor_io.py +++ b/tests/common/dualtor/dual_tor_io.py @@ -12,6 +12,7 @@ from operator import itemgetter from itertools import groupby +from tests.common.dualtor.dual_tor_common import CableType from tests.common.utilities import InterruptableThread from natsort import natsorted from collections import defaultdict @@ -28,8 +29,10 @@ class DualTorIO: + """Class to conduct IO over ports in `active-standby` mode.""" + def __init__(self, activehost, standbyhost, ptfhost, ptfadapter, tbinfo, - io_ready, tor_vlan_port=None, send_interval=0.01): + io_ready, tor_vlan_port=None, send_interval=0.01, cable_type=CableType.active_standby): self.tor_pc_intf = None self.tor_vlan_intf = tor_vlan_port self.duthost = activehost @@ -41,6 +44,8 @@ def __init__(self, activehost, standbyhost, ptfhost, ptfadapter, tbinfo, self.active_mac = self.dut_mac self.standby_mac = standbyhost.facts["router_mac"] + self.cable_type = cable_type + self.dataplane = self.ptfadapter.dataplane self.dataplane.flush() self.test_results = dict() @@ -74,11 +79,14 @@ def __init__(self, activehost, standbyhost, ptfhost, ptfadapter, tbinfo, self.vlan_mac = vlan_table[vlan_name]['mac'] self.mux_cable_table = config_facts['MUX_CABLE'] + self.test_interfaces = self._select_test_interfaces() + self.ptf_intf_to_server_ip_map = self._generate_vlan_servers() self.__configure_arp_responder() logger.info("VLAN interfaces: {}".format(str(self.vlan_interfaces))) logger.info("PORTCHANNEL interfaces: {}".format(str(self.tor_pc_intfs))) + logger.info("Selected testing interfaces: %s", self.test_interfaces) self.time_to_listen = 300.0 self.sniff_time_incr = 0 @@ -99,7 +107,7 @@ def __init__(self, activehost, standbyhost, ptfhost, ptfadapter, tbinfo, if self.tor_vlan_intf: self.packets_per_server = self.packets_to_send else: - self.packets_per_server = self.packets_to_send // len(self.vlan_interfaces) + self.packets_per_server = self.packets_to_send // len(self.test_interfaces) self.all_packets = [] @@ -114,7 +122,7 @@ def _generate_vlan_servers(self): logger.info("ALL server address:\n {}".format(server_ip_list)) ptf_to_server_map = dict() - for i, vlan_intf in enumerate(natsorted(self.vlan_interfaces)): + for i, vlan_intf in enumerate(natsorted(self.test_interfaces)): ptf_intf = self.tor_to_ptf_intf_map[vlan_intf] addr = server_ip_list[i] ptf_to_server_map[ptf_intf] = [str(addr)] @@ -122,6 +130,14 @@ def _generate_vlan_servers(self): logger.debug('VLAN intf to server IP map: {}'.format(json.dumps(ptf_to_server_map, indent=4, sort_keys=True))) return ptf_to_server_map + def _select_test_interfaces(self): + """Select DUT interfaces that is in `active-standby` cable type.""" + test_interfaces = [] + for port, port_config in natsorted(self.mux_cable_table.items()): + if port_config.get("cable_type", CableType.active_standby) == self.cable_type: + test_interfaces.append(port) + return test_interfaces + def __configure_arp_responder(self): """ @summary: Generate ARP responder configuration using vlan_host_map. @@ -258,7 +274,7 @@ def generate_from_server_to_t1(self): # use only the connected server else: # Otherwise send packets to all servers - vlan_src_intfs = self.vlan_interfaces + vlan_src_intfs = self.test_interfaces ptf_intf_to_mac_map = {} @@ -646,3 +662,4 @@ def check_tcp_payload(self, packet): return True except Exception as err: return False + diff --git a/tests/common/dualtor/mux_simulator_control.py b/tests/common/dualtor/mux_simulator_control.py index 0db8103bdc..36fd531e28 100644 --- a/tests/common/dualtor/mux_simulator_control.py +++ b/tests/common/dualtor/mux_simulator_control.py @@ -7,6 +7,8 @@ import requests from tests.common import utilities +from tests.common.dualtor.dual_tor_common import cable_type # lgtm[py/unused-import] +from tests.common.dualtor.dual_tor_common import CableType from tests.common.helpers.assertions import pytest_assert from tests.common.dualtor.constants import UPPER_TOR, LOWER_TOR, TOGGLE, RANDOM, NIC, DROP, OUTPUT, FLAP_COUNTER, CLEAR_FLAP_COUNTER, RESET @@ -342,25 +344,29 @@ def _toggle(side): _toggle_all_simulator_ports(mux_server_url, side, tbinfo) return _toggle + @pytest.fixture -def toggle_all_simulator_ports_to_upper_tor(mux_server_url, tbinfo): +def toggle_all_simulator_ports_to_upper_tor(mux_server_url, tbinfo, cable_type): """ - A function level fixture to toggle all ports to upper_tor + 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 """ - _toggle_all_simulator_ports(mux_server_url, UPPER_TOR, tbinfo) + if cable_type == CableType.active_standby: + _toggle_all_simulator_ports(mux_server_url, UPPER_TOR, tbinfo) + @pytest.fixture -def toggle_all_simulator_ports_to_lower_tor(mux_server_url, tbinfo): +def toggle_all_simulator_ports_to_lower_tor(mux_server_url, tbinfo, cable_type): """ - A function level fixture to toggle all ports to lower_tor + 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 """ - _toggle_all_simulator_ports(mux_server_url, LOWER_TOR, tbinfo) + if cable_type == CableType.active_standby: + _toggle_all_simulator_ports(mux_server_url, LOWER_TOR, tbinfo) def _are_muxcables_active(duthost): diff --git a/tests/common/dualtor/nic_simulator_control.py b/tests/common/dualtor/nic_simulator_control.py new file mode 100644 index 0000000000..13a4ee7e42 --- /dev/null +++ b/tests/common/dualtor/nic_simulator_control.py @@ -0,0 +1,57 @@ +"""Control utilities to interacts with nic_simulator.""" +import pytest + +from tests.common.dualtor.dual_tor_common import cable_type # lgtm[py/unused-import] +from tests.common.dualtor.dual_tor_common import CableType + +__all__ = [ + "nic_simulator_info", + "nic_simulator_url", + "toggle_all_ports_both_tors_admin_forwarding_state_to_active" +] + + +class ForwardingState(object): + """Forwarding state.""" + ACTIVE = True + STANDBY = False + + +@pytest.fixture(scope="session") +def nic_simulator_info(request, tbinfo): + """Fixture to gather nic_simulator related infomation.""" + pass + + +@pytest.fixture(scope="session") +def nic_simulator_url(nic_simulator_info): + """Fixture to return the nic_simulator url.""" + pass + + +def set_upper_tor_admin_forwarding_state(nic_simulator_url, port, state): + """Set upper ToR admin forwarding state.""" + pass + + +def set_lower_tor_admin_forwarding_state(nic_simulator_url, port, state): + """Set lower ToR admin forwarding state.""" + pass + + +def set_all_ports_upper_tor_admin_forwarding_state(nic_simulator_url, state): + """Set all ports lower ToR admin forwarding state.""" + pass + + +def set_all_ports_lower_tor_admin_forwarding_state(nic_simulator_url, state): + """Set all ports lower ToR admin forwarding state.""" + pass + + +@pytest.fixture +def toggle_all_ports_both_tors_admin_forwarding_state_to_active(nic_simulator_url, cable_type): + """A function level fixture to toggle both ToRs' admin forwarding state to active for all active-active ports.""" + if cable_type == CableType.active_active: + set_all_ports_upper_tor_admin_forwarding_state(nic_simulator_url, ForwardingState.ACTIVE) + set_all_ports_lower_tor_admin_forwarding_state(nic_simulator_url, ForwardingState.ACTIVE) diff --git a/tests/dualtor/test_orchagent_slb.py b/tests/dualtor/test_orchagent_slb.py index f88bf8a68d..b2d85bc372 100644 --- a/tests/dualtor/test_orchagent_slb.py +++ b/tests/dualtor/test_orchagent_slb.py @@ -13,6 +13,7 @@ from tests.common.dualtor.dual_tor_utils import get_t1_ptf_ports from tests.common.dualtor.dual_tor_utils import force_active_tor # lgtm[py/unused-import] from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor +from tests.common.dualtor.dual_tor_common import cable_type from tests.common.dualtor.server_traffic_utils import ServerTrafficMonitor from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor from tests.common.fixtures.ptfhost_utils import run_icmp_responder diff --git a/tests/dualtor/test_tunnel_memory_leak.py b/tests/dualtor/test_tunnel_memory_leak.py index 166f8b5bd7..b24694bd5b 100644 --- a/tests/dualtor/test_tunnel_memory_leak.py +++ b/tests/dualtor/test_tunnel_memory_leak.py @@ -13,6 +13,7 @@ from threading import Thread from ptf import testutils from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor +from tests.common.dualtor.dual_tor_common import cable_type from tests.common.dualtor.dual_tor_utils import upper_tor_host, lower_tor_host from tests.common.dualtor.server_traffic_utils import ServerTrafficMonitor from tests.common.helpers.assertions import pytest_assert diff --git a/tests/dualtor_io/test_heartbeat_failure.py b/tests/dualtor_io/test_heartbeat_failure.py index 2db9bc6a3a..924e0bf74f 100644 --- a/tests/dualtor_io/test_heartbeat_failure.py +++ b/tests/dualtor_io/test_heartbeat_failure.py @@ -9,6 +9,7 @@ from tests.common.dualtor.tor_failure_utils import shutdown_tor_heartbeat # lgtm[py/unused-import] from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, copy_ptftests_directory, change_mac_addresses # lgtm[py/unused-import] from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC +from tests.common.dualtor.dual_tor_common import cable_type pytestmark = [ pytest.mark.topology("dualtor") diff --git a/tests/dualtor_io/test_link_drop.py b/tests/dualtor_io/test_link_drop.py index 8bcfffc0c0..3209f966d3 100644 --- a/tests/dualtor_io/test_link_drop.py +++ b/tests/dualtor_io/test_link_drop.py @@ -16,6 +16,7 @@ from tests.common.fixtures.ptfhost_utils import change_mac_addresses # lgtm[py/unused-import] from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # lgtm[py/unused-import] from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC +from tests.common.dualtor.dual_tor_common import cable_type pytestmark = [ pytest.mark.topology("dualtor") diff --git a/tests/dualtor_io/test_link_failure.py b/tests/dualtor_io/test_link_failure.py index 46e2ab01b7..7628890427 100644 --- a/tests/dualtor_io/test_link_failure.py +++ b/tests/dualtor_io/test_link_failure.py @@ -8,6 +8,7 @@ from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor # lgtm[py/unused-import] from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, copy_ptftests_directory, change_mac_addresses # lgtm[py/unused-import] from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC +from tests.common.dualtor.dual_tor_common import cable_type pytestmark = [ pytest.mark.topology("dualtor") diff --git a/tests/dualtor_io/test_normal_op.py b/tests/dualtor_io/test_normal_op.py index d8e8f23a6e..7c8ee77319 100644 --- a/tests/dualtor_io/test_normal_op.py +++ b/tests/dualtor_io/test_normal_op.py @@ -3,11 +3,15 @@ from tests.common.config_reload import config_reload from tests.common.dualtor.control_plane_utils import verify_tor_states from tests.common.dualtor.data_plane_utils import send_t1_to_server_with_action, send_server_to_t1_with_action # lgtm[py/unused-import] +from tests.common.dualtor.dual_tor_common import cable_type # lgtm[py/unused-import] +from tests.common.dualtor.dual_tor_common import CableType # lgtm[py/unused-import] from tests.common.dualtor.dual_tor_utils import upper_tor_host, lower_tor_host, force_active_tor # lgtm[py/unused-import] from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor # lgtm[py/unused-import] +from tests.common.dualtor.nic_simulator_control import toggle_all_ports_both_tors_admin_forwarding_state_to_active # lgtm[py/unused-import] from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, copy_ptftests_directory, change_mac_addresses # lgtm[py/unused-import] from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC, CONFIG_RELOAD_ALLOWED_DISRUPTION_SEC + pytestmark = [ pytest.mark.topology("dualtor") ] @@ -15,12 +19,18 @@ def test_normal_op_upstream(upper_tor_host, lower_tor_host, send_server_to_t1_with_action, - toggle_all_simulator_ports_to_upper_tor): + toggle_all_simulator_ports_to_upper_tor, + toggle_all_ports_both_tors_admin_forwarding_state_to_active, + cable_type): """Send upstream traffic and confirm no disruption or switchover occurs""" send_server_to_t1_with_action(upper_tor_host, verify=True, stop_after=60) - verify_tor_states(expected_active_host=upper_tor_host, - expected_standby_host=lower_tor_host) - + if cable_type == CableType.active_standby: + verify_tor_states(expected_active_host=upper_tor_host, + expected_standby_host=lower_tor_host) + else: + verify_tor_states(expected_active_host=[upper_tor_host, lower_tor_host], + cable_type=cable_type) + def test_normal_op_downstream_active(upper_tor_host, lower_tor_host, send_t1_to_server_with_action, diff --git a/tests/dualtor_io/test_tor_bgp_failure.py b/tests/dualtor_io/test_tor_bgp_failure.py index 9157c32d77..5838dfe7ca 100644 --- a/tests/dualtor_io/test_tor_bgp_failure.py +++ b/tests/dualtor_io/test_tor_bgp_failure.py @@ -8,6 +8,7 @@ from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, copy_ptftests_directory, change_mac_addresses # lgtm[py/unused-import] from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC +from tests.common.dualtor.dual_tor_common import cable_type pytestmark = [ pytest.mark.topology("dualtor") diff --git a/tests/dualtor_io/test_tor_failure.py b/tests/dualtor_io/test_tor_failure.py index 6330781759..aa6457e822 100644 --- a/tests/dualtor_io/test_tor_failure.py +++ b/tests/dualtor_io/test_tor_failure.py @@ -9,6 +9,7 @@ from tests.common.dualtor.tor_failure_utils import reboot_tor, tor_blackhole_traffic, wait_for_device_reachable # lgtm[py/unused-import] from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, change_mac_addresses # lgtm[py/unused-import] from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC +from tests.common.dualtor.dual_tor_common import cable_type logger = logging.getLogger(__name__) diff --git a/tests/radv/test_radv_ipv6_ra.py b/tests/radv/test_radv_ipv6_ra.py index 5efe7470d2..cae707650f 100644 --- a/tests/radv/test_radv_ipv6_ra.py +++ b/tests/radv/test_radv_ipv6_ra.py @@ -10,6 +10,7 @@ from tests.common.fixtures.ptfhost_utils import run_icmp_responder # lgtm[py/unused-import] from tests.common.dualtor.dual_tor_mock import mock_server_base_ip_addr # lgtm[py/unused-import] from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor +from tests.common.dualtor.dual_tor_common import cable_type from tests.common.helpers.assertions import pytest_assert from tests.ptf_runner import ptf_runner