Skip to content

Commit c0026b8

Browse files
committed
[Snappi]: Adding FEC Error Insertion Test Script
1 parent 37840a5 commit c0026b8

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
from tests.snappi_tests.dataplane.imports import *
2+
from tests.common.snappi_tests.traffic_generation import setup_base_traffic_config
3+
from tests.common.snappi_tests.common_helpers import traffic_flow_mode
4+
from tests.common.snappi_tests.snappi_helpers import wait_for_arp, fetch_snappi_flow_metrics
5+
logger = logging.getLogger(__name__)
6+
pytestmark = [pytest.mark.topology('tgen')]
7+
8+
ErrorTypes = [ 'maxConsecutiveUncorrectableWithoutLossOfLink',
9+
'codeWords',
10+
'minConsecutiveUncorrectableWithLossOfLink',
11+
'laneMarkers'
12+
]
13+
# ErrorTypes = [
14+
# 'minConsecutiveUncorrectableWithLossOfLink'
15+
# ]
16+
17+
@pytest.mark.parametrize('error_type', ErrorTypes)
18+
def test_fec_error_injection(snappi_api, # noqa F811
19+
snappi_testbed_config, # noqa F811
20+
conn_graph_facts, # noqa F811
21+
fanout_graph_facts, # noqa F811
22+
duthosts,
23+
error_type,
24+
rand_one_dut_portname_oper_up,
25+
rand_one_dut_hostname): # noqa F811
26+
27+
dut_hostname, dut_port = rand_one_dut_portname_oper_up.split('|')
28+
testbed_config, port_config_list = snappi_testbed_config
29+
duthost = duthosts[rand_one_dut_hostname]
30+
api=snappi_api
31+
conn_data=conn_graph_facts
32+
fanout_data=fanout_graph_facts
33+
snappi_extra_params=None
34+
35+
if snappi_extra_params is None:
36+
snappi_extra_params = SnappiTestParams()
37+
port_id = get_dut_port_id(duthost.hostname,
38+
dut_port,
39+
conn_data,
40+
fanout_data)
41+
42+
pytest_assert(port_id is not None,
43+
'Fail to get ID for port {}'.format(dut_port))
44+
snappi_extra_params.base_flow_config = setup_base_traffic_config(testbed_config=testbed_config,
45+
port_config_list=port_config_list,
46+
port_id=port_id)
47+
base_flow = snappi_extra_params.base_flow_config
48+
test_flow = testbed_config.flows.flow(name='IPv4 Traffic')[-1]
49+
test_flow.tx_rx.device.tx_names = [testbed_config.devices[0].name]
50+
test_flow.tx_rx.device.rx_names = [testbed_config.devices[1].name]
51+
test_flow.metrics.enable = True
52+
test_flow.metrics.loss = True
53+
test_flow.size.fixed = 64
54+
test_flow.rate.percentage = 10
55+
56+
api.set_config(testbed_config)
57+
logger.info("Wait for Arp to Resolve ...")
58+
wait_for_arp(api, max_attempts=30, poll_interval_sec=2)
59+
ixnet = api._ixnetwork
60+
port1 = ixnet.Vport.find()[0]
61+
logger.info('|----------------------------------------|')
62+
logger.info('| Setting FEC Error Type to : {} |'.format(error_type))
63+
logger.info('|----------------------------------------|')
64+
port1.L1Config.FecErrorInsertion.ErrorType = error_type
65+
if error_type == 'codeWords':
66+
port1.L1Config.FecErrorInsertion.PerCodeword = 16
67+
port1.L1Config.FecErrorInsertion.Continuous = True
68+
69+
logger.info('Starting Traffic ...')
70+
ts = api.control_state()
71+
ts.traffic.flow_transmit.state = ts.traffic.flow_transmit.START
72+
api.set_control_state(ts)
73+
wait(10, "For traffic to start")
74+
75+
logger.info('Starting FEC Error Insertion')
76+
port1.StartFecErrorInsertion()
77+
wait(15, "For error insertion to start")
78+
# TODO For maxConsecutiveUncorrectableWithoutLossOfLink check link state on DUT
79+
flow_metrics = fetch_snappi_flow_metrics(api, ['IPv4 Traffic'])[0]
80+
pytest_assert(flow_metrics.frames_tx > 0 and int(flow_metrics.frames_rx_rate) == 0,
81+
"FAIL: Rx Port did not stop receiving packets after starting FEC Error Insertion")
82+
logger.info(' .. PASSED : Rx Port stopped receiving packets after starting FEC Error Insertion')
83+
logger.info('Stopping FEC Error Insertion')
84+
port1.StopFecErrorInsertion()
85+
wait(15, "For error insertion to stop")
86+
87+
flow_metrics = fetch_snappi_flow_metrics(api, ['IPv4 Traffic'])[0]
88+
pytest_assert(int(flow_metrics.frames_rx_rate) > 0,
89+
"FAIL: Rx Port did not resume receiving packets after stopping FEC Error Insertion")
90+
logger.info(' .. PASSED : Rx Port resumed receiving packets after stopping FEC Error Insertion')
91+
logger.info('Stopping Traffic ...')
92+
ts = api.control_state()
93+
ts.traffic.flow_transmit.state = ts.traffic.flow_transmit.STOP
94+
api.set_control_state(ts)
95+
wait(10, "For traffic to stop")
96+

0 commit comments

Comments
 (0)