Skip to content

Commit

Permalink
Use conditional mark to skip traffic test and remove temporary fixture (
Browse files Browse the repository at this point in the history
sonic-net#14434)

What is the motivation for this PR?
Previously, we use temporary workaround sonic-net#13602 to skip traffic test in VS platform because conditional mark could only match longest prefix, but now, it's fixed in sonic-net#14395, so it would be better to use a common way -- conditional mark to skip traffic test but not hardcode

How did you do it?
Remove skip_traffic_test fixture in duthost_utils and use fixture in ptfhost_utils
Add condition with tests need to skip traffic test in tests_mark_conditions_skip_traffic_test.yaml
  • Loading branch information
xwjiang-ms authored and hdwhdw committed Sep 20, 2024
1 parent 884c15f commit 4d0babd
Show file tree
Hide file tree
Showing 35 changed files with 111 additions and 102 deletions.
3 changes: 1 addition & 2 deletions tests/acl/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer, LogAnalyzerError
from tests.common.config_reload import config_reload
from tests.common.fixtures.ptfhost_utils import copy_arp_responder_py, run_garp_service, change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.dualtor.dual_tor_mock import mock_server_base_ip_addr # noqa F401
from tests.common.helpers.constants import DEFAULT_NAMESPACE
from tests.common.utilities import wait_until, get_upstream_neigh_type, get_downstream_neigh_type, check_msg_in_syslog
Expand Down
12 changes: 0 additions & 12 deletions tests/common/fixtures/duthost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,15 +849,3 @@ def assert_addr_in_output(addr_set: Dict[str, List], hostname: str,
pytest_assert(addr not in cmd_output,
f"{hostname} {cmd_desc} still with addr {addr}")
logger.info(f"{addr} not exists in the output of {cmd_desc} which is expected")


# Currently, conditional mark would only match longest prefix,
# so our mark in tests_mark_conditions_skip_traffic_test.yaml couldn't be matched.
# Use a temporary work around to add skip_traffic_test fixture here,
# once conditional mark support add all matches, will remove this code.
@pytest.fixture(scope="module")
def skip_traffic_test(duthosts, rand_one_dut_hostname):
duthost = duthosts[rand_one_dut_hostname]
if duthost.facts["asic_type"] == "vs":
return True
return False
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ arp/test_wr_arp.py:
conditions:
- "asic_type in ['vs']"

#######################################
##### copp #####
#######################################
copp/test_copp.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

#######################################
##### decap #####
#######################################
Expand Down Expand Up @@ -121,6 +130,48 @@ dualtor/test_tunnel_memory_leak.py:
conditions:
- "asic_type in ['vs']"

#######################################
##### dualtor_io #####
#######################################
dualtor_io/test_heartbeat_failure.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

dualtor_io/test_link_drop.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

dualtor_io/test_link_failure.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

dualtor_io/test_normal_op.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

dualtor_io/test_tor_bgp_failure.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

#######################################
##### dualtor_mgmt #####
#######################################
dualtor_mgmt/test_ingress_drop.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

#######################################
##### ecmp #####
#######################################
Expand Down Expand Up @@ -240,6 +291,15 @@ sub_port_interfaces/test_sub_port_interfaces.py:
conditions:
- "asic_type in ['vs']"

#######################################
##### vlan #####
#######################################
vlan/test_vlan_ping.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

#######################################
##### vxlan #####
#######################################
Expand All @@ -266,3 +326,9 @@ vxlan/test_vxlan_ecmp.py:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"

vxlan/test_vxlan_ecmp_switchover.py:
skip_traffic_test:
reason: "Skip traffic test for KVM testbed"
conditions:
- "asic_type in ['vs']"
3 changes: 1 addition & 2 deletions tests/copp/test_copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
# Module-level fixtures
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401

pytestmark = [
pytest.mark.topology("t0", "t1", "t2", "m0", "mx")
Expand Down
4 changes: 1 addition & 3 deletions tests/decap/test_decap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
from tests.common.fixtures.ptfhost_utils import set_ptf_port_mapping_mode # noqa F401
# from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import ptf_test_port_map_active_active
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.fib_utils import fib_info_files # noqa F401
from tests.common.fixtures.fib_utils import single_fib_for_duts # noqa F401
from tests.ptf_runner import ptf_runner
Expand Down
3 changes: 1 addition & 2 deletions tests/drop_packets/drop_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from tests.common.helpers.constants import DEFAULT_NAMESPACE
from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer, LogAnalyzerError
from tests.common import config_reload
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401

RX_DRP = "RX_DRP"
RX_ERR = "RX_ERR"
Expand Down
3 changes: 1 addition & 2 deletions tests/drop_packets/test_drop_counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
test_acl_egress_drop # noqa F401
from tests.common.helpers.constants import DEFAULT_NAMESPACE
from tests.common.fixtures.conn_graph_facts import enum_fanout_graph_facts # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401

pytestmark = [
pytest.mark.topology("any")
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor/test_ipinip.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.utilities import dump_scapy_packet_show_output
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
Expand Down
4 changes: 1 addition & 3 deletions tests/dualtor/test_orchagent_active_tor_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
# from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import wait_until

Expand Down
4 changes: 1 addition & 3 deletions tests/dualtor/test_orchagent_mac_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
# from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.utilities import dump_scapy_packet_show_output


Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor/test_orchagent_slb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.helpers import bgp
from tests.common.utilities import is_ipv4_address

Expand Down
18 changes: 8 additions & 10 deletions tests/dualtor/test_orchagent_standby_tor_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
from tests.common.dualtor.dual_tor_utils import build_packet_to_server
from tests.common.dualtor.dual_tor_utils import crm_neighbor_checker
from tests.common.dualtor.dual_tor_utils import add_nexthop_routes, remove_static_routes
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa: F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa: F401
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa: F401
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa: F401
# from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.helpers.assertions import pytest_assert as pt_assert
from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor # noqa: F401
from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor # noqa F401
from tests.common.dualtor.server_traffic_utils import ServerTrafficMonitor
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports # noqa: F401
from tests.common.dualtor.tor_failure_utils import shutdown_bgp_sessions # noqa: F401
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports # noqa F401
from tests.common.dualtor.tor_failure_utils import shutdown_bgp_sessions # noqa F401
from tests.common.utilities import wait_until


Expand Down
5 changes: 1 addition & 4 deletions tests/dualtor/test_standby_tor_upstream_mux_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
from tests.common.config_reload import config_reload
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses, run_garp_service, \
run_icmp_responder # noqa F401
# from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
run_icmp_responder, skip_traffic_test # noqa F401

logger = logging.getLogger(__file__)

Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor/test_tor_ecn.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.utilities import dump_scapy_packet_show_output
from tests.common.dualtor.tunnel_traffic_utils import derive_queue_id_from_dscp, derive_out_dscp_from_inner_dscp
from tests.common.dualtor.dual_tor_utils import config_active_active_dualtor_active_standby # noqa F401
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor/test_tunnel_memory_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
from tests.common.dualtor.dual_tor_utils import delete_neighbor
from tests.common.helpers.dut_utils import get_program_info
from tests.common.fixtures.ptfhost_utils import run_garp_service, run_icmp_responder # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.utilities import wait_until


Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor_io/test_heartbeat_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from tests.common.dualtor.tor_failure_utils import shutdown_tor_heartbeat # noqa F401
from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, \
copy_ptftests_directory, change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC
from tests.common.dualtor.dual_tor_common import cable_type # noqa F401
from tests.common.dualtor.dual_tor_common import CableType
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor_io/test_link_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service # noqa F401
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC
from tests.common.dualtor.dual_tor_common import ActiveActivePortID
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor_io/test_link_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor # noqa F401
from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, \
copy_ptftests_directory, change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
from tests.common.dualtor.dual_tor_common import cable_type # noqa F401
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor_io/test_normal_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
from tests.common.dualtor.dual_tor_utils import check_simulator_flap_counter # noqa F401
from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, \
copy_ptftests_directory, change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC, CONFIG_RELOAD_ALLOWED_DISRUPTION_SEC
from tests.common.utilities import wait_until
from tests.common.helpers.assertions import pytest_assert
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor_io/test_tor_bgp_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from tests.common.dualtor.tor_failure_utils import shutdown_bgp_sessions_on_duthost
from tests.common.fixtures.ptfhost_utils import run_icmp_responder, run_garp_service, \
copy_ptftests_directory, change_mac_addresses # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401
from tests.common.dualtor.tunnel_traffic_utils import tunnel_traffic_monitor # noqa F401
from tests.common.dualtor.constants import MUX_SIM_ALLOWED_DISRUPTION_SEC
from tests.common.dualtor.dual_tor_common import cable_type # noqa F401
Expand Down
3 changes: 1 addition & 2 deletions tests/dualtor_mgmt/test_ingress_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from tests.common.dualtor.nic_simulator_control import mux_status_from_nic_simulator # noqa F401
from tests.common.dualtor.nic_simulator_control import stop_nic_simulator # noqa F401
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa F401

from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import wait_until
Expand Down
4 changes: 1 addition & 3 deletions tests/everflow/test_everflow_per_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

from .everflow_test_utilities import setup_info, EVERFLOW_DSCP_RULES # noqa: F401
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor # noqa: F401
# from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa: F401
# Temporary work around to add skip_traffic_test fixture from duthost_utils
from tests.common.fixtures.duthost_utils import skip_traffic_test # noqa: F401
from tests.common.fixtures.ptfhost_utils import skip_traffic_test # noqa: F401

pytestmark = [
pytest.mark.topology("any")
Expand Down
Loading

0 comments on commit 4d0babd

Please sign in to comment.