aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2020-01-03 16:01:30 +0100
committerJan Gelety <jgelety@cisco.com>2020-01-10 16:08:42 +0100
commitb55e324d526e5b05baef015c3614b9743c955992 (patch)
tree1e42006c4513bdcdee35eb5f677e055b64c06e86 /resources/libraries/python
parent5147d3ac0844b31852a3c221759f31915744b1c7 (diff)
Autogen: Generate also NIC drivers.
+ Disallowed -avf- (or -rdma-) as "template" suites. + GBP suite switched to DPDK driver in repo. + Each NIC has its own list of supported drivers, in Constants. + Updated tag expressions for daily jobs: + Feature, ipsec, memif, scale, srv6, tunnels, vhost and vts are tested only with vfio-pci. + Other (base, dot1q, dot1ad) tested with all drivers. + Setup actions currently depend on driver, generated. - The performance_rdma action is trivial for now. - Several tests fail, to be fixed later, e.g. by performance_rdma. + Reconf tests are also supported. + Added DRV_VFIO_PCI tags missing, mainly in density tests. - Vhost suites (density, reconf) are failing, but suites look good. - TCP suites do not support NIC drivers yet. - DPDK obviously not supported. + Use Python 3 in regenerate scripts. + Fix typos binded => bound. + File open modes set either u"rt" or u"wt" everywhere. + Remove a trailing space in an environment variable name. Change-Id: I290470675dc5c9e88b2eaa5ab6285ecd9ed7827a Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/Constants.py43
-rw-r--r--resources/libraries/python/ContainerUtils.py2
-rw-r--r--resources/libraries/python/QemuUtils.py4
-rw-r--r--resources/libraries/python/VatExecutor.py6
-rw-r--r--resources/libraries/python/VppApiCrc.py4
-rw-r--r--resources/libraries/python/autogen/Regenerator.py127
-rw-r--r--resources/libraries/python/parsers/JsonParser.py2
7 files changed, 151 insertions, 37 deletions
diff --git a/resources/libraries/python/Constants.py b/resources/libraries/python/Constants.py
index dc9eda7505..0e06857472 100644
--- a/resources/libraries/python/Constants.py
+++ b/resources/libraries/python/Constants.py
@@ -185,7 +185,7 @@ class Constants:
TREX_INSTALL_DIR = u"/opt/trex-core-2.73"
# TRex limit memory.
- TREX_LIMIT_MEMORY = get_int_from_env(u"TREX_LIMIT_MEMORY ", 4096)
+ TREX_LIMIT_MEMORY = get_int_from_env(u"TREX_LIMIT_MEMORY", 4096)
# TRex number of cores
TREX_CORE_COUNT = get_int_from_env(u"TREX_CORE_COUNT", 7)
@@ -270,6 +270,47 @@ class Constants:
u"Mellanox-CX556A": u"100ge2p1cx556a",
}
+ # Not each driver is supported by each NIC.
+ NIC_NAME_TO_DRIVER = {
+ u"Cisco-VIC-1227": [u"vfio-pci"],
+ u"Cisco-VIC-1385": [u"vfio-pci"],
+ u"Intel-X520-DA2": [u"vfio-pci"],
+ u"Intel-X553": [u"vfio-pci"],
+ u"Intel-X710": [u"vfio-pci", u"avf"],
+ u"Intel-XL710": [u"vfio-pci", u"avf"],
+ u"Intel-XXV710": [u"vfio-pci", u"avf"],
+ u"Mellanox-CX556A": [u"rdma-core"],
+ }
+
+ # Each driver needs different prugin to work.
+ NIC_DRIVER_TO_PLUGINS = {
+ u"vfio-pci": u"dpdk_plugin.so",
+ u"avf": u"avf_plugin.so",
+ u"rdma-core": u"rdma_plugin.so",
+ }
+
+ # Tags to differentiate tests for different NIC driver.
+ NIC_DRIVER_TO_TAG = {
+ u"vfio-pci": u"DRV_VFIO_PCI",
+ u"avf": u"DRV_AVF",
+ u"rdma-core": u"DRV_RDMA_CORE",
+ }
+
+ # Suite names have to be different, add prefix.
+ NIC_DRIVER_TO_SUITE_PREFIX = {
+ u"vfio-pci": u"",
+ u"avf": u"avf-",
+ u"rdma-core": u"rdma-",
+ }
+
+ # Additional step for perf needs to know driver type.
+ # Contains part of suite setup line, matching both single and double link.
+ NIC_DRIVER_TO_SETUP_ARG = {
+ u"vfio-pci": u"le link | performance",
+ u"avf": u"le link | performance_avf",
+ u"rdma-core": u"le link | performance_rdma",
+ }
+
# TODO CSIT-1481: Crypto HW should be read from topology file instead.
NIC_NAME_TO_CRYPTO_HW = {
u"Intel-X553": u"HW_C3xxx",
diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py
index b2d0296656..a3b79518c2 100644
--- a/resources/libraries/python/ContainerUtils.py
+++ b/resources/libraries/python/ContainerUtils.py
@@ -696,7 +696,7 @@ class ContainerEngine:
running = u"/tmp/running.exec"
template = f"{Constants.RESOURCES_TPL_CONTAINER}/{template_file}"
- with open(template, "r") as src_file:
+ with open(template, u"rt") as src_file:
src = Template(src_file.read())
self.execute(f'echo "{src.safe_substitute(**kwargs)}" > {running}')
diff --git a/resources/libraries/python/QemuUtils.py b/resources/libraries/python/QemuUtils.py
index 09c3df7725..f31e153bd2 100644
--- a/resources/libraries/python/QemuUtils.py
+++ b/resources/libraries/python/QemuUtils.py
@@ -236,7 +236,7 @@ class QemuUtils:
template = f"{Constants.RESOURCES_TPL_VM}/{self._opt.get(u'vnf')}.exec"
exec_cmd_no_error(self._node, f"rm -f {running}", sudo=True)
- with open(template, "r") as src_file:
+ with open(template, u"rt") as src_file:
src = Template(src_file.read())
exec_cmd_no_error(
self._node, f"echo '{src.safe_substitute(**kwargs)}' | "
@@ -296,7 +296,7 @@ class QemuUtils:
init = self._temp.get(u"ini")
exec_cmd_no_error(self._node, f"rm -f {init}", sudo=True)
- with open(template, "r") as src_file:
+ with open(template, u"rt") as src_file:
src = Template(src_file.read())
exec_cmd_no_error(
self._node, f"echo '{src.safe_substitute(**kwargs)}' | "
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py
index 1de32a2a21..26d4b75781 100644
--- a/resources/libraries/python/VatExecutor.py
+++ b/resources/libraries/python/VatExecutor.py
@@ -113,7 +113,7 @@ class VatExecutor:
ssh.scp(vat_name, vat_name)
remote_file_path = vat_name
if history:
- with open(vat_name, "r") as vat_file:
+ with open(vat_name, u"rt") as vat_file:
for line in vat_file:
PapiHistory.add_to_papi_history(
node, line.replace(u"\n", u""), papi=False
@@ -155,7 +155,7 @@ class VatExecutor:
:type timeout: int
:type json_out: bool
"""
- with open(tmp_fn, "w") as tmp_f:
+ with open(tmp_fn, u"wt") as tmp_f:
tmp_f.writelines(commands)
self.execute_script(
@@ -388,7 +388,7 @@ class VatTerminal:
"""
file_path = f"{Constants.RESOURCES_TPL_VAT}/{vat_template_file}"
- with open(file_path, "r") as template_file:
+ with open(file_path, u"rt") as template_file:
cmd_template = template_file.readlines()
ret = list()
for line_tmpl in cmd_template:
diff --git a/resources/libraries/python/VppApiCrc.py b/resources/libraries/python/VppApiCrc.py
index d55058e431..693dac064a 100644
--- a/resources/libraries/python/VppApiCrc.py
+++ b/resources/libraries/python/VppApiCrc.py
@@ -132,7 +132,7 @@ class VppApiCrcChecker:
file_path = os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(__file__)), u"..", u"..",
u"api", u"vpp", u"supported_crcs.yaml"))
- with open(file_path, "r") as file_in:
+ with open(file_path, u"rt") as file_in:
collections_dict = yaml.safe_load(file_in.read())
for collection_name, name_to_crc_mapping in collections_dict.items():
self._register_collection(collection_name, name_to_crc_mapping)
@@ -242,7 +242,7 @@ class VppApiCrcChecker:
for filename in files:
if not filename.endswith(u".api.json"):
continue
- with open(f"{root}/{filename}", "r") as file_in:
+ with open(f"{root}/{filename}", u"rt") as file_in:
json_obj = json.load(file_in)
msgs = json_obj[u"messages"]
for msg_obj in msgs:
diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py
index 7271fbcf37..b1d0c9e993 100644
--- a/resources/libraries/python/autogen/Regenerator.py
+++ b/resources/libraries/python/autogen/Regenerator.py
@@ -188,31 +188,66 @@ def write_default_files(in_filename, in_prolog, kwargs_list):
_, suite_id = get_iface_and_suite_id(tmp_filename)
testcase = Testcase.default(suite_id)
for nic_name in Constants.NIC_NAME_TO_CODE:
- out_filename = replace_defensively(
+ tmp2_filename = replace_defensively(
tmp_filename, u"10ge2p1x710",
Constants.NIC_NAME_TO_CODE[nic_name], 1,
u"File name should contain NIC code once.", in_filename
)
- out_prolog = replace_defensively(
+ tmp2_prolog = replace_defensively(
tmp_prolog, u"Intel-X710", nic_name, 2,
u"NIC name should appear twice (tag and variable).",
in_filename
)
- if out_prolog.count(u"HW_") == 2:
+ if tmp2_prolog.count(u"HW_") == 2:
# TODO CSIT-1481: Crypto HW should be read
# from topology file instead.
if nic_name in Constants.NIC_NAME_TO_CRYPTO_HW:
- out_prolog = replace_defensively(
- out_prolog, u"HW_DH895xcc",
+ tmp2_prolog = replace_defensively(
+ tmp2_prolog, u"HW_DH895xcc",
Constants.NIC_NAME_TO_CRYPTO_HW[nic_name], 1,
u"HW crypto name should appear.", in_filename
)
- iface, suite_id = get_iface_and_suite_id(out_filename)
- with open(out_filename, "wt") as file_out:
- file_out.write(out_prolog)
- add_default_testcases(
- testcase, iface, suite_id, file_out, kwargs_list
+ iface, old_suite_id = get_iface_and_suite_id(tmp2_filename)
+ if u"DPDK" in in_prolog:
+ with open(tmp2_filename, u"wt") as file_out:
+ file_out.write(tmp2_prolog)
+ add_default_testcases(
+ testcase, iface, old_suite_id, file_out, kwargs_list
+ )
+ return
+ for driver in Constants.NIC_NAME_TO_DRIVER[nic_name]:
+ out_filename = replace_defensively(
+ tmp2_filename, old_suite_id,
+ Constants.NIC_DRIVER_TO_SUITE_PREFIX[driver] + old_suite_id,
+ 1, u"Error adding driver prefix.", in_filename
+ )
+ out_prolog = replace_defensively(
+ tmp2_prolog, u"vfio-pci", driver, 1,
+ u"Driver name should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_TAG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_TAG[driver], 1,
+ u"Driver tag should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_PLUGINS[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_PLUGINS[driver], 1,
+ u"Driver plugin should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_SETUP_ARG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_SETUP_ARG[driver], 1,
+ u"Perf setup argument should appear once.", in_filename
)
+ iface, suite_id = get_iface_and_suite_id(out_filename)
+ # TODO: Reorder loops so suite_id is finalized sooner.
+ testcase = Testcase.default(suite_id)
+ with open(out_filename, u"wt") as file_out:
+ file_out.write(out_prolog)
+ add_default_testcases(
+ testcase, iface, suite_id, file_out, kwargs_list
+ )
def write_reconf_files(in_filename, in_prolog, kwargs_list):
@@ -232,36 +267,66 @@ def write_reconf_files(in_filename, in_prolog, kwargs_list):
_, suite_id = get_iface_and_suite_id(in_filename)
testcase = Testcase.default(suite_id)
for nic_name in Constants.NIC_NAME_TO_CODE:
- out_filename = replace_defensively(
+ tmp_filename = replace_defensively(
in_filename, u"10ge2p1x710",
Constants.NIC_NAME_TO_CODE[nic_name], 1,
u"File name should contain NIC code once.", in_filename
)
- out_prolog = replace_defensively(
+ tmp_prolog = replace_defensively(
in_prolog, u"Intel-X710", nic_name, 2,
u"NIC name should appear twice (tag and variable).",
in_filename
)
- if out_prolog.count(u"HW_") == 2:
+ if tmp_prolog.count(u"HW_") == 2:
# TODO CSIT-1481: Crypto HW should be read
# from topology file instead.
- if nic_name in list(Constants.NIC_NAME_TO_CRYPTO_HW.keys()):
- out_prolog = replace_defensively(
- out_prolog, u"HW_DH895xcc",
+ if nic_name in Constants.NIC_NAME_TO_CRYPTO_HW.keys():
+ tmp_prolog = replace_defensively(
+ tmp_prolog, u"HW_DH895xcc",
Constants.NIC_NAME_TO_CRYPTO_HW[nic_name], 1,
u"HW crypto name should appear.", in_filename
)
- iface, suite_id = get_iface_and_suite_id(out_filename)
- with open(out_filename, "wt") as file_out:
- file_out.write(out_prolog)
- add_default_testcases(
- testcase, iface, suite_id, file_out, kwargs_list
+ iface, old_suite_id = get_iface_and_suite_id(tmp_filename)
+ for driver in Constants.NIC_NAME_TO_DRIVER[nic_name]:
+ out_filename = replace_defensively(
+ tmp_filename, old_suite_id,
+ Constants.NIC_DRIVER_TO_SUITE_PREFIX[driver] + old_suite_id,
+ 1, u"Error adding driver prefix.", in_filename
+ )
+ out_prolog = replace_defensively(
+ tmp_prolog, u"vfio-pci", driver, 1,
+ u"Driver name should appear once.", in_filename
)
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_TAG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_TAG[driver], 1,
+ u"Driver tag should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_PLUGINS[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_PLUGINS[driver], 1,
+ u"Driver plugin should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_SETUP_ARG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_SETUP_ARG[driver], 1,
+ u"Perf setup argument should appear once.", in_filename
+ )
+ iface, suite_id = get_iface_and_suite_id(out_filename)
+ # TODO: Reorder loops so suite_id is finalized sooner.
+ testcase = Testcase.default(suite_id)
+ with open(out_filename, u"wt") as file_out:
+ file_out.write(out_prolog)
+ add_default_testcases(
+ testcase, iface, suite_id, file_out, kwargs_list
+ )
def write_tcp_files(in_filename, in_prolog, kwargs_list):
"""Using given filename and prolog, write all generated tcp suites.
+ TODO: Suport drivers.
+
:param in_filename: Template filename to derive real filenames from.
:param in_prolog: Template content to derive real content from.
:param kwargs_list: List of kwargs for add_default_testcase.
@@ -283,7 +348,7 @@ def write_tcp_files(in_filename, in_prolog, kwargs_list):
u"NIC name should appear twice (tag and variable).",
in_filename
)
- with open(out_filename, "wt") as file_out:
+ with open(out_filename, u"wt") as file_out:
file_out.write(out_prolog)
add_tcp_testcases(testcase, file_out, kwargs_list)
@@ -303,9 +368,9 @@ class Regenerator:
"""Regenerate files matching glob pattern based on arguments.
In the current working directory, find all files matching
- the glob pattern. Use testcase template according to suffix
- to regenerate test cases, auto-numbering them,
- taking arguments from list.
+ the glob pattern. Use testcase template to regenerate test cases
+ according to suffix, governed by protocol, autonumbering them.
+ Also generate suites for other NICs and drivers.
Log-like prints are emitted to sys.stderr.
@@ -336,6 +401,9 @@ class Regenerator:
tcp_kwargs_list = [
{u"phy_cores": i, u"frame_size": 0} for i in (1, 2, 4)
]
+ forbidden = [
+ v for v in Constants.NIC_DRIVER_TO_SUITE_PREFIX.values() if v
+ ]
for in_filename in glob(pattern):
if not self.quiet:
print(
@@ -346,9 +414,14 @@ class Regenerator:
raise RuntimeError(
f"Error in {in_filename}: non-primary NIC found."
)
- with open(in_filename, "rt") as file_in:
+ for prefix in forbidden:
+ if prefix in in_filename:
+ raise RuntimeError(
+ f"Error in {in_filename}: non-primary driver found."
+ )
+ with open(in_filename, u"rt") as file_in:
in_prolog = u"".join(
- file_in.read().partition("*** Test Cases ***")[:-1]
+ file_in.read().partition(u"*** Test Cases ***")[:-1]
)
if in_filename.endswith(u"-ndrpdr.robot"):
write_default_files(in_filename, in_prolog, default_kwargs_list)
diff --git a/resources/libraries/python/parsers/JsonParser.py b/resources/libraries/python/parsers/JsonParser.py
index c597d5a935..bebe2a2407 100644
--- a/resources/libraries/python/parsers/JsonParser.py
+++ b/resources/libraries/python/parsers/JsonParser.py
@@ -49,6 +49,6 @@ class JsonParser:
:returns: JSON data parsed as python list.
:rtype: list
"""
- input_data = open(json_file, "rt").read()
+ input_data = open(json_file, u"rt").read()
parsed_data = JsonParser.parse_data(input_data)
return parsed_data