Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[202405 - cherry pick]: Enhancement of port selection criteria for multidut RDMA cases… #14256

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 117 additions & 1 deletion tests/common/snappi_tests/snappi_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tests.common.helpers.assertions import pytest_assert
from tests.snappi_tests.variables import dut_ip_start, snappi_ip_start, prefix_length, \
dut_ipv6_start, snappi_ipv6_start, v6_prefix_length, pfcQueueGroupSize, \
pfcQueueValueDict
pfcQueueValueDict # noqa: F401
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -980,3 +980,119 @@ def pre_configure_dut_interface(duthost, snappi_ports):
except Exception:
pytest_assert(False, "Unable to configure ip on the interface {}".format(port['peer_port']))
return snappi_ports_dut


@pytest.fixture(scope="module")
def get_snappi_ports(duthosts, # noqa: F811
tbinfo, # noqa: F811
conn_graph_facts, # noqa: F811
fanout_graph_facts_multidut,
): # noqa: F811
"""
Populate snappi ports and connected DUT ports info of T1 and T2 testbed and returns as a list
Args:
duthost (pytest fixture): duthost fixture
tbinfo (pytest fixture): fixture provides information about testbed
conn_graph_facts (pytest fixture): connection graph
fanout_graph_facts_multidut (pytest fixture): fanout graph
Return: (list)
[{ 'api_server_ip': '10.36.78.59',
'asic_type': 'broadcom',
'asic_value': None,
'card_id': '4',
'duthost': <MultiAsicSonicHost sonic-s6100-dut2>,
'ip': '10.36.78.53',
'location': '10.36.78.53;4;7',
'peer_device': 'sonic-s6100-dut1',
'peer_port': 'Ethernet72',
'port_id': '7',
'snappi_speed_type': 'speed_100_gbps',
'speed': '100000'
},
{ 'api_server_ip': '10.36.78.59',
'asic_type': 'broadcom',
'asic_value': 'asic0',
'card_id': '4',
'duthost': <MultiAsicSonicHost sonic-s6100-dut2>,
'ip': '10.36.78.53',
'location': '10.36.78.53;4;8',
'peer_device': 'sonic-s6100-dut2',
'peer_port': 'Ethernet76',
'port_id': '8',
'snappi_speed_type': 'speed_100_gbps',
'speed': '100000'
}]
"""
speed_type = {
'10000': 'speed_10_gbps',
'25000': 'speed_25_gbps',
'40000': 'speed_40_gbps',
'50000': 'speed_50_gbps',
'100000': 'speed_100_gbps',
'200000': 'speed_200_gbps',
'400000': 'speed_400_gbps',
'800000': 'speed_800_gbps'}
multidut_snappi_ports = []

for duthost in duthosts:
snappi_fanout = get_peer_snappi_chassis(conn_data=conn_graph_facts,
dut_hostname=duthost.hostname)
if snappi_fanout is None:
continue
snappi_fanout_id = list(fanout_graph_facts_multidut.keys()).index(snappi_fanout)
snappi_fanout_list = SnappiFanoutManager(fanout_graph_facts_multidut)
snappi_fanout_list.get_fanout_device_details(device_number=snappi_fanout_id)
snappi_ports = snappi_fanout_list.get_ports(peer_device=duthost.hostname)
port_speed = None
for i in range(len(snappi_ports)):
if port_speed is None:
port_speed = int(snappi_ports[i]['speed'])

elif port_speed != int(snappi_ports[i]['speed']):
""" All the ports should have the same bandwidth """
return None

for port in snappi_ports:
port['location'] = get_snappi_port_location(port)
port['speed'] = port['speed']
port['api_server_ip'] = tbinfo['ptf_ip']
port['asic_type'] = duthost.facts["asic_type"]
port['duthost'] = duthost
port['snappi_speed_type'] = speed_type[port['speed']]
if duthost.facts["num_asic"] > 1:
port['asic_value'] = duthost.get_port_asic_instance(port['peer_port']).namespace
else:
port['asic_value'] = None
multidut_snappi_ports = multidut_snappi_ports + snappi_ports
return multidut_snappi_ports


def get_snappi_ports_for_rdma(snappi_port_list, rdma_ports, tx_port_count, rx_port_count, testbed):
"""
Returns the required tx and rx ports for the rdma test
Args:
snappi_port_list (list): List of snappi ports and connected DUT ports info of T1 and T2 testbed
rdma_ports (dict): RDMA port info for testbed subtype defined in variables.py
tx_port_count (int): Number of Tx ports required for the test
rx_port_count (int): Number of Rx ports required for the test
Return: (list)
"""
tx_snappi_ports = []
rx_snappi_ports = []
var_tx_ports = random.sample(rdma_ports['tx_ports'], tx_port_count)
var_rx_ports = random.sample(rdma_ports['rx_ports'], rx_port_count)
for port in snappi_port_list:
for var_rx_port in var_rx_ports:
if port['peer_port'] == var_rx_port['port_name'] and port['peer_device'] == var_rx_port['hostname']:
rx_snappi_ports.append(port)
for var_tx_port in var_tx_ports:
if port['peer_port'] == var_tx_port['port_name'] and port['peer_device'] == var_tx_port['hostname']:
tx_snappi_ports.append(port)

pytest_assert(len(rx_snappi_ports) == rx_port_count,
'Rx Ports for {} in MULTIDUT_PORT_INFO doesn\'t match with ansible/files/*links.csv'.format(testbed))
pytest_assert(len(tx_snappi_ports) == tx_port_count,
'Tx Ports for {} in MULTIDUT_PORT_INFO doesn\'t match with ansible/files/*links.csv'.format(testbed))

multidut_snappi_ports = rx_snappi_ports + tx_snappi_ports
return multidut_snappi_ports
Original file line number Diff line number Diff line change
@@ -1,84 +1,80 @@
import pytest
import random
import logging
from tests.common.helpers.assertions import pytest_require, pytest_assert # noqa: F401
from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \
fanout_graph_facts # 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, cleanup_config # noqa: F401
snappi_api, snappi_dut_base_config, cleanup_config, get_snappi_ports, get_snappi_ports_for_rdma # noqa: F401
from tests.common.snappi_tests.qos_fixtures import lossless_prio_list, prio_dscp_map # noqa: F401
from tests.snappi_tests.variables import config_set, line_card_choice
from tests.snappi_tests.multidut.pfc.files.multidut_helper import run_pfc_test # noqa: F401
from tests.common.snappi_tests.snappi_test_params import SnappiTestParams
from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED

logger = logging.getLogger(__name__)

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_global_pause(snappi_api, # noqa: F811
conn_graph_facts, # noqa: F811
fanout_graph_facts, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
get_snappi_ports, # noqa: F811
duthosts,
prio_dscp_map, # noqa: F811
lossless_prio_list, # noqa: F811
line_card_choice,
linecard_configuration_set,
get_multidut_snappi_ports # noqa: F811
):
tbinfo, # noqa: F811
multidut_port_info):
"""
Test if IEEE 802.3X pause (a.k.a., global pause) will impact any priority

Args:
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 for multiple duts
get_snappi_ports (pytest fixture): list of snappi port and duthost information
duthosts (pytest fixture): list of DUTs
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)
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
"""
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(line_card_choice in linecard_configuration_set.keys(), "Invalid line_card_choice in parameter")
pytest_require(len(linecard_configuration_set[line_card_choice]['hostname']) != 0,
"Hostname can't be an empty list")
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]

snappi_port_list = get_multidut_snappi_ports(line_card_choice=line_card_choice,
line_card_info=linecard_configuration_set[line_card_choice])
pytest_assert(len(snappi_port_list) >= 2, "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)
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)
all_prio_list = prio_dscp_map.keys()
test_prio_list = lossless_prio_list
bg_prio_list = [x for x in all_prio_list if x not in test_prio_list]

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

run_pfc_test(api=snappi_api,
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,
global_pause=True,
pause_prio_list=None,
test_prio_list=test_prio_list,
Expand All @@ -87,4 +83,4 @@ def test_global_pause(snappi_api, # noqa: F811
test_traffic_pause=False,
snappi_extra_params=snappi_extra_params)

cleanup_config(dut_list, snappi_ports)
cleanup_config(duthosts, snappi_ports)
Loading
Loading