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

[WIP] [SDFAB-512] Design testing framework for ASTF-mode TRex for linerate TCP testing #368

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ba1df04
Design testing framework for ASTF-mode TRex for linerate TCP testing
Aug 26, 2021
e564ef0
Add copyright and licensing information to new files
Aug 26, 2021
90156b0
Bugfix and cleanup
Aug 26, 2021
ce508e8
Minor cleanup
Aug 27, 2021
4bebbba
Merge branch 'stratum:main' into tcp-linerate
dariusgrassi Sep 1, 2021
d27f106
Address comments
Sep 2, 2021
5376aac
Fix small mistake
Sep 2, 2021
d23ced6
Add update from debugging and forum advice
Sep 7, 2021
cb958a3
Merge branch 'stratum:main' into tcp-linerate
dariusgrassi Sep 9, 2021
e024ff5
Fix bug where ASTF servers were not receiving client requests
Sep 9, 2021
b834bcb
Merge branch 'stratum:main' into tcp-linerate
dariusgrassi Sep 13, 2021
d461149
Employ multiple methods to increase throughput and change behaviour of
Sep 16, 2021
e14cf92
Cleanup and verify test is only using one flow
Sep 18, 2021
c1ed339
Merge branch 'stratum:main' into tcp-linerate
dariusgrassi Sep 22, 2021
17e4444
Create a helper function for TRex tests which prints out readable
Sep 24, 2021
6bbce17
Normalize TRex INT tests to meet certain baseline expectations:
Sep 24, 2021
ccc3e09
Switch branch from trex-continuous-helper to main
Sep 25, 2021
95a445f
Push chassis config before INT tests and fix `int_single_flow` issues
Sep 27, 2021
dd373c9
Address Yi comments
Sep 28, 2021
d78ba82
Address comments and list all ports
Sep 28, 2021
5f554cb
Merge branch 'trex-continuous-helper' into tcp-linerate
Sep 28, 2021
c880cff
Address Carmelo comments
Sep 29, 2021
3dbbf81
Return dictionary of all results with function
Sep 29, 2021
8eb6768
Address comments
Sep 29, 2021
18925df
Merge branch 'trex-continuous-helper' into tcp-linerate
Sep 30, 2021
e2e86b6
Merge branch 'normalize-trex-test' into tcp-linerate
Sep 30, 2021
6c42081
Merge branch 'main' into tcp-linerate
Sep 30, 2021
7222d87
Remove extra monitor_port_stats function
Sep 30, 2021
cf558b7
Split sanity test, normalize and add verification
Oct 1, 2021
b86dcd3
Modify push_chassis_config and remove shaped sanity test
Oct 1, 2021
8aa46ef
Upgrade TRex to v2.92 and implement linerate unshaped sanity test
Nov 5, 2021
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
6 changes: 3 additions & 3 deletions ptf/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG PROTOBUF_VER=3.12
ARG SCAPY_VER=2.4.5
ARG PTF_VER=c5299ea2e27386653209af458757b3b15e5dec5d
ARG P4RUNTIME_SHELL_VER=0.0.1
ARG TREX_VER=3b19ddcf67e33934f268b09d3364cd87275d48db
ARG TREX_VER=2.92-scapy-2.4.5
ARG TREX_EXT_LIBS=/external_libs
ARG TREX_LIBS=/trex_python
ARG UNITTEST_XML_REPORTING_VER=3.0.4
Expand Down Expand Up @@ -106,8 +106,8 @@ ARG TREX_LIBS
# Install Trex library
ENV TREX_SCRIPT_DIR=/trex-core-${TREX_VER}/scripts
# RUN apt update && apt install -y wget
RUN wget https://github.com/stratum/trex-core/archive/${TREX_VER}.zip
RUN unzip -qq ${TREX_VER}.zip && \
RUN wget https://github.com/dariusgrassi/trex-core/archive/v${TREX_VER}.zip && \
unzip -qq v${TREX_VER}.zip && \
mkdir -p /output/${TREX_EXT_LIBS} && \
mkdir -p /output/${TREX_LIBS} && \
cp -r ${TREX_SCRIPT_DIR}/automation/trex_control_plane/interactive/* /output/${TREX_LIBS} && \
Expand Down
20 changes: 18 additions & 2 deletions ptf/tests/common/ptf_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_stream_packet(type_, timeout=1):
stream_recv_thread.join()


def set_up_trex_server(trex_daemon_client, trex_address, trex_config, force_restart):
def set_up_trex_server(trex_daemon_client, trex_address, trex_config, force_restart, trex_astf_mode):

try:
# TODO: Generate TRex config based on port_map json file (e.g., include pci address in port map)
Expand All @@ -231,7 +231,13 @@ def set_up_trex_server(trex_daemon_client, trex_address, trex_config, force_rest
return False

trex_config_file_on_server = TREX_FILES_DIR + os.path.basename(trex_config)
trex_daemon_client.start_stateless(cfg=trex_config_file_on_server)

trex_cmd_options = {}
if trex_astf_mode:
trex_cmd_options['astf'] = True
trex_cmd_options['c'] = 1

trex_daemon_client.start_stateless(cfg=trex_config_file_on_server, **trex_cmd_options)
except ConnectionRefusedError:
error(
"Unable to connect to server %s.\n" + "Did you start the Trex daemon?",
Expand Down Expand Up @@ -461,6 +467,12 @@ def main():
action="store_true",
required=False,
)
parser.add_argument(
"--trex-astf-mode",
help="Enables TRex ASTF mode for advanced stateful TCP linerate testing",
action="store_true",
required=False,
)
args, unknown_args = parser.parse_known_args()

if not check_ptf():
Expand Down Expand Up @@ -494,8 +506,11 @@ def main():

# if line rate test, set up and tear down TRex
if args.trex_address is not None:
trex_args = ""
if args.trex_sw_mode:
trex_args = "--software --no-hw-flow-stat"
if args.trex_astf_mode:
trex_args += " --astf"
else:
trex_args = None
trex_daemon_client = CTRexClient(args.trex_address, trex_args=trex_args)
Expand All @@ -505,6 +520,7 @@ def main():
args.trex_address,
args.trex_config,
args.trex_force_restart,
args.trex_astf_mode,
)
if not success:
error("Failed to set up TRex daemon client!")
Expand Down
27 changes: 27 additions & 0 deletions ptf/tests/common/trex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import gnmi_utils
from base_test import *
from trex.stl.api import STLClient
from trex.astf.api import ASTFClient
import gnmi_utils


class TRexTest(P4RuntimeTest):
Expand Down Expand Up @@ -35,3 +37,28 @@ def push_chassis_config(self) -> None:
with open(f"{this_dir}/../linerate/chassis_config.pb.txt", mode="rb") as file:
chassis_config = file.read()
gnmi_utils.push_chassis_config(chassis_config)


class TRexAstfTest(P4RuntimeTest):
trex_client: ASTFClient

def setUp(self):
super(TRexAstfTest, self).setUp()
trex_server_addr = ptf.testutils.test_param_get("trex_server_addr")
self.trex_client = ASTFClient(server=trex_server_addr)
self.trex_client.connect()
self.trex_client.acquire()
self.trex_client.reset() # Resets configs from all ports
self.trex_client.clear_stats() # Clear status from all ports
# Put all ports to promiscuous mode, otherwise they will drop all
# incoming packets if the destination mac is not the port mac address.
self.trex_client.set_port_attr(
self.trex_client.get_all_ports(), promiscuous=True
)

def tearDown(self):
print("Tearing down ASTFClient...")
self.trex_client.stop()
self.trex_client.release()
self.trex_client.disconnect()
super(TRexAstfTest, self).tearDown()
39 changes: 25 additions & 14 deletions ptf/tests/linerate/qos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,31 @@
ALL_PORTS = [0, 1, 2, 3]


class QosTest(TRexTest, SlicingTest, StatsTest):
class QosBaseTest(SlicingTest):
def __init__(self):
super().__init__()
self.control_pg_id = 7
self.system_pg_id = 2

def push_chassis_config(self, yaml_file="qos-config-1g.yaml") -> None:
this_dir = os.path.dirname(os.path.realpath(__file__))
with open(f"{this_dir}/chassis_config.pb.txt", mode="rb") as file:
chassis_config = file.read()
# Auto-generate and append vendor_config
with open(f"{this_dir}/{yaml_file}", "r") as file:
chassis_config += bytes(
"\n" + vendor_config(yaml.safe_load(file)), encoding="utf8"
)
# Write to disk for debugging
with open(f"{this_dir}/chassis_config.pb.txt.tmp", mode="wb") as file:
file.write(chassis_config)
gnmi_utils.push_chassis_config(chassis_config)
def push_chassis_config(self, yaml_file="qos-config-1g.yaml", with_shaping=True) -> None:
if with_shaping:
this_dir = os.path.dirname(os.path.realpath(__file__))
with open(f"{this_dir}/chassis_config.pb.txt", mode="rb") as file:
chassis_config = file.read()
# Auto-generate and append vendor_config
with open(f"{this_dir}/{yaml_file}", "r") as file:
chassis_config += bytes(
"\n" + vendor_config(yaml.safe_load(file)), encoding="utf8"
)
# Write to disk for debugging
with open(f"{this_dir}/chassis_config.pb.txt.tmp", mode="wb") as file:
file.write(chassis_config)
gnmi_utils.push_chassis_config(chassis_config)
else:
this_dir = os.path.dirname(os.path.realpath(__file__))
with open(f"{this_dir}/../linerate/chassis_config.pb.txt", mode="rb") as file:
chassis_config = file.read()
gnmi_utils.push_chassis_config(chassis_config)

def _setup_basic_forwarding(self, out_port) -> None:
in_ports = [self.port1, self.port2, self.port3, self.port4]
Expand Down Expand Up @@ -146,6 +152,11 @@ def get_flow_stats_from_switch(
rx_bytes=eg_bytes,
)


class QosTest(TRexTest, QosBaseTest, SlicingTest, StatsTest):
def __init__(self):
super().__init__()

# Create a background traffic stream.
def create_background_stream(self) -> STLStream:
pkt = qos_utils.get_best_effort_traffic_packet()
Expand Down
Loading