Skip to content

Commit 35f5d8b

Browse files
authored
[Snappi] New testcases for PFC-ECN. (#13865)
Description of PR This pull-request has changes specifically for the following commit-IDs: a82b489 180af4d 3da40bc This PR specifically handles the testcases pertaining to the new PFC-ECN testplan added. Summary: Fixes # (issue) #13655 #13215 Approach What is the motivation for this PR? Three test-scripts have been added to specifically test: non-congestion scenarios (line-rate tests), congestion testcases via over-subscription and PFCWD (drop and forward mode). How did you do it? Test case has dictionary called test_def which defines various testcases parameters necessary to run the testcase. An example of this, is packet-size (default is IMIX but can be changed to 1024B), test-duration, stats capture, file log at the end of the test. Similarly, there is test_check which passes test-case uses for verification info. Lossless and lossy priorities are selected from the available list. Most important change comes in form of port_map definition. Port map is a list with first two parameters defining the egress port count and egress speed. Last two parameters define the ingress port count and ingress speed. Example - [1, 100, 2 , 100] defines single egress port of speed 100Gbps and 2 ingress ports of 100Gbps. This definition is important because, multi-speed ingress and egress ports needs to be supported. Example - [1, 100, 1, 400] will define single ingress and egress of 400Gbps and 100Gbps respectively. A new function is provided to capture snappi_ports. This will pick the line-card choice from variable.py and choose the ports as defined in port_map. The port_map is used to filter out the available ports for the required port-speed. At the end of the test, a CSV is created as raw data for the test-case execution. Summary of the test-case is generated in form of text file with same name. Additional checks are present in multi_dut helper file, depending upon the type of the test. The test passes the verification parameters in test_check in dictionary format. There is important change in variables.py file. The line_card_choice is sent as dictionary from variables.py, which then is parameterized in the test. Depending upon the type of line_card_choice, the tests are ran for that specific line_card choice and set of ports. Testcases: a. tests/snappi_tests/pfc/test_pfc_no_congestion_throughput.py: -- This testcase has testcases to test line-rate speeds with single ingress and egress. Traffic combination around lossless and lossy priorities have been used. Expectations is that no PFCs will be generated, line-rate will be achieved, no drops will be seen on both DUT and TGEN. b. tests/snappi_tests/pfc/test_pfc_port_congestion.py: -- This testcase has testcases to test behavior with 2 ingress ports and 1 egress port on the DUT. Traffic combination around lossless and lossy priorities. c. tests/snappi_tests/pfcwd/test_pfcwd_actions.py: -- Testcases cover PFCWD action - DROP and FORWARD mode. DROP and FORWARD mode is also tested for two ingresses and single egress with pause frames on egress. How did you verify/test it? Test case was executed on local clone. Results of the verification: Test cases executed for 100Gbps interfaces. Two combinations - single-line-card-multi-asic and multiple-dut Non-congestion: 19:06:48 test_sys_non_congestion.test_multiple_pr L0095 INFO | Running test for testbed subtype: single-dut-multi-asic 19:15:21 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Egress_diff_dist_100Gbps_single-dut-multi-asic_1024B-2024-10-08-19-15.csv PASSED [ 16%] snappi_tests/multidut/systest/test_sys_non_congestion.py::test_multiple_prio_diff_dist[multidut_port_info1-port_map0] 19:15:26 test_sys_non_congestion.test_multiple_pr L0095 INFO | Running test for testbed subtype: single-dut-single-asic 19:23:37 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Egress_diff_dist_100Gbps_single-dut-single-asic_1024B-2024-10-08-19-23.csv PASSED [ 33%] snappi_tests/multidut/systest/test_sys_non_congestion.py::test_multiple_prio_uni_dist[multidut_port_info0-port_map0] 19:23:42 test_sys_non_congestion.test_multiple_pr L0235 INFO | Running test for testbed subtype: single-dut-multi-asic 19:31:57 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Egress_uni_dist_100Gbps_single-dut-multi-asic_1024B-2024-10-08-19-31.csv PASSED [ 50%] snappi_tests/multidut/systest/test_sys_non_congestion.py::test_multiple_prio_uni_dist[multidut_port_info1-port_map0] 19:32:02 test_sys_non_congestion.test_multiple_pr L0235 INFO | Running test for testbed subtype: single-dut-single-asic 19:40:12 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Egress_uni_dist_100Gbps_single-dut-single-asic_1024B-2024-10-08-19-40.csv PASSED [ 66%] snappi_tests/multidut/systest/test_sys_non_congestion.py::test_single_lossless_prio[multidut_port_info0-port_map0] 19:40:18 test_sys_non_congestion.test_single_loss L0375 INFO | Running test for testbed subtype: single-dut-multi-asic 19:48:26 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Egress_1Prio_linerate_100Gbps_single-dut-multi-asic_1024B-2024-10-08-19-48.csv PASSED [ 83%] snappi_tests/multidut/systest/test_sys_non_congestion.py::test_single_lossless_prio[multidut_port_info1-port_map0] 19:48:31 test_sys_non_congestion.test_single_loss L0375 INFO | Running test for testbed subtype: single-dut-single-asic 19:56:38 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Egress_1Prio_linerate_100Gbps_single-dut-single-asic_1024B-2024-10-08-19-56.csv PASSED [100%] Over-subscription: 20:13:40 test_sys_over_subscription.test_multiple L0093 INFO | Running test for testbed subtype: single-dut-multi-asic 20:23:07 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_diff_dist_100Gbps_single-dut-multi-asic_1024B-2024-10-08-20-23.csv PASSED [ 12%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_diff_dist[multidut_port_info1-port_map0] 20:23:16 test_sys_over_subscription.test_multiple L0093 INFO | Running test for testbed subtype: single-dut-single-asic 20:32:20 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_diff_dist_100Gbps_single-dut-single-asic_1024B-2024-10-08-20-32.csv PASSED [ 25%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_uni_dist[multidut_port_info0-port_map0] 20:32:29 test_sys_over_subscription.test_multiple L0227 INFO | Running test for testbed subtype: single-dut-multi-asic 20:41:39 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_uni_dist_full100Gbps_single-dut-multi-asic_1024B-2024-10-08-20-41.csv PASSED [ 37%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_uni_dist[multidut_port_info1-port_map0] 20:41:48 test_sys_over_subscription.test_multiple L0227 INFO | Running test for testbed subtype: single-dut-single-asic 20:50:53 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_uni_dist_full100Gbps_single-dut-single-asic_1024B-2024-10-08-20-50.csv PASSED [ 50%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_uni_dist_full[multidut_port_info0-port_map0] 20:51:02 test_sys_over_subscription.test_multiple L0364 INFO | Running test for testbed subtype: single-dut-multi-asic 21:00:11 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_uni_dist_full100Gbps_single-dut-multi-asic_1024B-2024-10-08-21-00.csv PASSED [ 62%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_uni_dist_full[multidut_port_info1-port_map0] 21:00:20 test_sys_over_subscription.test_multiple L0364 INFO | Running test for testbed subtype: single-dut-single-asic 21:09:25 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_uni_dist_full100Gbps_single-dut-single-asic_1024B-2024-10-08-21-09.csv PASSED [ 75%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_non_cngtn[multidut_port_info0-port_map0] 21:09:34 test_sys_over_subscription.test_multiple L0502 INFO | Running test for testbed subtype: single-dut-multi-asic 21:18:38 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_non_cngstn_100Gbps_single-dut-multi-asic_1024B-2024-10-08-21-18.csv PASSED [ 87%] snappi_tests/multidut/systest/test_sys_over_subscription.py::test_multiple_prio_non_cngtn[multidut_port_info1-port_map0] 21:18:47 test_sys_over_subscription.test_multiple L0502 INFO | Running test for testbed subtype: single-dut-single-asic 21:27:45 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_non_cngstn_100Gbps_single-dut-single-asic_1024B-2024-10-08-21-27.csv PASSED [100%] PFCWD: 01:08:43 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/One_Ingress_Egress_pfcwd_drop_90_10_dist100Gbps_single-dut-multi-asic_1024B-2024-10-09-01-08.csv PASSED [ 10%] 01:19:33 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/One_Ingress_Egress_pfcwd_drop_90_10_dist100Gbps_single-dut-single-asic_1024B-2024-10-09-01-19.csv PASSED [ 20%] 01:30:32 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/One_Ingress_Egress_pfcwd_frwd_90_10_dist100Gbps_single-dut-multi-asic_1024B-2024-10-09-01-30.csv PASSED [ 30%] 01:41:25 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/One_Ingress_Egress_pfcwd_frwd_90_10_dist100Gbps_single-dut-single-asic_1024B-2024-10-09-01-41.csv PASSED [ 40%] 01:53:08 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_pfcwd_drop_40_9_dist100Gbps_single-dut-multi-asic_1024B-2024-10-09-01-53.csv PASSED [ 50%] 02:04:49 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_pfcwd_drop_40_9_dist100Gbps_single-dut-single-asic_1024B-2024-10-09-02-04.csv PASSED [ 60%] 02:16:26 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_pfcwd_frwd_40_9_dist100Gbps_single-dut-multi-asic_1024B-2024-10-09-02-16.csv PASSED [ 70%] 02:27:53 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Two_Ingress_Single_Egress_pfcwd_frwd_40_9_dist100Gbps_single-dut-single-asic_1024B-2024-10-09-02-27.csv PASSED [ 80%] 02:38:45 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Single_Egress_pause_cngstn_100Gbps_single-dut-multi-asic_1024B-2024-10-09-02-38.csv PASSED [ 90%] 02:49:22 traffic_generation.run_sys_traffic L1190 INFO | Writing statistics to file : /tmp/Single_Ingress_Single_Egress_pause_cngstn_100Gbps_single-dut-single-asic_1024B-2024-10-09-02-49.csv PASSED [100%] Any platform specific information? The testcases are specifically meant for Broadcom DNX Multi-ASIC platform DUT. co-authorized by: [email protected]
1 parent 376178e commit 35f5d8b

File tree

5 files changed

+2801
-0
lines changed

5 files changed

+2801
-0
lines changed
Lines changed: 382 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,382 @@
1+
import logging
2+
import time
3+
4+
from tests.common.helpers.assertions import pytest_assert
5+
from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\
6+
fanout_graph_facts # noqa F401
7+
from tests.common.snappi_tests.common_helpers import pfc_class_enable_vector,\
8+
get_lossless_buffer_size, get_pg_dropped_packets,\
9+
stop_pfcwd, disable_packet_aging, sec_to_nanosec,\
10+
get_pfc_frame_count, packet_capture, config_capture_pkt,\
11+
start_pfcwd, enable_packet_aging, \
12+
traffic_flow_mode, calc_pfc_pause_flow_rate # noqa F401
13+
from tests.common.snappi_tests.port import select_ports, select_tx_port # noqa F401
14+
from tests.common.snappi_tests.snappi_helpers import wait_for_arp # noqa F401
15+
from tests.common.snappi_tests.traffic_generation import generate_pause_flows, verify_pause_flow, \
16+
verify_basic_test_flow, verify_background_flow, verify_pause_frame_count_dut, verify_egress_queue_frame_count, \
17+
verify_in_flight_buffer_pkts, verify_unset_cev_pause_frame_count, run_traffic_and_collect_stats, \
18+
multi_base_traffic_config, generate_test_flows, generate_background_flows
19+
from tests.common.snappi_tests.snappi_test_params import SnappiTestParams
20+
from tests.common.snappi_tests.read_pcap import validate_pfc_frame
21+
22+
logger = logging.getLogger(__name__)
23+
24+
dut_port_config = []
25+
PAUSE_FLOW_NAME = 'Pause Storm'
26+
TEST_FLOW_NAME = 'Test Flow'
27+
BG_FLOW_NAME = 'Background Flow'
28+
TOLERANCE_THRESHOLD = 0.1
29+
CONTINUOUS_MODE = -5
30+
ANSIBLE_POLL_DELAY_SEC = 4
31+
global DATA_FLOW_DURATION_SEC
32+
global data_flow_delay_sec
33+
34+
35+
def run_pfc_test(api,
36+
testbed_config,
37+
port_config_list,
38+
conn_data,
39+
fanout_data,
40+
global_pause,
41+
pause_prio_list,
42+
test_prio_list,
43+
bg_prio_list,
44+
prio_dscp_map,
45+
test_traffic_pause,
46+
test_def,
47+
snappi_extra_params=None):
48+
"""
49+
Run a multidut PFC test
50+
Args:
51+
api (obj): snappi session
52+
testbed_config (obj): testbed L1/L2/L3 configuration
53+
port_config_list (list): list of port configuration
54+
conn_data (dict): the dictionary returned by conn_graph_fact.
55+
fanout_data (dict): the dictionary returned by fanout_graph_fact.
56+
duthost (Ansible host instance): device under test
57+
dut_port (str): DUT port to test
58+
global_pause (bool): if pause frame is IEEE 802.3X pause
59+
pause_prio_list (list): priorities to pause for pause frames
60+
test_prio_list (list): priorities of test flows
61+
bg_prio_list (list): priorities of background flows
62+
prio_dscp_map (dict): Priority vs. DSCP map (key = priority).
63+
test_traffic_pause (bool): if test flows are expected to be paused
64+
test_def['enable_pause'] (bool) : if test expects no pause flow traffic.
65+
snappi_extra_params (SnappiSysTestParams obj): additional parameters for Snappi traffic
66+
67+
Returns:
68+
N/A
69+
"""
70+
71+
TEST_FLOW_AGGR_RATE_PERCENT = test_def['TEST_FLOW_AGGR_RATE_PERCENT']
72+
BG_FLOW_AGGR_RATE_PERCENT = test_def['BG_FLOW_AGGR_RATE_PERCENT']
73+
data_flow_pkt_size = test_def['data_flow_pkt_size']
74+
DATA_FLOW_DURATION_SEC = test_def['DATA_FLOW_DURATION_SEC']
75+
data_flow_delay_sec = test_def['data_flow_delay_sec']
76+
SNAPPI_POLL_DELAY_SEC = test_def['SNAPPI_POLL_DELAY_SEC']
77+
PAUSE_FLOW_DUR_BASE_SEC = data_flow_delay_sec + DATA_FLOW_DURATION_SEC
78+
if test_def['imix']:
79+
fname = test_def['test_type'] + '_' + test_def['line_card_choice'] + '_' + 'IMIX'
80+
else:
81+
fname = test_def['test_type'] + '_' + test_def['line_card_choice'] + '_' + str(data_flow_pkt_size) + 'B'
82+
port_map = test_def['port_map']
83+
84+
if snappi_extra_params is None:
85+
snappi_extra_params = SnappiTestParams()
86+
87+
# Traffic flow:
88+
# tx_port (TGEN) --- ingress DUT --- egress DUT --- rx_port (TGEN)
89+
90+
rx_port = snappi_extra_params.multi_dut_params.multi_dut_ports[0]
91+
egress_duthost = rx_port['duthost']
92+
93+
tx_port = snappi_extra_params.multi_dut_params.multi_dut_ports[1]
94+
ingress_duthost = tx_port['duthost']
95+
96+
dut_list = []
97+
dut_list.append(egress_duthost)
98+
dut_list.append(ingress_duthost)
99+
100+
if (test_traffic_pause):
101+
logger.info("PFC receiving DUT is {}".format(egress_duthost.hostname))
102+
103+
pytest_assert(testbed_config is not None, 'Fail to get L2/3 testbed config')
104+
105+
if (test_def['enable_pfcwd']):
106+
start_pfcwd(egress_duthost)
107+
start_pfcwd(ingress_duthost)
108+
else:
109+
stop_pfcwd(egress_duthost)
110+
stop_pfcwd(ingress_duthost)
111+
112+
if (test_def['enable_credit_wd']):
113+
enable_packet_aging(egress_duthost, rx_port['asic_value'])
114+
enable_packet_aging(ingress_duthost, tx_port['asic_value'])
115+
else:
116+
disable_packet_aging(egress_duthost, rx_port['asic_value'])
117+
disable_packet_aging(ingress_duthost, tx_port['asic_value'])
118+
119+
# Port id of Rx port for traffic config
120+
# rx_port_id and tx_port_id belong to IXIA chassis.
121+
rx_port_id = 0
122+
123+
# Rate percent must be an integer
124+
bg_flow_rate_percent = int(BG_FLOW_AGGR_RATE_PERCENT / len(bg_prio_list))
125+
test_flow_rate_percent = int(TEST_FLOW_AGGR_RATE_PERCENT / len(test_prio_list))
126+
# Generate base traffic config
127+
for i in range(port_map[2]):
128+
tx_port_id = i+1
129+
snappi_extra_params.base_flow_config_list.append(multi_base_traffic_config(testbed_config=testbed_config,
130+
port_config_list=port_config_list,
131+
rx_port_id=rx_port_id,
132+
tx_port_id=tx_port_id))
133+
134+
speed_str = testbed_config.layer1[0].speed
135+
speed_gbps = int(speed_str.split('_')[1])
136+
137+
if snappi_extra_params.headroom_test_params is not None:
138+
DATA_FLOW_DURATION_SEC += 10
139+
data_flow_delay_sec += 2
140+
141+
# Set up pfc delay parameter
142+
l1_config = testbed_config.layer1[0]
143+
pfc = l1_config.flow_control.ieee_802_1qbb
144+
pfc.pfc_delay = snappi_extra_params.headroom_test_params[0]
145+
146+
if snappi_extra_params.poll_device_runtime:
147+
# If the switch needs to be polled as traffic is running for stats,
148+
# then the test runtime needs to be increased for the polling delay
149+
DATA_FLOW_DURATION_SEC += ANSIBLE_POLL_DELAY_SEC
150+
data_flow_delay_sec = ANSIBLE_POLL_DELAY_SEC
151+
152+
if snappi_extra_params.packet_capture_type != packet_capture.NO_CAPTURE:
153+
# Setup capture config
154+
if snappi_extra_params.is_snappi_ingress_port_cap:
155+
# packet capture is required on the ingress snappi port
156+
snappi_extra_params.packet_capture_ports = [snappi_extra_params.base_flow_config_list["rx_port_name"]]
157+
else:
158+
# packet capture will be on the egress snappi port
159+
snappi_extra_params.packet_capture_ports = [snappi_extra_params.base_flow_config_list["tx_port_name"]]
160+
161+
snappi_extra_params.packet_capture_file = snappi_extra_params.packet_capture_type.value
162+
163+
config_capture_pkt(testbed_config=testbed_config,
164+
port_names=snappi_extra_params.packet_capture_ports,
165+
capture_type=snappi_extra_params.packet_capture_type,
166+
capture_name=snappi_extra_params.packet_capture_file)
167+
logger.info("Packet capture file: {}.pcapng".format(snappi_extra_params.packet_capture_file))
168+
169+
# Set default traffic flow configs if not set
170+
if snappi_extra_params.traffic_flow_config.data_flow_config is None:
171+
snappi_extra_params.traffic_flow_config.data_flow_config = {
172+
"flow_name": TEST_FLOW_NAME,
173+
"flow_dur_sec": DATA_FLOW_DURATION_SEC,
174+
"flow_rate_percent": test_flow_rate_percent,
175+
"flow_rate_pps": None,
176+
"flow_rate_bps": None,
177+
"flow_pkt_count": None,
178+
"flow_pkt_size": data_flow_pkt_size,
179+
"flow_delay_sec": data_flow_delay_sec,
180+
"flow_traffic_type": traffic_flow_mode.FIXED_DURATION
181+
}
182+
183+
if snappi_extra_params.traffic_flow_config.background_flow_config is None and \
184+
snappi_extra_params.gen_background_traffic:
185+
snappi_extra_params.traffic_flow_config.background_flow_config = {
186+
"flow_name": BG_FLOW_NAME,
187+
"flow_dur_sec": DATA_FLOW_DURATION_SEC,
188+
"flow_rate_percent": bg_flow_rate_percent,
189+
"flow_rate_pps": None,
190+
"flow_rate_bps": None,
191+
"flow_pkt_size": data_flow_pkt_size,
192+
"flow_pkt_count": None,
193+
"flow_delay_sec": data_flow_delay_sec,
194+
"flow_traffic_type": traffic_flow_mode.FIXED_DURATION
195+
}
196+
197+
if (test_traffic_pause):
198+
if snappi_extra_params.traffic_flow_config.pause_flow_config is None:
199+
snappi_extra_params.traffic_flow_config.pause_flow_config = {
200+
"flow_name": PAUSE_FLOW_NAME,
201+
"flow_dur_sec": None,
202+
"flow_rate_percent": None,
203+
"flow_rate_pps": calc_pfc_pause_flow_rate(speed_gbps),
204+
"flow_rate_bps": None,
205+
"flow_pkt_size": 64,
206+
"flow_pkt_count": None,
207+
"flow_delay_sec": 0,
208+
"flow_traffic_type": traffic_flow_mode.CONTINUOUS
209+
}
210+
211+
if snappi_extra_params.packet_capture_type == packet_capture.PFC_CAPTURE:
212+
# PFC pause frame capture is requested
213+
valid_pfc_frame_test = True
214+
else:
215+
# PFC pause frame capture is not requested
216+
valid_pfc_frame_test = False
217+
218+
if (test_traffic_pause):
219+
if valid_pfc_frame_test:
220+
snappi_extra_params.traffic_flow_config.pause_flow_config["flow_dur_sec"] = DATA_FLOW_DURATION_SEC + \
221+
data_flow_delay_sec + SNAPPI_POLL_DELAY_SEC + PAUSE_FLOW_DUR_BASE_SEC
222+
snappi_extra_params.traffic_flow_config.pause_flow_config["flow_traffic_type"] = \
223+
traffic_flow_mode.FIXED_DURATION
224+
225+
# Generate test flow config based on number of ingress ports
226+
# Every ingress port will be used as index. Example - test flow stream 0 - for first ingress.
227+
for m in range(port_map[2]):
228+
generate_test_flows(testbed_config=testbed_config,
229+
test_flow_prio_list=test_prio_list,
230+
prio_dscp_map=prio_dscp_map,
231+
snappi_extra_params=snappi_extra_params,
232+
flow_index=m)
233+
234+
if (test_def['background_traffic']):
235+
for m in range(port_map[2]):
236+
if snappi_extra_params.gen_background_traffic:
237+
# Generate background flow config
238+
generate_background_flows(testbed_config=testbed_config,
239+
bg_flow_prio_list=bg_prio_list,
240+
prio_dscp_map=prio_dscp_map,
241+
snappi_extra_params=snappi_extra_params,
242+
flow_index=m)
243+
244+
# Generate pause storm config
245+
if (test_traffic_pause):
246+
for m in range(port_map[0]):
247+
generate_pause_flows(testbed_config=testbed_config,
248+
pause_prio_list=pause_prio_list,
249+
global_pause=global_pause,
250+
snappi_extra_params=snappi_extra_params,
251+
snap_index=m)
252+
253+
flows = testbed_config.flows
254+
255+
all_flow_names = [flow.name for flow in flows]
256+
data_flow_names = [flow.name for flow in flows if PAUSE_FLOW_NAME not in flow.name]
257+
258+
# Clear PFC, queue and interface counters before traffic run
259+
for dut in dut_list:
260+
dut.command("pfcstat -c \n")
261+
time.sleep(1)
262+
dut.command("sonic-clear queuecounters \n")
263+
time.sleep(1)
264+
dut.command("sonic-clear counters \n")
265+
time.sleep(1)
266+
267+
exp_dur_sec = DATA_FLOW_DURATION_SEC + data_flow_delay_sec
268+
269+
""" Run traffic """
270+
tgen_flow_stats, switch_flow_stats, test_stats = \
271+
run_traffic_and_collect_stats(rx_duthost=ingress_duthost,
272+
tx_duthost=egress_duthost,
273+
api=api,
274+
config=testbed_config,
275+
data_flow_names=data_flow_names,
276+
all_flow_names=all_flow_names,
277+
exp_dur_sec=exp_dur_sec,
278+
port_map=test_def['port_map'],
279+
fname=fname,
280+
stats_interval=test_def['stats_interval'],
281+
imix=test_def['imix'],
282+
snappi_extra_params=snappi_extra_params)
283+
284+
test_check = test_def['test_check']
285+
if (not test_check['loss_expected']):
286+
# Check for loss packets on IXIA and DUT.
287+
pytest_assert(test_stats['tgen_loss_pkts'] == 0, 'Loss seen on TGEN')
288+
pytest_assert(test_stats['dut_loss_pkts'] == 0, 'Loss seen on DUT')
289+
290+
# Check for Tx and Rx packets on IXIA for lossless and lossy streams.
291+
pytest_assert(test_stats['tgen_lossless_rx_pkts'] == test_stats['tgen_lossless_tx_pkts'],
292+
'Losses observed in lossless traffic streams')
293+
pytest_assert(test_stats['tgen_lossy_rx_pkts'] == test_stats['tgen_lossy_tx_pkts'],
294+
'Losses observed in lossy traffic streams')
295+
296+
# Check for Rx packets between IXIA and DUT for lossy and lossless streams.
297+
pytest_assert(test_stats['tgen_lossless_rx_pkts'] == test_stats['dut_lossless_pkts'],
298+
'Losses observed in lossless traffic streams on DUT Tx and IXIA Rx')
299+
pytest_assert(test_stats['tgen_lossy_rx_pkts'] == test_stats['dut_lossy_pkts'],
300+
'Losses observed in lossy traffic streams on DUT Tx and IXIA Rx')
301+
else:
302+
# Check for lossless and lossy stream percentage drop for a given tolerance limit.
303+
lossless_drop = round((1 - float(test_stats['tgen_lossless_rx_pkts']) / test_stats['tgen_lossless_tx_pkts']), 2)
304+
lossy_drop = round((1 - float(test_stats['tgen_lossy_rx_pkts']) / test_stats['tgen_lossy_tx_pkts']), 2)
305+
logger.info('Lossless Drop %:{}, Lossy Drop %:{}'.format(lossless_drop, lossy_drop))
306+
pytest_assert((lossless_drop*100) <= test_check['lossless'], 'Lossless packet drop outside tolerance limit')
307+
pytest_assert((lossy_drop*100) <= test_check['lossy'], 'Lossy packet drop outside tolerance limit')
308+
309+
# Checking if the actual line rate on egress is within tolerable limit of egress line speed.
310+
pytest_assert(((1 - test_stats['tgen_rx_rate'] / float(port_map[0]*port_map[1]))*100) <= test_check['speed_tol'],
311+
'Egress speed beyond tolerance range')
312+
313+
# Checking for PFC counts on DUT
314+
if (not test_check['pfc']):
315+
pytest_assert(test_stats['lossless_tx_pfc'] == 0, 'Error:PFC transmitted by DUT for lossless priorities')
316+
pytest_assert(test_stats['lossy_rx_tx_pfc'] == 0, 'Error:PFC transmitted by DUT for lossy priorities')
317+
else:
318+
if (test_stats['lossless_rx_pfc'] != 0):
319+
pytest_assert(test_stats['lossless_tx_pfc'] > 0, 'Error:No Tx PFCs from DUT after receiving PFCs')
320+
pytest_assert(test_stats['lossless_tx_pfc'] > 0, 'Error: PFC not be transmitted from DUT on congestion')
321+
pytest_assert(test_stats['lossy_rx_tx_pfc'] == 0, 'Error:Incorrect Rx/Tx PFCs on DUT for lossy priorities')
322+
323+
# Reset pfc delay parameter
324+
pfc = testbed_config.layer1[0].flow_control.ieee_802_1qbb
325+
pfc.pfc_delay = 0
326+
327+
# Verify PFC pause frames
328+
if (test_traffic_pause):
329+
if valid_pfc_frame_test:
330+
is_valid_pfc_frame = validate_pfc_frame(snappi_extra_params.packet_capture_file + ".pcapng")
331+
pytest_assert(is_valid_pfc_frame, "PFC frames invalid")
332+
return
333+
334+
# Verify pause flows
335+
if (test_traffic_pause):
336+
for metric in tgen_flow_stats:
337+
if PAUSE_FLOW_NAME in metric.name:
338+
pause_flow_name = metric.name
339+
verify_pause_flow(flow_metrics=tgen_flow_stats,
340+
pause_flow_name=pause_flow_name)
341+
342+
# Check for the flows ONLY if normal packet size (non-imix) is used.
343+
if (test_def['background_traffic'] and test_def['verify_flows'] and not test_def['imix']):
344+
if snappi_extra_params.gen_background_traffic:
345+
# Verify background flows
346+
verify_background_flow(flow_metrics=tgen_flow_stats,
347+
speed_gbps=speed_gbps,
348+
tolerance=TOLERANCE_THRESHOLD,
349+
snappi_extra_params=snappi_extra_params)
350+
351+
# Verify basic test flows metrics from ixia
352+
if (test_def['verify_flows'] and not test_def['imix']):
353+
verify_basic_test_flow(flow_metrics=tgen_flow_stats,
354+
speed_gbps=speed_gbps,
355+
tolerance=TOLERANCE_THRESHOLD,
356+
test_flow_pause=test_traffic_pause,
357+
snappi_extra_params=snappi_extra_params)
358+
359+
if (test_traffic_pause and test_def['verify_flows']):
360+
verify_pause_frame_count_dut(rx_dut=ingress_duthost,
361+
tx_dut=egress_duthost,
362+
test_traffic_pause=test_traffic_pause,
363+
global_pause=global_pause,
364+
snappi_extra_params=snappi_extra_params)
365+
366+
# Verify in flight TX lossless packets do not leave the DUT when traffic is expected
367+
# to be paused, or leave the DUT when the traffic is not expected to be paused
368+
verify_egress_queue_frame_count(duthost=egress_duthost,
369+
switch_flow_stats=switch_flow_stats,
370+
test_traffic_pause=test_traffic_pause,
371+
snappi_extra_params=snappi_extra_params)
372+
373+
if (test_traffic_pause and test_def['verify_flows']):
374+
# Verify in flight TX packets count relative to switch buffer size
375+
verify_in_flight_buffer_pkts(duthost=ingress_duthost,
376+
asic_value=rx_port['asic_value'],
377+
flow_metrics=tgen_flow_stats,
378+
snappi_extra_params=snappi_extra_params)
379+
380+
# Verify zero pause frames are counted when the PFC class enable vector is not set
381+
verify_unset_cev_pause_frame_count(duthost=egress_duthost,
382+
snappi_extra_params=snappi_extra_params)

0 commit comments

Comments
 (0)