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

[Snappi] Update test PFC pause frame functionality to include DUT counter polling #9847

Merged
merged 18 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions tests/common/snappi_tests/common_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from enum import Enum
import ipaddr
import json
import re
from netaddr import IPNetwork
from tests.common.mellanox_data import is_mellanox_device as isMellanoxDevice
from tests.common.broadcom_data import is_broadcom_device as isBroadcomDevice
Expand Down Expand Up @@ -821,6 +823,42 @@ def get_pfc_frame_count(duthost, port, priority, is_tx=False):
return int(pause_frame_count.replace(',', ''))


def get_tx_frame_count(duthost, port):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unify these 2 functions - get_tx_frame_count and get_rx_frame_count

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unified in #9775. this PR is dependent on that PR.

"""
Get the Tx_OK and Tx_DRP frame count for a given port ex. Ethernet4 from SONiC CLI
Args:
duthost (Ansible host instance): device under test
port (str): port name ex. Ethernet4
Returns:
tx_frame_count (int): Tx frame count
"""
raw_out = duthost.shell("portstat -ji {}".format(port))['stdout']
raw_out_stripped = re.sub(r'^.*?\n', '', raw_out, count=1)
raw_json = json.loads(raw_out_stripped)
tx_ok_frame_count = raw_json[port]["TX_OK"]
tx_drp_frame_count = raw_json[port]["TX_DRP"]

return int(tx_ok_frame_count.replace(',', '')), int(tx_drp_frame_count.replace(',', ''))


def get_rx_frame_count(duthost, port):
"""
Get the Rx_OK and Rx_DRP frame count for a given port ex. Ethernet4 from SONiC CLI
Args:
duthost (Ansible host instance): device under test
port (str): port name ex. Ethernet4
Returns:
rx_frame_count (int): Rx frame count
"""
raw_out = duthost.shell("portstat -ji {}".format(port))['stdout']
raw_out_stripped = re.sub(r'^.*?\n', '', raw_out, count=1)
raw_json = json.loads(raw_out_stripped)
rx_ok_frame_count = raw_json[port]["RX_OK"]
rx_drp_frame_count = raw_json[port]["RX_DRP"]

return int(rx_ok_frame_count.replace(',', '')), int(rx_drp_frame_count.replace(',', ''))


def get_egress_queue_count(duthost, port, priority):
"""
Get the egress queue count in packets and bytes for a given port and priority from SONiC CLI.
Expand Down
17 changes: 16 additions & 1 deletion tests/common/snappi_tests/snappi_test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@ def __init__(self):
then pcap is on the tgen egress port
base_flow_config (dict): base flow configuration
test_tx_frames (list): number of test frames transmitted for priorities to test ex. [2000, 3000]
for priorities 3 and 4
for ex. priorities 3 and 4
gen_background_traffic (bool): whether or not to generate background traffic (default: True)
pause_flow_params (dict): pause frame parameters
Params:
pause_frame_size (int): pause frame size in bytes (default: 64)
pause_frame_rate (int): pause frame rate in frames per second
(default: pause dur to block link fully)
pause_flow_dur (int): pause flow duration in seconds (default: -5 to signal continuous mode)
pause_flow_delay (int): pause flow delay in seconds (default: 0)
link_blockage_threshold (int): link blockage threshold in number of overlaps per pause dur
(default: 2)
poll_device_runtime (bool): whether or not to poll the device for stats when traffic is running
(default: False)
"""
self.headroom_test_params = None
self.pfc_pause_src_mac = None
Expand All @@ -33,3 +45,6 @@ def __init__(self):
self.is_snappi_ingress_port_cap = True
self.base_flow_config = None
self.test_tx_frames = 0
self.gen_background_traffic = True
self.pause_flow_params = None
self.poll_device_runtime = True
Loading