Skip to content

Commit

Permalink
Introduced parametrization for various ecnconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
sreejithsreekumaran committed Dec 20, 2024
1 parent 10f0e34 commit ea43434
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
11 changes: 8 additions & 3 deletions tests/common/snappi_tests/common_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def get_wred_profiles(host_ans, asic_value=None):
return None


def config_wred(host_ans, kmin, kmax, pmax, profile=None, asic_value=None):
def config_wred(host_ans, kmin, kmax, pmax, gdrop=None, profile=None, asic_value=None):
"""
Config a WRED/ECN profile of a SONiC switch
Args:
Expand All @@ -456,10 +456,11 @@ def config_wred(host_ans, kmin, kmax, pmax, profile=None, asic_value=None):
asic_type = str(host_ans.facts["asic_type"])
if not isinstance(kmin, int) or \
not isinstance(kmax, int) or \
not isinstance(pmax, int):
not isinstance(pmax, int) or \
(gdrop is not None and not isinstance(gdrop, int)):
return False

if kmin < 0 or kmax < 0 or pmax < 0 or pmax > 100 or kmin > kmax:
if kmin < 0 or kmax < 0 or pmax < 0 or pmax > 100 or kmin > kmax or (gdrop and (gdrop < 0 or gdrop > 100)):
return False
profiles = get_wred_profiles(host_ans, asic_value)
""" Cannot find any WRED/ECN profiles """
Expand All @@ -486,6 +487,7 @@ def config_wred(host_ans, kmin, kmax, pmax, profile=None, asic_value=None):

kmin_old = int(profiles[p]['{}_min_threshold'.format(color)])
kmax_old = int(profiles[p]['{}_max_threshold'.format(color)])
gdrop_old = int(profiles[p]['{}_drop_probability'.format(color)])

if kmin_old > kmax_old:
return False
Expand All @@ -508,6 +510,9 @@ def config_wred(host_ans, kmin, kmax, pmax, profile=None, asic_value=None):
host_ans.shell(kmin_cmd.format(p, kmin))
host_ans.shell(kmax_cmd.format(p, kmax))

if gdrop and gdrop != gdrop_old:
host_ans.shell('sudo ecnconfig -p {} -gdrop {}'.format(p, gdrop))

return True


Expand Down
22 changes: 21 additions & 1 deletion tests/snappi_tests/multidut/ecn/files/multidut_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import time
import csv
import os
from tests.common.helpers.assertions import pytest_assert
from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts # noqa: F401
from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \
Expand Down Expand Up @@ -645,6 +646,8 @@ def run_ecn_marking_with_pfc_quanta_variance(
dut_port,
test_prio_list,
prio_dscp_map,
test_ecn_config,
log_dir=None,
snappi_extra_params=None):

pytest_assert(testbed_config is not None, 'Fail to get L2/3 testbed config')
Expand Down Expand Up @@ -712,6 +715,19 @@ def run_ecn_marking_with_pfc_quanta_variance(
"flow_traffic_type": traffic_flow_mode.FIXED_PACKETS
}

gmin, gmax, gdrop = test_ecn_config

# Configure WRED/ECN thresholds
logger.info("Configuring WRED and ECN thresholds gmin {}MB gmax {}MB gdrop {}%".format(gmin, gmax, gdrop))

config_result = config_wred(host_ans=duthost,
kmin=gmin * 1024 * 1024,
kmax=gmax * 1024 * 1024,
pmax=0,
gdrop=gdrop)

pytest_assert(config_result is True, 'Failed to configure WRED/ECN at the DUT')

start_quanta = 500
end_quanta = 65000
n = 15 # Number of quanta values
Expand Down Expand Up @@ -760,7 +776,11 @@ def run_ecn_marking_with_pfc_quanta_variance(
stats_only = {key: ctr_3[key] for key in ctr_3['stats_name']}
results.append((quanta, stats_only))

with open('xoff_quanta_variance_results.csv', 'w', newline='') as csvfile:
file_name = "xoff_quanta_variance_results_{}_{}_{}.csv".format(gmin, gmax, gdrop)
if log_dir:
file_name = os.path.join(log_dir, file_name)

with open(file_name, 'w', newline='') as csvfile:
if results:
first_ctr = results[0][1]
fieldnames = ['quanta'] + list(first_ctr.keys())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import logging
import os
from tabulate import tabulate # noqa F401
from tests.common.helpers.assertions import pytest_assert # noqa: F401
from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts, \
Expand All @@ -21,17 +22,23 @@ def number_of_tx_rx_ports():
yield (1, 1)


# tuple of -gmin in MB, -gmax in MB and -gdrop in percentage
test_ecn_config = [(1, 4, 5), (1, 4, 10), (2, 4, 5), (2, 4, 10)]


@pytest.mark.parametrize("test_ecn_config", test_ecn_config)
def test_ecn_marking_with_pfc_quanta_variance(
request,
snappi_api, # noqa: F811
conn_graph_facts, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
duthosts,
lossless_prio_list, # noqa: F811
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
disable_pfcwd, # noqa: F811
test_ecn_config,
prio_dscp_map, # noqa: F811
setup_ports_and_dut): # noqa: F811

"""
Verify ECN marking on lossless prio with varying XOFF quanta
Expand All @@ -45,25 +52,24 @@ def test_ecn_marking_with_pfc_quanta_variance(
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).
tbinfo (pytest fixture): fixture provides information about testbed
test_flow_percent: Percentage of flow rate used for the two lossless prio
get_snappi_ports (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
Returns:
N/A
"""

testbed_config, port_config_list, snappi_ports = setup_ports_and_dut
log_file_path = request.config.getoption("--log-file", default=None)

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

try:
run_ecn_marking_with_pfc_quanta_variance(
api=snappi_api,
testbed_config=testbed_config,
port_config_list=port_config_list,
dut_port=snappi_ports[0]['peer_port'],
test_prio_list=lossless_prio_list,
prio_dscp_map=prio_dscp_map,
snappi_extra_params=snappi_extra_params)
finally:
cleanup_config(duthosts, snappi_ports)
run_ecn_marking_with_pfc_quanta_variance(
api=snappi_api,
testbed_config=testbed_config,
port_config_list=port_config_list,
dut_port=snappi_ports[0]['peer_port'],
test_prio_list=lossless_prio_list,
prio_dscp_map=prio_dscp_map,
log_dir=os.path.dirname(log_file_path) if log_file_path else None,
test_ecn_config=test_ecn_config,
snappi_extra_params=snappi_extra_params)

0 comments on commit ea43434

Please sign in to comment.