aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2020-01-08 20:51:43 +0000
committerPeter Mikus <pmikus@cisco.com>2020-01-17 13:52:00 +0000
commit96bce92149e6ba9a6590a94347f42645ea8ac861 (patch)
treec047a2a1ba456c2b6f757effaceb4fbd41b52ef6 /resources/libraries/python
parente206bb978809135e907841db46ea5765070e818e (diff)
perf: add TCP Iperf3+LDPRELOAD test suite
Change-Id: Icff49fb31cce342a2a4ae799e844ec91f9e5e366 Signed-off-by: Dave Wallace <dwallacelf@gmail.com> (cherry picked from commit 6518c73a0e5cdaf12ae01d247a65aec287d01625)
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/Constants.py6
-rw-r--r--resources/libraries/python/HoststackUtil.py44
-rw-r--r--resources/libraries/python/autogen/Regenerator.py71
-rw-r--r--resources/libraries/python/autogen/Testcase.py27
4 files changed, 129 insertions, 19 deletions
diff --git a/resources/libraries/python/Constants.py b/resources/libraries/python/Constants.py
index 1b4d44c636..eded294f60 100644
--- a/resources/libraries/python/Constants.py
+++ b/resources/libraries/python/Constants.py
@@ -145,9 +145,15 @@ class Constants:
# Container templates location
RESOURCES_TPL_CONTAINER = u"resources/templates/container"
+ # VPP Communications Library templates location
+ RESOURCES_TPL_VCL = u"resources/templates/vcl"
+
# HTTP Server www root directory
RESOURCES_TP_WRK_WWW = u"resources/traffic_profiles/wrk/www"
+ # VPP Communications Library LD_PRELOAD library
+ VCL_LDPRELOAD_LIBRARY=u"/usr/lib/x86_64-linux-gnu/libvcl_ldpreload.so"
+
# OpenVPP VAT binary name
VAT_BIN_NAME = u"vpp_api_test"
diff --git a/resources/libraries/python/HoststackUtil.py b/resources/libraries/python/HoststackUtil.py
index 9e6e20014c..ad95d5114d 100644
--- a/resources/libraries/python/HoststackUtil.py
+++ b/resources/libraries/python/HoststackUtil.py
@@ -15,6 +15,7 @@
from time import sleep
from robot.api import logger
+from resources.libraries.python.Constants import Constants
from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error
from resources.libraries.python.PapiExecutor import PapiSocketExecutor
from resources.libraries.python.DUTSetup import DUTSetup
@@ -56,6 +57,49 @@ class HoststackUtil():
return vpp_echo_cmd
@staticmethod
+ def get_iperf3_command(iperf3_attributes):
+ """Construct the iperf3 command using the specified attributes.
+
+ :param iperf3_attributes: iperf3 test program attributes.
+ :type iperf3_attributes: dict
+ :returns: Command line components of the iperf3 command
+ 'env_vars' - environment variables
+ 'name' - program name
+ 'args' - command arguments.
+ :rtype: dict
+ """
+ # TODO: Use a python class instead of dictionary for the return type
+ iperf3_cmd = {}
+ iperf3_cmd[u"env_vars"] = f"VCL_CONFIG={Constants.REMOTE_FW_DIR}/" \
+ f"{Constants.RESOURCES_TPL_VCL}/" \
+ f"{iperf3_attributes[u'vcl_config']}"
+ if iperf3_attributes[u"ld_preload"]:
+ iperf3_cmd[u"env_vars"] += \
+ f" LD_PRELOAD={Constants.VCL_LDPRELOAD_LIBRARY}"
+ if iperf3_attributes[u'transparent_tls']:
+ iperf3_cmd[u"env_vars"] += u" LDP_ENV_TLS_TRANS=1"
+
+ json_results = u" --json" if iperf3_attributes[u'json'] else u""
+ ip_address = f" {iperf3_attributes[u'ip_address']}" if u"ip_address" \
+ in iperf3_attributes else u""
+ iperf3_cmd[u"name"] = u"iperf3"
+ iperf3_cmd[u"args"] = f"--{iperf3_attributes[u'role']}{ip_address} " \
+ f"--interval 0{json_results} " \
+ f"--version{iperf3_attributes[u'ip_version']}"
+
+ if iperf3_attributes[u"role"] == u"server":
+ iperf3_cmd[u"args"] += u" --one-off"
+ else:
+ iperf3_cmd[u"args"] += u" --get-server-output"
+ if u"parallel" in iperf3_attributes:
+ iperf3_cmd[u"args"] += \
+ f" --parallel {iperf3_attributes[u'parallel']}"
+ if u"bytes" in iperf3_attributes:
+ iperf3_cmd[u"args"] += \
+ f" --bytes {iperf3_attributes[u'bytes']}"
+ return iperf3_cmd
+
+ @staticmethod
def set_hoststack_quic_fifo_size(node, fifo_size):
"""Set the QUIC protocol fifo size.
diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py
index d47680ccd0..cb0d3329d5 100644
--- a/resources/libraries/python/autogen/Regenerator.py
+++ b/resources/libraries/python/autogen/Regenerator.py
@@ -113,7 +113,7 @@ def check_suite_tag(suite_tag, prolog):
"""
found = prolog.count(u"| " + suite_tag)
if found != 1:
- raise ValueError(f"Suite tag found {found} times for {suite_id}")
+ raise ValueError(f"Suite tag found {found} times for {suite_tag}")
def add_default_testcases(testcase, iface, suite_id, file_out, tc_kwargs_list):
@@ -440,22 +440,56 @@ class Regenerator:
min_frame_size = PROTOCOL_TO_MIN_FRAME_SIZE[protocol]
default_kwargs_list = [
- {u"frame_size": min_frame_size, u"phy_cores": 1},
- {u"frame_size": min_frame_size, u"phy_cores": 2},
- {u"frame_size": min_frame_size, u"phy_cores": 4},
- {u"frame_size": 1518, u"phy_cores": 1},
- {u"frame_size": 1518, u"phy_cores": 2},
- {u"frame_size": 1518, u"phy_cores": 4},
- {u"frame_size": 9000, u"phy_cores": 1},
- {u"frame_size": 9000, u"phy_cores": 2},
- {u"frame_size": 9000, u"phy_cores": 4},
- {u"frame_size": u"IMIX_v4_1", u"phy_cores": 1},
- {u"frame_size": u"IMIX_v4_1", u"phy_cores": 2},
- {u"frame_size": u"IMIX_v4_1", u"phy_cores": 4}
+ {u"frame_size": min_frame_size, u"phy_cores": 1, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": min_frame_size, u"phy_cores": 2, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": min_frame_size, u"phy_cores": 4, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": 1518, u"phy_cores": 1, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": 1518, u"phy_cores": 2, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": 1518, u"phy_cores": 4, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": 9000, u"phy_cores": 1, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": 9000, u"phy_cores": 2, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": 9000, u"phy_cores": 4, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": u"IMIX_v4_1", u"phy_cores": 1, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": u"IMIX_v4_1", u"phy_cores": 2, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"frame_size": u"IMIX_v4_1", u"phy_cores": 4, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"}
]
- tcp_kwargs_list = [
- {u"phy_cores": i, u"frame_size": 0} for i in (1, 2, 4)
+ hoststack_wrk_kwargs_list = [
+ {u"phy_cores": i, u"frame_size": 0, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"} for i in (1, 2, 4)
]
+ hoststack_iperf3_kwargs_list = [
+ {u"phy_cores": 1, u"frame_size": 0, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"1G"},
+ {u"phy_cores": 1, u"frame_size": 0, u"clients": 1,
+ u"streams": 10, u"bytes_str": u"10G"},
+ {u"phy_cores": 2, u"frame_size": 0, u"clients": 1,
+ u"streams": 10, u"bytes_str": u"10G"},
+ {u"phy_cores": 4, u"frame_size": 0, u"clients": 1,
+ u"streams": 10, u"bytes_str": u"10G"},
+ ]
+ hoststack_quic_kwargs_list = [
+ {u"phy_cores": 1, u"frame_size": 0, u"clients": 1,
+ u"streams": 1, u"bytes_str": u"100M"},
+ {u"phy_cores": 1, u"frame_size": 0, u"clients": 1,
+ u"streams": 10, u"bytes_str": u"100M"},
+ {u"phy_cores": 1, u"frame_size": 0, u"clients": 10,
+ u"streams": 1, u"bytes_str": u"100M"},
+ {u"phy_cores": 1, u"frame_size": 0, u"clients": 10,
+ u"streams": 10, u"bytes_str": u"100M"},
+ ]
+
for in_filename in glob(pattern):
if not self.quiet:
print(
@@ -480,7 +514,12 @@ class Regenerator:
elif in_filename.endswith(u"-reconf.robot"):
write_reconf_files(in_filename, in_prolog, default_kwargs_list)
elif in_filename[-10:] in (u"-cps.robot", u"-rps.robot"):
- write_tcp_files(in_filename, in_prolog, tcp_kwargs_list)
+ write_tcp_files(in_filename, in_prolog,
+ hoststack_wrk_kwargs_list)
+ elif in_filename[-10:] in (u"-bps.robot"):
+ write_tcp_files(in_filename, in_prolog,
+ hoststack_iperf3_kwargs_list if u"iperf3"
+ in in_filename else hoststack_quic_kwargs_list)
else:
raise RuntimeError(
f"Error in {in_filename}: non-primary suite type found."
diff --git a/resources/libraries/python/autogen/Testcase.py b/resources/libraries/python/autogen/Testcase.py
index 224295e1e2..6b4cfb2e06 100644
--- a/resources/libraries/python/autogen/Testcase.py
+++ b/resources/libraries/python/autogen/Testcase.py
@@ -34,7 +34,8 @@ class Testcase:
"""
self.template = Template(template_string)
- def generate(self, num, frame_size, phy_cores):
+ def generate(self, num, frame_size, phy_cores, clients, streams,
+ bytes_str):
"""Return string of test case code with placeholders filled.
Fail if there are placeholders left unfilled.
@@ -43,9 +44,16 @@ class Testcase:
:param num: Test case number. Example value: 4.
:param frame_size: Imix string or numeric frame size. Example: 74.
:param phy_cores: Number of physical cores to use. Example: 2.
+ :param clients: Number of clients used by test program. Example: 4.
+ :param streams: Number of streams used by test program. Example: 10.
+ :param bytes_str: Size in bytes of stream sent by test program.
+ Example: 1G
:type num: int
:type frame_size: str or int
:type phy_cores: int or str
+ :type clients: int
+ :type streams: int
+ :type bytes_str: str
:returns: Filled template, usable as test case code.
:rtype: str
"""
@@ -66,7 +74,12 @@ class Testcase:
{
u"cores_num": f"${{{cores_num:d}}}",
u"cores_str": phy_cores,
- u"tc_num": f"tc{num:02d}"
+ u"tc_num": f"tc{num:02d}",
+ u"clients_num": f"${{{clients:d}}}",
+ u"clients_str": str(clients),
+ u"streams_num": f"${{{streams:d}}}",
+ u"streams_str": str(streams),
+ u"bytes_str": bytes_str,
}
)
return self.template.substitute(subst_dict)
@@ -103,9 +116,17 @@ class Testcase:
"""
# TODO: Choose a better frame size identifier for streamed protocols
# (TCP, QUIC, SCTP, ...) where DUT (not TG) decides frame size.
- template_string = f'''
+ if u"tcphttp" in suite_id:
+ template_string = f'''
| ${{tc_num}}-IMIX-${{cores_str}}c-{suite_id}
| | [Tags] | ${{cores_str}}C
| | phy_cores=${{cores_num}}
'''
+ else:
+ template_string = f'''
+| ${{tc_num}}-IMIX-${{cores_str}}c-{suite_id}
+| | [Tags] | ${{cores_str}}C | ${{clients_str}}CLIENT | ${{streams_str}}STREAM
+| | phy_cores=${{cores_num}} | clients=${{clients_num}}'''
+ template_string += f" | streams=${{streams_num}}" \
+ f" | bytes=${{bytes_str}}\n"
return cls(template_string)