Skip to content

Commit

Permalink
[Fix] Accomodating the infra change for multidut ECN and PFCWD cases (#…
Browse files Browse the repository at this point in the history
…14305)

Description of PR
Summary: Accomodating the infra change for multidut ECN and PFCWD cases
Fixes # (issue)
#13389
#13769

Approach
What is the motivation for this PR?
To accomodate the infra change from PR 14127

How did you do it?
Added a pytest fixture called get_snappi_ports and get_snappi_ports_for_rdma whcih selects the ports from the information provided in MULTIDUT_PORT_INFO in variables.py

co-authorized by: [email protected]
  • Loading branch information
selldinesh authored Sep 20, 2024
1 parent 71c82b9 commit 83553f6
Show file tree
Hide file tree
Showing 9 changed files with 512 additions and 563 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import random
import logging

from tests.common.helpers.assertions import pytest_assert, pytest_require
from tests.common.helpers.assertions import pytest_assert, pytest_require # noqa: F401
from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \
fanout_graph_facts # noqa: F401
fanout_graph_facts_multidut # noqa: F401
from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \
snappi_api, snappi_dut_base_config, get_tgen_peer_ports, get_multidut_snappi_ports, \
get_multidut_tgen_peer_port_set, cleanup_config # noqa: F401
snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401
from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401

from tests.snappi_tests.variables import config_set, line_card_choice
from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED
from tests.snappi_tests.multidut.ecn.files.multidut_helper import run_ecn_test
from tests.common.snappi_tests.read_pcap import is_ecn_marked
from tests.snappi_tests.files.helper import skip_ecn_tests
Expand All @@ -20,17 +19,16 @@
pytestmark = [pytest.mark.topology('multidut-tgen')]


@pytest.mark.parametrize('line_card_choice', [line_card_choice])
@pytest.mark.parametrize('linecard_configuration_set', [config_set])
@pytest.mark.parametrize("multidut_port_info", MULTIDUT_PORT_INFO[MULTIDUT_TESTBED])
def test_dequeue_ecn(request,
snappi_api, # noqa: F811
conn_graph_facts, # noqa: F811
fanout_graph_facts, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
duthosts,
rand_one_dut_lossless_prio,
line_card_choice,
linecard_configuration_set,
get_multidut_snappi_ports, # noqa: F811
lossless_prio_list, # noqa: F811
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
multidut_port_info, # noqa: F811
prio_dscp_map): # noqa: F811
"""
Test if the device under test (DUT) performs ECN marking at the egress
Expand All @@ -39,48 +37,50 @@ def test_dequeue_ecn(request,
request (pytest fixture): pytest request object
snappi_api (pytest fixture): SNAPPI session
conn_graph_facts (pytest fixture): connection graph
fanout_graph_facts (pytest fixture): fanout graph
fanout_graph_facts_multidut (pytest fixture): fanout graph
duthosts (pytest fixture): list of DUTs
lossless_prio_list (pytest fixture): list of all the lossless priorities
rand_one_dut_lossless_prio (str): name of lossless priority to test, e.g., 's6100-1|3'
line_card_choice: Line card choice to be mentioned in the variable.py file
linecard_configuration_set : Line card classification, (min 1 or max 2 hostnames and asics to be given)
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).
tbinfo (pytest fixture): fixture provides information about testbed
get_snappi_ports (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
Returns:
N/A
"""

if line_card_choice not in linecard_configuration_set.keys():
pytest_require(False, "Invalid line_card_choice value passed in parameter")

if (len(linecard_configuration_set[line_card_choice]['hostname']) == 2):
dut_list = random.sample(duthosts.frontend_nodes, 2)
duthost1, duthost2 = dut_list
elif (len(linecard_configuration_set[line_card_choice]['hostname']) == 1):
dut_list = [dut for dut in duthosts.frontend_nodes if
linecard_configuration_set[line_card_choice]['hostname'] == [dut.hostname]]
duthost1, duthost2 = dut_list[0], dut_list[0]
else:
pytest_require(False, "Hostname can't be an empty list")

snappi_port_list = get_multidut_snappi_ports(line_card_choice=line_card_choice,
line_card_info=linecard_configuration_set[line_card_choice])
if len(snappi_port_list) < 2:
pytest_require(False, "Need Minimum of 2 ports for the test")

snappi_ports = get_multidut_tgen_peer_port_set(line_card_choice, snappi_port_list, config_set, 2)

testbed_config, port_config_list, snappi_ports = snappi_dut_base_config(dut_list,
snappi_ports,
snappi_api)

_, lossless_prio = rand_one_dut_lossless_prio.split('|')
skip_ecn_tests(duthost1)
skip_ecn_tests(duthost2)
for testbed_subtype, rdma_ports in multidut_port_info.items():
tx_port_count = 1
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 2 ports defined in ansible/files/*links.csv file")

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))
logger.info('Running test for testbed subtype: {}'.format(testbed_subtype))
snappi_ports = get_snappi_ports_for_rdma(snappi_port_list, rdma_ports,
tx_port_count, rx_port_count, MULTIDUT_TESTBED)
testbed_config, port_config_list, snappi_ports = snappi_dut_base_config(duthosts,
snappi_ports,
snappi_api)

lossless_prio = random.sample(lossless_prio_list, 1)
skip_ecn_tests(snappi_ports[0]['duthost'])
skip_ecn_tests(snappi_ports[1]['duthost'])
lossless_prio = int(lossless_prio)
snappi_extra_params = SnappiTestParams()
snappi_extra_params.multi_dut_params.duthost1 = duthost1
snappi_extra_params.multi_dut_params.duthost2 = duthost2

snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports
snappi_extra_params.packet_capture_type = packet_capture.IP_CAPTURE
snappi_extra_params.is_snappi_ingress_port_cap = True
Expand All @@ -99,7 +99,7 @@ def test_dequeue_ecn(request,
testbed_config=testbed_config,
port_config_list=port_config_list,
conn_data=conn_graph_facts,
fanout_data=fanout_graph_facts,
fanout_data=fanout_graph_facts_multidut,
dut_port=snappi_ports[0]['peer_port'],
lossless_prio=lossless_prio,
prio_dscp_map=prio_dscp_map,
Expand All @@ -117,3 +117,4 @@ def test_dequeue_ecn(request,
# Check if the last packet is not ECN marked
pytest_assert(not is_ecn_marked(ip_pkts[-1]),
"The last packet should not be marked")
cleanup_config(duthosts, snappi_ports)
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import random
import logging
from tabulate import tabulate # noqa F401
from tests.common.helpers.assertions import pytest_assert, pytest_require
from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts # noqa: F401
from tests.common.helpers.assertions import pytest_assert, pytest_require # noqa: F401
from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401
from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \
snappi_api, snappi_dut_base_config, get_tgen_peer_ports, get_multidut_snappi_ports, \
get_multidut_tgen_peer_port_set # noqa: F401
snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401
from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \
lossless_prio_list # noqa F401
from tests.snappi_tests.variables import config_set, line_card_choice
from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED
from tests.snappi_tests.files.helper import skip_ecn_tests
from tests.common.snappi_tests.read_pcap import is_ecn_marked
from tests.snappi_tests.multidut.ecn.files.multidut_helper import run_ecn_test
Expand All @@ -20,17 +19,16 @@
pytestmark = [pytest.mark.topology('multidut-tgen')]


@pytest.mark.parametrize('line_card_choice', [line_card_choice])
@pytest.mark.parametrize('linecard_configuration_set', [config_set])
@pytest.mark.parametrize("multidut_port_info", MULTIDUT_PORT_INFO[MULTIDUT_TESTBED])
def test_red_accuracy(request,
snappi_api, # noqa: F811
conn_graph_facts, # noqa: F811
fanout_graph_facts, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
duthosts,
rand_one_dut_lossless_prio,
line_card_choice,
linecard_configuration_set,
get_multidut_snappi_ports, # noqa: F811
lossless_prio_list, # noqa: F811
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
multidut_port_info, # noqa: F811
prio_dscp_map): # noqa: F811
"""
Measure RED/ECN marking accuracy of the device under test (DUT).
Expand All @@ -42,50 +40,47 @@ def test_red_accuracy(request,
conn_graph_facts (pytest fixture): connection graph
fanout_graph_facts (pytest fixture): fanout graph
duthosts (pytest fixture): list of DUTs
rand_one_dut_lossless_prio (str): name of lossless priority to test, e.g., 's6100-1|3'
lossless_prio_list (pytest fixture): list of all the lossless priorities
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).
line_card_choice: Line card choice to be mentioned in the variable.py file
linecard_configuration_set : Line card classification, (min 1 or max 2 hostnames and asics to be given)
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).
tbinfo (pytest fixture): fixture provides information about testbed
get_snappi_ports (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
Returns:
N/A
"""
# disable_test = request.config.getoption("--disable_ecn_snappi_test")
# if disable_test:
# pytest.skip("test_red_accuracy is disabled")

if line_card_choice not in linecard_configuration_set.keys():
pytest_require(False, "Invalid line_card_choice value passed in parameter")

if (len(linecard_configuration_set[line_card_choice]['hostname']) == 2):
dut_list = random.sample(duthosts.frontend_nodes, 2)
duthost1, duthost2 = dut_list
elif (len(linecard_configuration_set[line_card_choice]['hostname']) == 1):
dut_list = [dut for dut in duthosts.frontend_nodes if
linecard_configuration_set[line_card_choice]['hostname'] == [dut.hostname]] # noqa: E501
duthost1, duthost2 = dut_list[0], dut_list[0]
else:
pytest_require(False, "Hostname can't be an empty list")

snappi_port_list = get_multidut_snappi_ports(line_card_choice=line_card_choice,
line_card_info=linecard_configuration_set[line_card_choice])
if len(snappi_port_list) < 2:
pytest_require(False, "Need Minimum of 2 ports for the test")

snappi_ports = get_multidut_tgen_peer_port_set(line_card_choice, snappi_port_list, config_set, 2)

testbed_config, port_config_list, snappi_ports = snappi_dut_base_config(dut_list,
snappi_ports,
snappi_api)

_, lossless_prio = rand_one_dut_lossless_prio.split('|')
skip_ecn_tests(duthost1) or skip_ecn_tests(duthost2)
lossless_prio = int(lossless_prio)
for testbed_subtype, rdma_ports in multidut_port_info.items():
tx_port_count = 1
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 2 ports defined in ansible/files/*links.csv file")

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))
logger.info('Running test for testbed subtype: {}'.format(testbed_subtype))
snappi_ports = get_snappi_ports_for_rdma(snappi_port_list, rdma_ports,
tx_port_count, rx_port_count, MULTIDUT_TESTBED)
testbed_config, port_config_list, snappi_ports = snappi_dut_base_config(duthosts,
snappi_ports,
snappi_api)

skip_ecn_tests(snappi_ports[0]['duthost']) or skip_ecn_tests(snappi_ports[1]['duthost'])
lossless_prio = random.sample(lossless_prio_list, 1)

snappi_extra_params = SnappiTestParams()
snappi_extra_params.multi_dut_params.duthost1 = duthost1
snappi_extra_params.multi_dut_params.duthost2 = duthost2
snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports

snappi_extra_params.packet_capture_type = packet_capture.IP_CAPTURE
Expand All @@ -107,7 +102,7 @@ def test_red_accuracy(request,
testbed_config=testbed_config,
port_config_list=port_config_list,
conn_data=conn_graph_facts,
fanout_data=fanout_graph_facts,
fanout_data=fanout_graph_facts_multidut,
dut_port=snappi_ports[0]['peer_port'],
lossless_prio=lossless_prio,
prio_dscp_map=prio_dscp_map,
Expand Down Expand Up @@ -145,3 +140,4 @@ def test_red_accuracy(request,
for queue, mark_cnt in list(queue_mark_cnt.items()):
output_table.append([queue, float(mark_cnt)/num_iterations])
logger.info(tabulate(output_table, headers=['Queue Length', 'ECN Marking Probability']))
cleanup_config(duthosts, snappi_ports)
Loading

0 comments on commit 83553f6

Please sign in to comment.