Skip to content

Commit

Permalink
Convert all udp port numbers to serial sequence. (#16394)
Browse files Browse the repository at this point in the history
Description of PR
Summary:
In snappi tests, we have a number of tests with UDP streams. We need them to be counted sequentially instead of random, or any other order. This PR addresses some of the mistakes in the udp port count logic.

Approach
What is the motivation for this PR?
The tests fail in cisco-8000 due to backplane bandwidth limitations. The backplane bandwidth limit will be avoided if the number of streams we use in the traffic is large enough to cause load balancing across the backplane, so that many backplane ports are used instead of just one. This PR addresses some of the script locations where the udp port numbers are not correctly calculated.

How did you do it?
How did you verify/test it?
Ran it on my TB, with a -e --count=2 option, for repeating the tests 2 times:

=========================================================================================================== PASSES ===========================================================================================================
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info0-1-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info0-2-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info1-1-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info1-2-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info2-1-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info2-2-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info3-1-2] ____________________________________________________________________________________
___________________________________________________________________________________ test_ecn_marking_port_toggle[multidut_port_info3-2-2] ____________________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent0-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent0-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent1-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent1-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent2-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent2-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent3-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent3-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent4-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent4-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent5-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent5-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent6-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent6-2-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent7-1-2] _________________________________________________________________________
_________________________________________________________________________ test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent7-2-2] _________________________________________________________________________
---------------------------------------------------------------- generated xml file: /run_logs/ixia/ecn_repeat/2025-01-08-22-40-28/tr_2025-01-08-22-40-28.xml ----------------------------------------------------------------
INFO:root:Can not get Allure report URL. Please check logs
================================================================================================== short test summary info ===================================================================================================
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info0-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info0-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info1-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info1-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info2-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info2-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info3-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_port_toggle[multidut_port_info3-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent0-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent0-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent1-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent1-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent2-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent2-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent3-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent3-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent4-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent4-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent5-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent5-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent6-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent6-2-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent7-1-2]
PASSED snappi_tests/multidut/ecn/test_multidut_ecn_marking_with_snappi.py::test_ecn_marking_lossless_prio[multidut_port_info1-test_flow_percent7-2-2]
SKIPPED [16] common/helpers/assertions.py:16: ECN tests are not supported on Cisco switches yet.
SKIPPED [48] common/helpers/assertions.py:16: Invalid combination of duthosts or ASICs in snappi_ports
================================================================================= 24 passed, 64 skipped, 28 warnings in 12774.71s (3:32:54) ==================================================================================
sonic@snappi-sonic-mgmt-vanilla-202405-t2:/data/tests$ 

co-authorized by: [email protected]
  • Loading branch information
rraghav-cisco authored Jan 10, 2025
1 parent a7fcbb3 commit 5f66027
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions tests/common/snappi_tests/traffic_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import time
import logging
import random
import re
from tests.common.helpers.assertions import pytest_assert
from tests.common.snappi_tests.common_helpers import get_egress_queue_count, pfc_class_enable_vector, \
Expand All @@ -20,6 +19,7 @@
SNAPPI_POLL_DELAY_SEC = 2
CONTINUOUS_MODE = -5
ANSIBLE_POLL_DELAY_SEC = 4
UDP_PORT_START = 5000


def setup_base_traffic_config(testbed_config,
Expand Down Expand Up @@ -129,7 +129,9 @@ def generate_test_flows(testbed_config,
test_flow.tx_rx.port.rx_name = base_flow_config["rx_port_name"]

eth, ipv4, udp = test_flow.packet.ethernet().ipv4().udp()
src_port = random.randint(5000, 6000)
global UDP_PORT_START
src_port = UDP_PORT_START
UDP_PORT_START += number_of_streams
udp.src_port.increment.start = src_port
udp.src_port.increment.step = 1
udp.src_port.increment.count = number_of_streams
Expand Down
15 changes: 10 additions & 5 deletions tests/snappi_tests/multidut/ecn/files/multidut_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def run_ecn_test(api,
generate_test_flows(testbed_config=testbed_config,
test_flow_prio_list=[lossless_prio],
prio_dscp_map=prio_dscp_map,
snappi_extra_params=snappi_extra_params)
snappi_extra_params=snappi_extra_params,
number_of_streams=10)

logger.info("Generating pause flows")
generate_pause_flows(testbed_config=testbed_config,
Expand Down Expand Up @@ -426,7 +427,8 @@ def run_ecn_marking_port_toggle_test(
generate_test_flows(testbed_config=testbed_config,
test_flow_prio_list=test_prio_list,
prio_dscp_map=prio_dscp_map,
snappi_extra_params=snappi_extra_params)
snappi_extra_params=snappi_extra_params,
number_of_streams=10)

snappi_extra_params.base_flow_config = base_flow_config2

Expand All @@ -444,7 +446,8 @@ def run_ecn_marking_port_toggle_test(
generate_test_flows(testbed_config=testbed_config,
test_flow_prio_list=test_prio_list,
prio_dscp_map=prio_dscp_map,
snappi_extra_params=snappi_extra_params)
snappi_extra_params=snappi_extra_params,
number_of_streams=10)

flows = testbed_config.flows

Expand Down Expand Up @@ -588,7 +591,8 @@ def run_ecn_marking_test(api,
generate_test_flows(testbed_config=testbed_config,
test_flow_prio_list=test_prio_list,
prio_dscp_map=prio_dscp_map,
snappi_extra_params=snappi_extra_params)
snappi_extra_params=snappi_extra_params,
number_of_streams=10)

snappi_extra_params.base_flow_config = base_flow_config2

Expand All @@ -606,7 +610,8 @@ def run_ecn_marking_test(api,
generate_test_flows(testbed_config=testbed_config,
test_flow_prio_list=test_prio_list,
prio_dscp_map=prio_dscp_map,
snappi_extra_params=snappi_extra_params)
snappi_extra_params=snappi_extra_params,
number_of_streams=10)

flows = testbed_config.flows

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ def __gen_data_flow(testbed_config,
flow.tx_rx.port.rx_name = testbed_config.ports[dst_port_id].name
eth, ipv4, udp = flow.packet.ethernet().ipv4().udp()
global UDP_PORT_START
src_port = UDP_PORT_START + no_of_streams
src_port = UDP_PORT_START
UDP_PORT_START += no_of_streams
udp.src_port.increment.start = src_port
udp.src_port.increment.step = 1
udp.src_port.increment.count = no_of_streams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ def __gen_data_flow(testbed_config,
flow.tx_rx.port.rx_name = testbed_config.ports[dst_port_id].name
eth, ipv4, udp = flow.packet.ethernet().ipv4().udp()
global UDP_PORT_START
src_port = UDP_PORT_START + no_of_streams
src_port = UDP_PORT_START
UDP_PORT_START += no_of_streams
udp.src_port.increment.start = src_port
udp.src_port.increment.step = 1
udp.src_port.increment.count = no_of_streams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ def __gen_data_flow(testbed_config,
flow.tx_rx.port.rx_name = testbed_config.ports[dst_port_id].name
eth, ipv4, udp = flow.packet.ethernet().ipv4().udp()
global UDP_PORT_START
src_port = UDP_PORT_START + no_of_streams
src_port = UDP_PORT_START
UDP_PORT_START += no_of_streams
udp.src_port.increment.start = src_port
udp.src_port.increment.step = 1
udp.src_port.increment.count = no_of_streams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def __gen_traffic(testbed_config,
else:
eth.pfc_queue.value = pfcQueueValueDict[prio]

src_port = UDP_PORT_START + eth.pfc_queue.value
global UDP_PORT_START
src_port = UDP_PORT_START
UDP_PORT_START += 1
udp.src_port.increment.start = src_port
udp.src_port.increment.step = 1
udp.src_port.increment.count = 1
Expand Down

0 comments on commit 5f66027

Please sign in to comment.