Skip to content

Commit

Permalink
Added support based on PR 15099
Browse files Browse the repository at this point in the history
  • Loading branch information
sreejithsreekumaran committed Nov 21, 2024
1 parent 403c970 commit bde32ca
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 78 deletions.
52 changes: 22 additions & 30 deletions tests/snappi_tests/multidut/ecn/files/multidut_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
snappi_api # noqa: F401
from tests.common.snappi_tests.snappi_helpers import get_dut_port_id
from tests.common.snappi_tests.common_helpers import pfc_class_enable_vector, config_wred, \
enable_ecn, config_ingress_lossless_buffer_alpha, stop_pfcwd, disable_packet_aging, \
enable_ecn, config_ingress_lossless_buffer_alpha, stop_pfcwd, disable_packet_aging,\
config_capture_pkt, traffic_flow_mode, calc_pfc_pause_flow_rate # noqa: F401
from tests.common.snappi_tests.read_pcap import get_ipv4_pkts
from tests.common.snappi_tests.snappi_test_params import SnappiTestParams
Expand Down Expand Up @@ -234,6 +234,26 @@ def run_ecn_test(api,
return result


def toggle_dut_port_state(api):
# Get the current configuration
config = api.get_config()
# Collect all port names
port_names = [port.name for port in config.ports]
# Create a link state object for all ports
link_state = api.link_state()
# Apply the state to all ports
link_state.port_names = port_names
# Set all ports down (shut)
link_state.state = link_state.DOWN
api.set_link_state(link_state)
logger.info("All Snappi ports are set to DOWN")
time.sleep(0.2)
# Unshut all ports
link_state.state = link_state.UP
api.set_link_state(link_state)
logger.info("All Snappi ports are set to UP")


def run_ecn_marking_port_toggle_test(
api,
testbed_config,
Expand Down Expand Up @@ -279,18 +299,6 @@ def run_ecn_marking_port_toggle_test(
rx_port = snappi_extra_params.multi_dut_params.multi_dut_ports[0]
egress_duthost = rx_port['duthost']

tx_port = snappi_extra_params.multi_dut_params.multi_dut_ports[1]
ingress_duthost = tx_port['duthost']

pytest_assert(testbed_config is not None, 'Failed to get L2/3 testbed config')

logger.info("Stopping PFC watchdog")
stop_pfcwd(egress_duthost, rx_port['asic_value'])
stop_pfcwd(ingress_duthost, tx_port['asic_value'])
logger.info("Disabling packet aging if necessary")
disable_packet_aging(egress_duthost)
disable_packet_aging(ingress_duthost)

duthost = egress_duthost

init_ctr_3 = get_npu_voq_queue_counters(duthost, dut_port, test_prio_list[0])
Expand Down Expand Up @@ -380,23 +388,7 @@ def run_ecn_marking_port_toggle_test(

verify_ecn_counters(ecn_counters)

# Get the current configuration
config = api.get_config()
# Collect all port names
port_names = [port.name for port in config.ports]
# Create a link state object for all ports
link_state = api.link_state()
# Apply the state to all ports
link_state.port_names = port_names
# Set all ports down (shut)
link_state.state = link_state.DOWN
api.set_link_state(link_state)
logger.info("All Snappi ports are set to DOWN")
time.sleep(0.2)
# Unshut all ports
link_state.state = link_state.UP
api.set_link_state(link_state)
logger.info("All Snappi ports are set to UP")
toggle_dut_port_state(api)

init_ctr_3 = get_npu_voq_queue_counters(duthost, dut_port, test_prio_list[0])
init_ctr_4 = get_npu_voq_queue_counters(duthost, dut_port, test_prio_list[1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config, \
is_snappi_multidut, get_snappi_ports_multi_dut # noqa: F401
from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \
lossless_prio_list # noqa F401
from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED
lossless_prio_list, disable_pfcwd # noqa F401
from tests.snappi_tests.files.helper import multidut_port_info, setup_ports_and_dut # noqa: F401
from tests.snappi_tests.multidut.ecn.files.multidut_helper import run_ecn_marking_port_toggle_test
from tests.common.snappi_tests.common_helpers import packet_capture # noqa F401
from tests.common.snappi_tests.snappi_test_params import SnappiTestParams
logger = logging.getLogger(__name__)
pytestmark = [pytest.mark.topology('multidut-tgen')]


@pytest.mark.parametrize("multidut_port_info", [
pytest.param(
multidut_port_info,
id=f"multidut_port_keys={'_'.join(multidut_port_info.keys())}"
)
for multidut_port_info in MULTIDUT_PORT_INFO[MULTIDUT_TESTBED]
])
@pytest.fixture(autouse=True)
def number_of_tx_rx_ports():
yield (2, 1)


def test_ecn_marking_port_toggle(
snappi_api, # noqa: F811
conn_graph_facts, # noqa: F811
Expand All @@ -32,7 +30,10 @@ def test_ecn_marking_port_toggle(
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
multidut_port_info, # noqa: F811
prio_dscp_map): # noqa: F811
prio_dscp_map, # noqa: F811
disable_pfcwd, # noqa: F811
setup_ports_and_dut # noqa: F811
):
"""
Verify ECN marking both pre and post port shut/no shut toggle
Expand All @@ -51,44 +52,7 @@ def test_ecn_marking_port_toggle(
N/A
"""

for testbed_subtype, rdma_ports in multidut_port_info.items():
tx_port_count = 2
rx_port_count = 1
snappi_port_list = get_snappi_ports
pytest_assert(MULTIDUT_TESTBED == tbinfo['conf-name'],
"The testbed name from testbed file doesn't match with MULTIDUT_TESTBED in variables.py ")
pytest_assert(len(snappi_port_list) >= tx_port_count + rx_port_count,
"Need Minimum of {} ports defined in ansible/files/*links.csv file".
format(tx_port_count + rx_port_count))

pytest_assert(len(rdma_ports['tx_ports']) >= tx_port_count,
'MULTIDUT_PORT_INFO doesn\'t have the required Tx ports defined for \
testbed {}, subtype {} in variables.py'.
format(MULTIDUT_TESTBED, testbed_subtype))

pytest_assert(len(rdma_ports['rx_ports']) >= rx_port_count,
'MULTIDUT_PORT_INFO doesn\'t have the required Rx ports defined for \
testbed {}, subtype {} in variables.py'.
format(MULTIDUT_TESTBED, testbed_subtype))

# Collect port names from rx_ports and tx_ports into a set for uniqueness
all_ports_set = set(port['port_name'] for port in rdma_ports['rx_ports'] + rdma_ports['tx_ports'])
pytest_assert(len(all_ports_set) >= tx_port_count + rx_port_count,
'MULTIDUT_PORT_INFO doesn\'t have at least {} unique ports for \
testbed {}, subtype {} in variables.py'.
format(tx_port_count + rx_port_count, MULTIDUT_TESTBED, testbed_subtype))

logger.info('Running test for testbed subtype: {}'.format(testbed_subtype))

if is_snappi_multidut(duthosts):
snappi_ports = get_snappi_ports_for_rdma(snappi_port_list, rdma_ports,
tx_port_count, rx_port_count, MULTIDUT_TESTBED)
else:
snappi_ports = snappi_port_list

testbed_config, port_config_list, snappi_ports = snappi_dut_base_config(duthosts,
snappi_ports,
snappi_api)
testbed_config, port_config_list, snappi_ports = setup_ports_and_dut

logger.info("Snappi Ports : {}".format(snappi_ports))
snappi_extra_params = SnappiTestParams()
Expand Down

0 comments on commit bde32ca

Please sign in to comment.