aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2019-12-20 22:46:51 +0000
committerPeter Mikus <pmikus@cisco.com>2020-01-15 07:01:56 +0000
commit2da2aa12260143bc513b4dff5e2b2ef6755172ab (patch)
tree8bbd4b177bc7e12cd942b7a91a4af8641af24935 /resources/libraries
parent6ae8614cf1459f977508f9f4ba3548ac0a16b231 (diff)
Hoststack perf infrastructure refactoring
- DUT only topology (hoststack test apps are co-located with vpp) - Make vpp app specific keywords generic where applicable - Add IP4 Prefix to topology file - Support running wrk in linux namespace - Refactor namespace cleanup - Remove redundant namespace creation code - Refactor test/keyword dirs: tcp -> hoststack - Add hoststack utility keywords - Refactor wrk suite setup/teardown - Update tests with recent perf infra changes Change-Id: Ia1cf07978d579393eef94923819a87c8c1f36f34 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'resources/libraries')
-rw-r--r--resources/libraries/python/Constants.py8
-rw-r--r--resources/libraries/python/CoreDumpUtil.py4
-rw-r--r--resources/libraries/python/DUTSetup.py82
-rw-r--r--resources/libraries/python/HoststackUtil.py287
-rw-r--r--resources/libraries/python/IPUtil.py104
-rw-r--r--resources/libraries/python/Namespaces.py81
-rw-r--r--resources/libraries/python/VPPUtil.py7
-rw-r--r--resources/libraries/python/VatExecutor.py4
-rw-r--r--resources/libraries/python/VppConfigGenerator.py21
-rw-r--r--resources/libraries/python/topology.py20
-rw-r--r--resources/libraries/robot/hoststack/hoststack.robot372
-rw-r--r--resources/libraries/robot/hoststack/tcp_setup.robot (renamed from resources/libraries/robot/tcp/tcp_setup.robot)0
-rw-r--r--resources/libraries/robot/shared/default.robot27
-rw-r--r--resources/libraries/robot/shared/suite_setup.robot77
-rw-r--r--resources/libraries/robot/shared/suite_teardown.robot19
-rw-r--r--resources/libraries/robot/wrk/wrk_utils.robot18
16 files changed, 1057 insertions, 74 deletions
diff --git a/resources/libraries/python/Constants.py b/resources/libraries/python/Constants.py
index 0a8470ec65..dc9eda7505 100644
--- a/resources/libraries/python/Constants.py
+++ b/resources/libraries/python/Constants.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -224,6 +224,12 @@ class Constants:
u"FAIL_ON_CRC_MISMATCH"
)
+ # Default IP4 prefix length (if not defined in topology file)
+ DEFAULT_IP4_PREFIX_LENGTH = u"24"
+
+ # Maximum number of interfaces in a data path
+ DATAPATH_INTERFACES_MAX = 100
+
# Mapping from NIC name to its bps limit.
NIC_NAME_TO_BPS_LIMIT = {
u"Cisco-VIC-1227": 10000000000,
diff --git a/resources/libraries/python/CoreDumpUtil.py b/resources/libraries/python/CoreDumpUtil.py
index 57f0c1d896..e1c7b65765 100644
--- a/resources/libraries/python/CoreDumpUtil.py
+++ b/resources/libraries/python/CoreDumpUtil.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -113,7 +113,7 @@ class CoreDumpUtil:
:type node: dict
"""
if node[u"type"] == NodeType.DUT and self.is_core_limit_enabled():
- vpp_pid = DUTSetup.get_vpp_pid(node)
+ vpp_pid = DUTSetup.get_pid(node, u"vpp")
self.enable_coredump_limit(node, vpp_pid)
def enable_coredump_limit_vpp_on_all_duts(self, nodes):
diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py
index d0da4645d2..431ccfb8ae 100644
--- a/resources/libraries/python/DUTSetup.py
+++ b/resources/libraries/python/DUTSetup.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -13,10 +13,11 @@
"""DUT setup library."""
+from time import sleep
from robot.api import logger
from resources.libraries.python.Constants import Constants
-from resources.libraries.python.ssh import SSH, exec_cmd_no_error
+from resources.libraries.python.ssh import SSH, exec_cmd, exec_cmd_no_error
from resources.libraries.python.topology import NodeType, Topology
@@ -157,11 +158,62 @@ class DUTSetup:
DUTSetup.stop_service(node, service)
@staticmethod
- def get_vpp_pid(node):
- """Get PID of running VPP process.
+ def kill_program(node, program, namespace=None):
+ """Kill program on the specified topology node.
+
+ :param node: Topology node.
+ :param program: Program name.
+ :param namespace: Namespace program is running in.
+ :type node: dict
+ :type program: str
+ :type namespace: str
+ """
+ host = node[u"host"]
+ cmd_timeout = 5
+ if namespace in (None, u"default"):
+ shell_cmd = u"sh -c"
+ else:
+ shell_cmd = f"ip netns exec {namespace} sh -c"
+
+ pgrep_cmd = f"{shell_cmd} \'pgrep {program}\'"
+ ret_code, _, _ = exec_cmd(node, pgrep_cmd, timeout=cmd_timeout,
+ sudo=True)
+ if ret_code == 0:
+ logger.trace(f"{program} is not running on {host}")
+ return
+ ret_code, _, _ = exec_cmd(node, f"{shell_cmd} \'pkill {program}\'",
+ timeout=cmd_timeout, sudo=True)
+ for attempt in range(5):
+ ret_code, _, _ = exec_cmd(node, pgrep_cmd, timeout=cmd_timeout,
+ sudo=True)
+ if ret_code != 0:
+ logger.trace(f"Attempt {attempt}: {program} is dead on {host}")
+ return
+ sleep(1)
+ logger.trace(f"SIGKILLing {program} on {host}")
+ ret_code, _, _ = exec_cmd(node, f"{shell_cmd} \'pkill -9 {program}\'",
+ timeout=cmd_timeout, sudo=True)
+
+ @staticmethod
+ def verify_program_installed(node, program):
+ """Verify that program is installed on the specified topology node.
+
+ :param node: Topology node.
+ :param program: Program name.
+ :type node: dict
+ :type program: str
+ """
+ cmd = f"command -v {program}"
+ exec_cmd_no_error(node, cmd, message=f"{program} is not installed")
+
+ @staticmethod
+ def get_pid(node, process):
+ """Get PID of running process.
:param node: DUT node.
+ :param process: process name.
:type node: dict
+ :type process: str
:returns: PID
:rtype: int
:raises RuntimeError: If it is not possible to get the PID.
@@ -171,26 +223,24 @@ class DUTSetup:
retval = None
for i in range(3):
- logger.trace(f"Try {i}: Get VPP PID")
- ret_code, stdout, stderr = ssh.exec_command(u"pidof vpp")
+ logger.trace(f"Try {i}: Get {process} PID")
+ ret_code, stdout, stderr = ssh.exec_command(f"pidof {process}")
if int(ret_code):
raise RuntimeError(
- f"Not possible to get PID of VPP process on node: "
+ f"Not possible to get PID of {process} process on node: "
f"{node[u'host']}\n {stdout + stderr}"
)
pid_list = stdout.split()
if len(pid_list) == 1:
- retval = int(stdout)
- elif not pid_list:
- logger.debug(f"No VPP PID found on node {node[u'host']}")
+ return [int(stdout)]
+ if not pid_list:
+ logger.debug(f"No {process} PID found on node {node[u'host']}")
continue
- else:
- logger.debug(
- f"More then one VPP PID found on node {node[u'host']}"
- )
- retval = [int(pid) for pid in pid_list]
+ logger.debug(f"More than one {process} PID found " \
+ f"on node {node[u'host']}")
+ retval = [int(pid) for pid in pid_list]
return retval
@@ -206,7 +256,7 @@ class DUTSetup:
pids = dict()
for node in nodes.values():
if node[u"type"] == NodeType.DUT:
- pids[node[u"host"]] = DUTSetup.get_vpp_pid(node)
+ pids[node[u"host"]] = DUTSetup.get_pid(node, u"vpp")
return pids
@staticmethod
diff --git a/resources/libraries/python/HoststackUtil.py b/resources/libraries/python/HoststackUtil.py
new file mode 100644
index 0000000000..9e6e20014c
--- /dev/null
+++ b/resources/libraries/python/HoststackUtil.py
@@ -0,0 +1,287 @@
+# Copyright (c) 2020 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Host Stack util library."""
+from time import sleep
+from robot.api import logger
+
+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
+
+class HoststackUtil():
+ """Utilities for Host Stack tests."""
+
+ @staticmethod
+ def get_vpp_echo_command(vpp_echo_attributes):
+ """Construct the vpp_echo command using the specified attributes.
+
+ :param vpp_echo_attributes: vpp_echo test program attributes.
+ :type vpp_echo_attributes: dict
+ :returns: Command line components of the vpp_echo command
+ 'name' - program name
+ 'args' - command arguments.
+ :rtype: dict
+ """
+ # TODO: Use a python class instead of dictionary for the return type
+ proto = vpp_echo_attributes[u"uri_protocol"]
+ addr = vpp_echo_attributes[u"uri_ip4_addr"]
+ port = vpp_echo_attributes[u"uri_port"]
+ vpp_echo_cmd = {}
+ vpp_echo_cmd[u"name"] = u"vpp_echo"
+ vpp_echo_cmd[u"args"] = f"{vpp_echo_attributes[u'role']} " \
+ f"socket-name {vpp_echo_attributes[u'vpp_api_socket']} " \
+ f"{vpp_echo_attributes[u'json_output']} " \
+ f"uri {proto}://{addr}/{port} " \
+ f"nclients {vpp_echo_attributes[u'nclients']} " \
+ f"quic-streams {vpp_echo_attributes[u'quic_streams']} " \
+ f"time {vpp_echo_attributes[u'time']} " \
+ f"fifo-size {vpp_echo_attributes[u'fifo_size']} " \
+ f"TX={vpp_echo_attributes[u'tx_bytes']} " \
+ f"RX={vpp_echo_attributes[u'rx_bytes']}"
+ if vpp_echo_attributes[u"rx_results_diff"]:
+ vpp_echo_cmd[u"args"] += u" rx-results-diff"
+ if vpp_echo_attributes[u"tx_results_diff"]:
+ vpp_echo_cmd[u"args"] += u" tx-results-diff"
+ return vpp_echo_cmd
+
+ @staticmethod
+ def set_hoststack_quic_fifo_size(node, fifo_size):
+ """Set the QUIC protocol fifo size.
+
+ :param node: Node to set the QUIC fifo size on.
+ :param fifo_size: fifo size, passed to the quic set fifo-size command.
+ :type node: dict
+ :type fifo_size: str
+ """
+ cmd = f"quic set fifo-size {fifo_size}"
+ PapiSocketExecutor.run_cli_cmd(node, cmd)
+
+ @staticmethod
+ def set_hoststack_quic_crypto_engine(node, quic_crypto_engine,
+ fail_on_error=False):
+ """Set the Hoststack QUIC crypto engine on node
+
+ :param node: Node to enable/disable HostStack.
+ :param quic_crypto_engine: type of crypto engine
+ :type node: dict
+ :type quic_crypto_engine: str
+ """
+ vpp_crypto_engines = {u"openssl", u"ia32", u"ipsecmb"}
+ if quic_crypto_engine == u"nocrypto":
+ logger.trace(u"No QUIC crypto engine.")
+ return
+
+ if quic_crypto_engine in vpp_crypto_engines:
+ cmds = [u"quic set crypto api vpp",
+ f"set crypto handler aes-128-gcm {quic_crypto_engine}",
+ f"set crypto handler aes-256-gcm {quic_crypto_engine}"]
+ elif quic_crypto_engine == u"picotls":
+ cmds = [u"quic set crypto api picotls"]
+ else:
+ raise ValueError(f"Unknown QUIC crypto_engine {quic_crypto_engine}")
+
+ for cmd in cmds:
+ try:
+ PapiSocketExecutor.run_cli_cmd(node, cmd)
+ except AssertionError:
+ if fail_on_error:
+ raise
+
+ @staticmethod
+ def get_hoststack_test_program_logs(node, program):
+ """Get HostStack test program stdout log.
+
+ :param node: DUT node.
+ :param program: test program.
+ :type node: dict
+ :type program: dict
+ """
+ program_name = program[u"name"]
+ cmd = f"sh -c \'cat /tmp/{program_name}_stdout.log\'"
+ stdout_log, _ = exec_cmd_no_error(node, cmd, sudo=True, \
+ message=f"Get {program_name} stdout log failed!")
+
+ cmd = f"sh -c \'cat /tmp/{program_name}_stderr.log\'"
+ stderr_log, _ = exec_cmd_no_error(node, cmd, sudo=True, \
+ message=f"Get {program_name} stderr log failed!")
+ return stdout_log, stderr_log
+
+ @staticmethod
+ def start_hoststack_test_program(node, namespace, program):
+ """Start the specified HostStack test program.
+
+ :param node: DUT node.
+ :param namespace: Net Namespace to run program in.
+ :param program: Test program.
+ :type node: dict
+ :type namespace: str
+ :type program: dict
+ :returns: Process ID
+ :rtype: int
+ :raises RuntimeError: If node subtype is not a DUT or startup failed.
+ """
+ # TODO: Pin test program to core(s) on same numa node as VPP.
+ if node[u"type"] != u"DUT":
+ raise RuntimeError(u"Node type is not a DUT!")
+
+ program_name = program[u"name"]
+ DUTSetup.kill_program(node, program_name, namespace)
+
+ if namespace == u"default":
+ shell_cmd = u"sh -c"
+ else:
+ shell_cmd = f"ip netns exec {namespace} sh -c"
+
+ env_vars = f"{program[u'env_vars']} " if u"env_vars" in program else u""
+ args = program[u"args"]
+ cmd = f"nohup {shell_cmd} \'{env_vars}{program_name} {args} " \
+ f">/tmp/{program_name}_stdout.log " \
+ f"2>/tmp/{program_name}_stderr.log &\'"
+ try:
+ exec_cmd_no_error(node, cmd, sudo=True)
+ return DUTSetup.get_pid(node, program_name)[0]
+ except RuntimeError:
+ stdout_log, stderr_log = \
+ HoststackUtil.get_hoststack_test_program_logs(node,
+ program)
+ raise RuntimeError(f"Start {program_name} failed!\nSTDERR:\n" \
+ f"{stderr_log}\nSTDOUT:\n{stdout_log}")
+ return None
+
+ @staticmethod
+ def stop_hoststack_test_program(node, program, pid):
+ """Stop the specified Hoststack test program.
+
+ :param node: DUT node.
+ :param program: Test program.
+ :param pid: Process ID of test program.
+ :type node: dict
+ :type program: dict
+ :type pid: int
+ """
+ program_name = program[u"name"]
+ if program_name == u"nginx":
+ cmd = u"nginx -s quit"
+ errmsg = u"Quit nginx failed!"
+ else:
+ cmd = f'if [ -n "$(ps {pid} | grep {program_name})" ] ; ' \
+ f'then kill -s SIGTERM {pid}; fi'
+ errmsg = f"Kill {program_name} ({pid}) failed!"
+
+ exec_cmd_no_error(node, cmd, message=errmsg, sudo=True)
+
+ @staticmethod
+ def hoststack_test_program_finished(node, program_pid):
+ """Wait for the specified HostStack test program process to complete.
+
+ :param node: DUT node.
+ :param program_pid: test program pid.
+ :type node: dict
+ :type program_pid: str
+ :raises RuntimeError: If node subtype is not a DUT.
+ """
+ if node[u"type"] != u"DUT":
+ raise RuntimeError(u"Node type is not a DUT!")
+
+ cmd = f"sh -c 'strace -qqe trace=none -p {program_pid}'"
+ exec_cmd(node, cmd, sudo=True)
+ # Wait a bit for stdout/stderr to be flushed to log files
+ # TODO: see if sub-second sleep works e.g. sleep(0.1)
+ sleep(1)
+
+ @staticmethod
+ def analyze_hoststack_test_program_output(node, role, nsim_attr,
+ program):
+ """Gather HostStack test program output and check for errors.
+
+ :param node: DUT node.
+ :param role: Role (client|server) of test program.
+ :param nsim_attr: Network Simulation Attributes.
+ :param program: Test program.
+ :param program_args: List of test program args.
+ :type node: dict
+ :type role: str
+ :type nsim_attr: dict
+ :type program: dict
+ :returns: tuple of no results bool and test program results.
+ :rtype: bool, str
+ :raises RuntimeError: If node subtype is not a DUT.
+ """
+ if node[u"type"] != u"DUT":
+ raise RuntimeError(u"Node type is not a DUT!")
+
+ program_name = program[u"name"]
+ program_stdout, program_stderr = \
+ HoststackUtil.get_hoststack_test_program_logs(node, program)
+ if len(program_stdout) == 0 and len(program_stderr) == 0:
+ logger.trace(f"Retrying {program_name} log retrieval")
+ program_stdout, program_stderr = \
+ HoststackUtil.get_hoststack_test_program_logs(node, program)
+
+ no_results = False
+ env_vars = f"{program[u'env_vars']} " if u"env_vars" in program else u""
+ program_cmd = f"{env_vars}{program_name} {program[u'args']}"
+ test_results = f"Test Results of '{program_cmd}':\n"
+
+ if nsim_attr[u"output_feature_enable"] or \
+ nsim_attr[u"cross_connect_feature_enable"]:
+ if nsim_attr[u"output_feature_enable"]:
+ feature_name = u"output"
+ else:
+ feature_name = u"cross-connect"
+ test_results += \
+ f"NSIM({feature_name}): delay " \
+ f"{nsim_attr[u'delay_in_usec']} usecs, " \
+ f"avg-pkt-size {nsim_attr[u'average_packet_size']}, " \
+ f"bandwidth {nsim_attr[u'bandwidth_in_bits_per_second']} " \
+ f"bits/sec, pkt-drop-rate {nsim_attr[u'packets_per_drop']} " \
+ f"pkts/drop\n"
+
+ if u"error" in program_stderr.lower():
+ test_results += f"ERROR DETECTED:\n{program_stderr}"
+ raise RuntimeError(test_results)
+ if program_stdout:
+ bad_test_results = False
+ if program == u"vpp_echo" and u"JSON stats" not in program_stdout:
+ test_results += u"Invalid test data output!\n"
+ bad_test_results = True
+ test_results += program_stdout
+ if bad_test_results:
+ raise RuntimeError(test_results)
+ else:
+ no_results = True
+ test_results += f"\nNo {program} test data retrieved!\n"
+ cmd = u"ls -l /tmp/*.log"
+ ls_stdout, _ = exec_cmd_no_error(node, cmd, sudo=True)
+ test_results += f"{ls_stdout}\n"
+
+ # TODO: Incorporate show error stats into results analysis
+ host = node[u"host"]
+ test_results += \
+ f"\n{role} VPP 'show errors' on host {host}:\n" \
+ f"{PapiSocketExecutor.run_cli_cmd(node, u'show error')}\n"
+
+ return no_results, test_results
+
+ @staticmethod
+ def no_hoststack_test_program_results(server_no_results, client_no_results):
+ """Return True if no HostStack test program output was gathered.
+
+ :param server_no_results: server no results value.
+ :param client_no_results: client no results value.
+ :type server_no_results: bool
+ :type client_no_results: bool
+ :rtype: bool
+ """
+ return server_no_results and client_no_results
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py
index c3df1fe376..1e0d90f065 100644
--- a/resources/libraries/python/IPUtil.py
+++ b/resources/libraries/python/IPUtil.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -12,7 +12,6 @@
# limitations under the License.
"""Common IP utilities library."""
-
import re
from enum import IntEnum
@@ -25,6 +24,7 @@ from resources.libraries.python.PapiExecutor import PapiSocketExecutor
from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd
from resources.libraries.python.topology import Topology
from resources.libraries.python.VatExecutor import VatTerminal
+from resources.libraries.python.Namespaces import Namespaces
# from vpp/src/vnet/vnet/mpls/mpls_types.h
@@ -243,31 +243,31 @@ class IPUtil:
raise AssertionError(f"IP addresses are not equal: {ip1} != {ip2}")
@staticmethod
- def setup_network_namespace(
- node, namespace_name, interface_name, ip_addr, prefix):
+ def setup_network_namespace(node, namespace_name, interface_name,
+ ip_addr_list, prefix_length):
"""Setup namespace on given node and attach interface and IP to
this namespace. Applicable also on TG node.
:param node: VPP node.
:param namespace_name: Namespace name.
:param interface_name: Interface name.
- :param ip_addr: IP address of namespace's interface.
- :param prefix: IP address prefix length.
+ :param ip_addr_list: List of IP addresses of namespace's interface.
+ :param prefix_length: IP address prefix length.
:type node: dict
:type namespace_name: str
:type interface_name: str
- :type ip_addr: str
- :type prefix: int
+ :type ip_addr_list: list
+ :type prefix_length: int
"""
- cmd = f"ip netns add {namespace_name}"
- exec_cmd_no_error(node, cmd, sudo=True)
+ Namespaces.create_namespace(node, namespace_name)
- cmd = f"ip link set dev {interface_name} up netns {namespace_name}"
+ cmd = f"ip netns exec {namespace_name} ip link set {interface_name} up"
exec_cmd_no_error(node, cmd, sudo=True)
- cmd = f"ip netns exec {namespace_name} ip addr add {ip_addr}/{prefix}" \
- f" dev {interface_name}"
- exec_cmd_no_error(node, cmd, sudo=True)
+ for ip_addr in ip_addr_list:
+ cmd = f"ip netns exec {namespace_name} ip addr add " \
+ f"{ip_addr}/{prefix_length} dev {interface_name}"
+ exec_cmd_no_error(node, cmd, sudo=True)
@staticmethod
def linux_enable_forwarding(node, ip_ver=u"ipv4"):
@@ -351,6 +351,64 @@ class IPUtil:
exec_cmd_no_error(node, cmd, timeout=5, sudo=True)
@staticmethod
+ def delete_linux_interface_ip(
+ node, interface, ip_addr, prefix_length, namespace=None):
+ """Delete IP address from interface in linux.
+
+ :param node: VPP/TG node.
+ :param interface: Interface in namespace.
+ :param ip_addr: IP to be deleted from interface.
+ :param prefix_length: IP prefix length.
+ :param namespace: Execute command in namespace. Optional
+ :type node: dict
+ :type interface: str
+ :type ip_addr: str
+ :type prefix_length: int
+ :type namespace: str
+ :raises RuntimeError: IP could not be deleted.
+ """
+ # TODO: Refactor command execution in namespaces into central
+ # methods (e.g. Namespace.exec_cmd_in_namespace)
+ if namespace is not None:
+ cmd = f"ip netns exec {namespace} ip addr del " \
+ f"{ip_addr}/{prefix_length} dev {interface}"
+ else:
+ cmd = f"ip addr del {ip_addr}/{prefix_length} dev {interface}"
+
+ exec_cmd_no_error(node, cmd, timeout=5, sudo=True)
+
+ @staticmethod
+ def linux_interface_has_ip(
+ node, interface, ip_addr, prefix_length, namespace=None):
+ """Return True if interface in linux has IP address.
+
+ :param node: VPP/TG node.
+ :param interface: Interface in namespace.
+ :param ip_addr: IP to be queried on interface.
+ :param prefix_length: IP prefix length.
+ :param namespace: Execute command in namespace. Optional
+ :type node: dict
+ :type interface: str
+ :type ip_addr: str
+ :type prefix_length: int
+ :type namespace: str
+ :rtype boolean
+ :raises RuntimeError: Request fails.
+ """
+ ip_addr_with_prefix = f"{ip_addr}/{prefix_length}"
+ if namespace is not None:
+ cmd = f"ip netns exec {namespace} ip addr show dev {interface}"
+ else:
+ cmd = f"ip addr show dev {interface}"
+
+ cmd += u" | grep 'inet ' | awk -e '{print $2}'"
+ cmd += f" | grep '{ip_addr_with_prefix}'"
+ _, stdout, _ = exec_cmd(node, cmd, timeout=5, sudo=True)
+
+ has_ip = stdout.rstrip()
+ return bool(has_ip == ip_addr_with_prefix)
+
+ @staticmethod
def add_linux_route(node, ip_addr, prefix, gateway, namespace=None):
"""Add linux route in namespace.
@@ -406,6 +464,24 @@ class IPUtil:
papi_exec.add(cmd, **args).get_reply(err_msg)
@staticmethod
+ def vpp_interface_set_ip_addresses(node, interface, ip_addr_list,
+ prefix_length=None):
+ """Set IP addresses to VPP interface.
+
+ :param node: VPP node.
+ :param interface: Interface name.
+ :param ip_addr_list: IP addresses.
+ :param prefix_length: Prefix length.
+ :type node: dict
+ :type interface: str
+ :type ip_addr_list: list
+ :type prefix_length: int
+ """
+ for ip_addr in ip_addr_list:
+ IPUtil.vpp_interface_set_ip_address(node, interface, ip_addr,
+ prefix_length)
+
+ @staticmethod
def vpp_add_ip_neighbor(node, iface_key, ip_addr, mac_address):
"""Add IP neighbor on DUT node.
diff --git a/resources/libraries/python/Namespaces.py b/resources/libraries/python/Namespaces.py
index 2618f3d19b..2bdcbcb324 100644
--- a/resources/libraries/python/Namespaces.py
+++ b/resources/libraries/python/Namespaces.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -18,21 +18,52 @@ from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd
class Namespaces:
"""Linux namespace utilities."""
- def __init__(self):
- self._namespaces = []
+ __namespaces = []
- def create_namespace(self, node, namespace_name):
+ @staticmethod
+ def create_namespace(node, namespace, delete_before_create=True):
"""Create namespace and add the name to the list for later clean-up.
:param node: Where to create namespace.
- :param namespace_name: Name for namespace.
+ :param namespace: Name for namespace.
+ :param delete_before_create: Delete namespace prior to create
:type node: dict
- :type namespace_name: str
+ :type namespace: str
+ :type delete_before_create: bool
"""
- cmd = f"ip netns add {namespace_name}"
+ if delete_before_create:
+ Namespaces.delete_namespace(node, namespace)
+ cmd = f"ip netns add {namespace}"
exec_cmd_no_error(node, cmd, sudo=True)
- self._namespaces.append(namespace_name)
+ Namespaces.__namespaces.append(namespace)
+
+ @staticmethod
+ def delete_namespace(node, namespace):
+ """Delete namespace from the node and list.
+
+ :param node: Where to delete namespace.
+ :param namespace: Name for namespace.
+ :param delete_before_create: Delete namespace prior to create
+ :type node: dict
+ :type namespace: str
+ :type delete_before_create: bool
+ """
+ cmd_timeout = 5
+ cmd = f"ip netns delete {namespace}"
+ (ret_code, _, delete_errmsg) = \
+ exec_cmd(node, cmd, timeout=cmd_timeout, sudo=True)
+ if ret_code != 0:
+ cmd = f"ip netns list {namespace}"
+ (stdout, _) = \
+ exec_cmd_no_error(node, cmd, timeout=cmd_timeout, sudo=True)
+ if stdout == namespace:
+ raise RuntimeError(f"Could not delete namespace "
+ f"({namespace}): {delete_errmsg}")
+ try:
+ Namespaces.__namespaces.remove(namespace)
+ except ValueError:
+ pass
@staticmethod
def attach_interface_to_namespace(node, namespace, interface):
@@ -61,6 +92,21 @@ class Namespaces:
)
@staticmethod
+ def add_default_route_to_namespace(node, namespace, default_route):
+ """Add IPv4 default route to interface in namespace.
+
+ :param node: Node where to execute command.
+ :param namespace: Namespace to execute command on.
+ :param default_route: Default route address.
+ :type node: dict
+ :type namespace: str
+ :type default_route: str
+ """
+ cmd = f"ip netns exec {namespace} ip route add default " \
+ f"via {default_route}"
+ exec_cmd_no_error(node, cmd, sudo=True)
+
+ @staticmethod
def create_bridge_for_int_in_namespace(
node, namespace, bridge_name, *interfaces):
"""Setup bridge domain and add interfaces to it.
@@ -85,16 +131,19 @@ class Namespaces:
cmd = f"ip netns exec {namespace} ip link set dev {bridge_name} up"
exec_cmd_no_error(node, cmd, sudo=True)
- def clean_up_namespaces(self, node):
- """Remove all old namespaces.
+ @staticmethod
+ def clean_up_namespaces(node, namespace=None):
+ """Delete all old namespaces.
:param node: Node where to execute command.
+ :param namespace: Namespace to delete, if None delete all namespaces
:type node: dict
+ :type namespace: str
:raises RuntimeError: Namespaces could not be cleaned properly.
"""
- for namespace in self._namespaces:
- print(f"Cleaning namespace {namespace}")
- cmd = f"ip netns delete {namespace}"
- ret_code, _, _ = exec_cmd(node, cmd, timeout=5, sudo=True)
- if ret_code != 0:
- raise RuntimeError(u"Could not delete namespace")
+ if namespace is not None:
+ Namespaces.delete_namespace(node, namespace)
+ return
+
+ for namespace_name in Namespaces.__namespaces:
+ Namespaces.delete_namespace(node, namespace_name)
diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py
index 865775f995..ca63fa6cea 100644
--- a/resources/libraries/python/VPPUtil.py
+++ b/resources/libraries/python/VPPUtil.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -113,8 +113,7 @@ class VPPUtil:
:param node: Topology node.
:type node: dict
"""
- cmd = u"command -v vpp"
- exec_cmd_no_error(node, cmd, message=u"VPP is not installed!")
+ DUTSetup.verify_program_installed(node, u"vpp")
@staticmethod
def adjust_privileges(node):
@@ -155,7 +154,7 @@ class VPPUtil:
:type node: dict
:raises RuntimeError: If VPP service fails to start.
"""
- VPPUtil.verify_vpp_installed(node)
+ DUTSetup.verify_program_installed(node, 'vpp')
try:
# Verify responsiveness of vppctl.
VPPUtil.verify_vpp_started(node)
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py
index 19b92a6a1a..1de32a2a21 100644
--- a/resources/libraries/python/VatExecutor.py
+++ b/resources/libraries/python/VatExecutor.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -62,7 +62,7 @@ def get_vpp_pid(node):
running on the DUT node.
:rtype: int or list
"""
- pid = PidLib.DUTSetup.get_vpp_pid(node)
+ pid = PidLib.DUTSetup.get_pid(node, u"vpp")
return pid
diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py
index 02f7cf725d..cd225db896 100644
--- a/resources/libraries/python/VppConfigGenerator.py
+++ b/resources/libraries/python/VppConfigGenerator.py
@@ -202,7 +202,7 @@ class VppConfigGenerator:
def add_socksvr(self, socket=Constants.SOCKSVR_PATH):
"""Add socksvr configuration."""
- path = ['socksvr', u"socket-name"]
+ path = [u"socksvr", u"socket-name"]
self.add_config_item(self._nodeconfig, socket, path)
def add_api_segment_gid(self, value=u"vpp"):
@@ -504,6 +504,16 @@ class VppConfigGenerator:
path = [u"tcp", u"preallocated-half-open-connections"]
self.add_config_item(self._nodeconfig, value, path)
+ def add_session_enable(self):
+ """Add session enable."""
+ path = [u"session", u"enable"]
+ self.add_config_item(self._nodeconfig, u"", path)
+
+ def add_session_event_queues_memfd_segment(self):
+ """Add session event queue memfd segment."""
+ path = [u"session", u"evt_qs_memfd_seg"]
+ self.add_config_item(self._nodeconfig, u"", path)
+
def add_session_event_queue_length(self, value):
"""Add session event queue length.
@@ -513,6 +523,15 @@ class VppConfigGenerator:
path = [u"session", u"event-queue-length"]
self.add_config_item(self._nodeconfig, value, path)
+ def add_session_event_queues_segment_size(self, value):
+ """Add session event queue length.
+
+ :param value: Session event queue segment size.
+ :type value: str
+ """
+ path = [u"session", u"evt_qs_seg_size"]
+ self.add_config_item(self._nodeconfig, value, path)
+
def add_session_preallocated_sessions(self, value):
"""Add the number of pre-allocated sessions.
diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py
index b2d106d3ed..7dec51619c 100644
--- a/resources/libraries/python/topology.py
+++ b/resources/libraries/python/topology.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -22,6 +22,8 @@ from yaml import safe_load
from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
+from resources.libraries.python.Constants import Constants
+
__all__ = [
u"DICT__nodes", u"Topology", u"NodeType", u"SocketType", u"NodeSubTypeTG"
]
@@ -705,6 +707,22 @@ class Topology:
return None
@staticmethod
+ def get_interface_ip4_prefix_length(node, iface_key):
+ """Get IP4 address prefix length for the interface.
+
+ :param node: Node to get prefix length on.
+ :param iface_key: Interface key from topology file.
+ :type node: dict
+ :type iface_key: str
+ :returns: Prefix length from topology file or the default
+ IP4 prefix length if not found.
+ :rtype: int
+ :raises: KeyError if iface_key is not found.
+ """
+ return node[u"interfaces"][iface_key].get(u"ip4_prefix_length", \
+ Constants.DEFAULT_IP4_PREFIX_LENGTH)
+
+ @staticmethod
def get_adjacent_node_and_interface(nodes_info, node, iface_key):
"""Get node and interface adjacent to specified interface
on local network.
diff --git a/resources/libraries/robot/hoststack/hoststack.robot b/resources/libraries/robot/hoststack/hoststack.robot
new file mode 100644
index 0000000000..d0fd9a2a95
--- /dev/null
+++ b/resources/libraries/robot/hoststack/hoststack.robot
@@ -0,0 +1,372 @@
+# Copyright (c) 2020 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+| Library | resources.libraries.python.InterfaceUtil
+| Library | resources.libraries.python.IPUtil
+| Library | resources.libraries.python.HoststackUtil
+| Library | resources.libraries.python.NsimUtil
+| Variables | resources/libraries/python/Constants.py
+| Resource | resources/libraries/robot/ip/ip4.robot
+| Resource | resources/libraries/robot/nsim/nsim.robot
+|
+| Documentation | L2 keywords to set up VPP to test hoststack.
+
+*** Variables ***
+| ${quic_crypto_engine}= | nocrypto
+| ${quic_fifo_size}= | 4M
+| &{vpp_hoststack_attr}=
+| ... | rxq=${None}
+| ... | phy_cores=${1}
+| ... | vpp_api_socket=${SOCKSVR_PATH}
+| ... | api_seg_global_size=2G
+| ... | api_seg_api_size=1G
+| ... | sess_evt_q_seg_size=4G
+| ... | sess_evt_q_length=4000000
+| ... | sess_prealloc_sess=4000000
+| ... | sess_v4_sess_tbl_buckets=2000000
+| ... | sess_v4_sess_tbl_mem=2G
+| ... | sess_v4_sess_halfopen_buckets=5000000
+| ... | sess_v4_sess_halfopen_mem=3G
+| ... | sess_lcl_endpt_tbl_buckets=5000000
+| ... | sess_lcl_endpt_tbl_mem=3G
+| &{vpp_echo_server_attr}=
+| ... | role=server
+| ... | cfg_vpp_feature=${None}
+| ... | namespace=default
+| ... | vpp_api_socket=${vpp_hoststack_attr}[vpp_api_socket]
+| ... | json_output=json
+| ... | uri_protocol=quic
+| ... | uri_ip4_addr=${EMPTY}
+| ... | uri_port=1234
+| ... | nclients=1
+| ... | quic_streams=1
+| ... | time=sconnect:lastbyte
+| ... | fifo_size=4M
+| ... | rx_bytes=0
+| ... | tx_bytes=0
+| ... | rx_results_diff=${False}
+| ... | tx_results_diff=${False}
+| &{vpp_echo_client_attr}=
+| ... | role=client
+| ... | cfg_vpp_feature=${None}
+| ... | namespace=default
+| ... | vpp_api_socket=${vpp_hoststack_attr}[vpp_api_socket]
+| ... | json_output=json
+| ... | uri_protocol=quic
+| ... | uri_ip4_addr=${EMPTY}
+| ... | uri_port=1234
+| ... | nclients=1
+| ... | quic_streams=1
+| ... | time=sconnect:lastbyte
+| ... | fifo_size=4M
+| ... | rx_bytes=0
+| ... | tx_bytes=0
+| ... | rx_results_diff=${False}
+| ... | tx_results_diff=${False}
+
+*** Keywords ***
+| Set VPP Hoststack Attributes
+| | [Documentation]
+| | ... | Set the VPP HostStack attributes in the vpp_hoststack_attr dictionary.
+| |
+| | ... | *Arguments:*
+| | ... | - ${rxq} - Type: int
+| | ... | - ${phy_cores} - Number of cores for workers Type: int
+| | ... | - ${vpp_api_socket} - Path to VPP api socket file Type: string
+| | ... | - ${api_seg_global_size} - Global API segment size Type: string
+| | ... | - ${api_seg_api_size} - API segment API fifo size Type: string
+| | ... | - ${sess_evt_q_seg_size} - Session event queue segment size
+| | ... | Type: string
+| | ... | - ${sess_evt_q_length} - Session event queue length Type: string
+| | ... | - ${sess_prealloc_sess} - Number of sessions to preallocate
+| | ... | Type: string
+| | ... | - ${sess_v4_sess_tbl_buckets} - Number of IPv4 session table buckets
+| | ... | Type: string
+| | ... | - ${sess_v4_sess_tbl_mem} - IPv4 session table memory size
+| | ... | Type: string
+| | ... | - ${sess_v4_sess_halfopen_buckets} - Number of IPv4 session
+| | ... | half open table buckets Type: string
+| | ... | - ${sess_v4_sess_halfopen_mem} - IPv4 session half open
+| | ... | table memory size Type: string
+| | ... | - ${sess_lcl_endpt_tbl_buckets} - Number of session local endpoint
+| | ... | table buckets Type: string
+| | ... | - ${sess_lcl_endpt_tbl_mem} - Session local endpoint
+| | ... | table memory size Type: string
+| |
+| | ... | *Example:*
+| |
+| | ... | \| Set VPP Hoststack Attributes \| phy_cores=${phy_cores} \|
+| |
+| | [Arguments]
+| | ... | ${rxq}=${vpp_hoststack_attr}[rxq]
+| | ... | ${phy_cores}=${vpp_hoststack_attr}[phy_cores]
+| | ... | ${vpp_api_socket}=${vpp_hoststack_attr}[vpp_api_socket]
+| | ... | ${api_seg_global_size}=${vpp_hoststack_attr}[api_seg_global_size]
+| | ... | ${api_seg_api_size}=${vpp_hoststack_attr}[api_seg_api_size]
+| | ... | ${sess_evt_q_seg_size}=${vpp_hoststack_attr}[sess_evt_q_seg_size]
+| | ... | ${sess_evt_q_length}=${vpp_hoststack_attr}[sess_evt_q_length]
+| | ... | ${sess_prealloc_sess}=${vpp_hoststack_attr}[sess_prealloc_sess]
+| | ... | ${sess_v4_sess_tbl_buckets}=${vpp_hoststack_attr}[sess_v4_sess_tbl_buckets]
+| | ... | ${sess_v4_sess_tbl_mem}=${vpp_hoststack_attr}[sess_v4_sess_tbl_mem]
+| | ... | ${sess_v4_sess_halfopen_buckets}=${vpp_hoststack_attr}[sess_v4_sess_halfopen_buckets]
+| | ... | ${sess_v4_sess_halfopen_mem}=${vpp_hoststack_attr}[sess_v4_sess_halfopen_mem]
+| | ... | ${sess_lcl_endpt_tbl_buckets}=${vpp_hoststack_attr}[sess_lcl_endpt_tbl_buckets]
+| | ... | ${sess_lcl_endpt_tbl_mem}=${vpp_hoststack_attr}[sess_lcl_endpt_tbl_mem]
+| |
+| | Set To Dictionary | ${vpp_hoststack_attr} | rxq | ${rxq}
+| | Set To Dictionary | ${vpp_hoststack_attr} | phy_cores | ${phy_cores}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | vpp_api_socket | ${vpp_api_socket}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | api_seg_global_size | ${api_seg_global_size}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | api_seg_api_size | ${api_seg_api_size}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_evt_q_seg_size | ${sess_evt_q_seg_size}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_evt_q_length | ${sess_evt_q_length}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_prealloc_sess | ${sess_prealloc_sess}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_v4_sess_tbl_buckets | ${sess_v4_sess_tbl_buckets}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_v4_sess_tbl_mem | ${sess_v4_sess_tbl_mem}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_v4_sess_halfopen_buckets | ${sess_v4_sess_halfopen_buckets}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_v4_sess_halfopen_mem | ${sess_v4_sess_halfopen_mem}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_lcl_endpt_tbl_buckets | ${sess_lcl_endpt_tbl_buckets}
+| | Set To Dictionary | ${vpp_hoststack_attr}
+| | ... | sess_lcl_endpt_tbl_mem | ${sess_lcl_endpt_tbl_mem}
+
+| Set VPP Echo Server Attributes
+| | [Documentation]
+| | ... | Set the HostStack vpp_echo test program attributes
+| | ... | in the vpp_echo_server_attr dictionary.
+| |
+| | ... | *Arguments:*
+| | ... | - ${cfg_vpp_feature} - VPP Feature requiring config Type: string
+| | ... | - ${namespace} - Namespace Type: string
+| | ... | - ${nclients} - Number of clients Type: string
+| | ... | - ${quic_streams} - Number of quic streams Type: string
+| | ... | - ${fifo_size} - Session Fifo Size Type: integer
+| | ... | - ${time} - Timing events (start:end) Type: string
+| | ... | - ${rx_bytes} - Number of Bytes to receive Type: string
+| | ... | - ${tx_bytes} - Number of Bytes to send Type: string
+| | ... | - ${rx_results_diff} - Rx Results are different to pass Type: boolean
+| | ... | - ${tx_results_diff} - Tx Results are different to pass Type: boolean
+| |
+| | ... | *Example:*
+| |
+| | ... | \| Set VPP Echo Server Attributes \| nclients=${nclients} \|
+| | ... | \| tx_bytes=${tx_bytes} \|
+| |
+| | [Arguments]
+| | ... | ${cfg_vpp_feature}=${vpp_echo_server_attr}[cfg_vpp_feature]
+| | ... | ${namespace}=${vpp_echo_server_attr}[namespace]
+| | ... | ${nclients}=${vpp_echo_server_attr}[nclients]
+| | ... | ${quic_streams}=${vpp_echo_server_attr}[quic_streams]
+| | ... | ${time}=${vpp_echo_server_attr}[time]
+| | ... | ${fifo_size}=${vpp_echo_server_attr}[fifo_size]
+| | ... | ${rx_bytes}=${vpp_echo_server_attr}[rx_bytes]
+| | ... | ${tx_bytes}=${vpp_echo_server_attr}[tx_bytes]
+| | ... | ${rx_results_diff}=${vpp_echo_server_attr}[rx_results_diff]
+| | ... | ${tx_results_diff}=${vpp_echo_server_attr}[tx_results_diff]
+| |
+| | Set To Dictionary | ${vpp_echo_server_attr} | cfg_vpp_feature
+| | ... | ${cfg_vpp_feature}
+| | Set To Dictionary | ${vpp_echo_server_attr} | namespace | ${namespace}
+| | Set To Dictionary | ${vpp_echo_server_attr} | nclients | ${nclients}
+| | Set To Dictionary | ${vpp_echo_server_attr} | quic_streams | ${quic_streams}
+| | Set To Dictionary | ${vpp_echo_server_attr} | time | ${time}
+| | Set To Dictionary | ${vpp_echo_server_attr} | fifo_size | ${fifo_size}
+| | Set To Dictionary | ${vpp_echo_server_attr} | rx_bytes | ${rx_bytes}
+| | Set To Dictionary | ${vpp_echo_server_attr} | tx_bytes | ${tx_bytes}
+| | Set To Dictionary
+| | ... | ${vpp_echo_server_attr} | rx_results_diff | ${rx_results_diff}
+| | Set To Dictionary
+| | ... | ${vpp_echo_server_attr} | tx_results_diff | ${tx_results_diff}
+
+| Set VPP Echo Client Attributes
+| | [Documentation]
+| | ... | Set the HostStack vpp_echo test program attributes
+| | ... | in the vpp_echo_client_attr dictionary.
+| |
+| | ... | *Arguments:*
+| | ... | - ${cfg_vpp_feature} - VPP Feature requiring config Type: string
+| | ... | - ${namespace} - Namespace Type: string
+| | ... | - ${nclients} - Number of clients Type: string
+| | ... | - ${fifo_size} - Session Fifo Size Type: integer
+| | ... | - ${time} - Timing events (start:end) Type: string
+| | ... | - ${rx_bytes} - Number of Bytes to receive Type: string
+| | ... | - ${tx_bytes} - Number of Bytes to send Type: string
+| | ... | - ${rx_results_diff} - Rx Results are different to pass Type: boolean
+| | ... | - ${tx_results_diff} - Tx Results are different to pass Type: boolean
+| |
+| | ... | *Example:*
+| |
+| | ... | \| Set VPP Echo Client Attributes \| nclients=${nclients} \|
+| | ... | \| tx_bytes=${tx_bytes} \|
+| |
+| | [Arguments]
+| | ... | ${cfg_vpp_feature}=${vpp_echo_client_attr}[cfg_vpp_feature]
+| | ... | ${namespace}=${vpp_echo_client_attr}[namespace]
+| | ... | ${nclients}=${vpp_echo_client_attr}[nclients]
+| | ... | ${quic_streams}=${vpp_echo_server_attr}[quic_streams]
+| | ... | ${time}=${vpp_echo_client_attr}[time]
+| | ... | ${fifo_size}=${vpp_echo_client_attr}[fifo_size]
+| | ... | ${rx_bytes}=${vpp_echo_client_attr}[rx_bytes]
+| | ... | ${tx_bytes}=${vpp_echo_client_attr}[tx_bytes]
+| | ... | ${rx_results_diff}=${vpp_echo_client_attr}[rx_results_diff]
+| | ... | ${tx_results_diff}=${vpp_echo_client_attr}[tx_results_diff]
+| |
+| | Set To Dictionary | ${vpp_echo_client_attr} | cfg_vpp_feature
+| | ... | ${cfg_vpp_feature}
+| | Set To Dictionary | ${vpp_echo_client_attr} | namespace | ${namespace}
+| | Set To Dictionary | ${vpp_echo_client_attr} | nclients | ${nclients}
+| | Set To Dictionary | ${vpp_echo_client_attr} | quic_streams | ${quic_streams}
+| | Set To Dictionary | ${vpp_echo_client_attr} | time | ${time}
+| | Set To Dictionary | ${vpp_echo_client_attr} | fifo_size | ${fifo_size}
+| | Set To Dictionary | ${vpp_echo_client_attr} | rx_bytes | ${rx_bytes}
+| | Set To Dictionary | ${vpp_echo_client_attr} | tx_bytes | ${tx_bytes}
+| | Set To Dictionary
+| | ... | ${vpp_echo_client_attr} | rx_results_diff | ${rx_results_diff}
+| | Set To Dictionary
+| | ... | ${vpp_echo_client_attr} | tx_results_diff | ${tx_results_diff}
+
+| Run hoststack test program on DUT
+| | [Documentation]
+| | ... | Configure IP address on the port, set it up and start the specified
+| | ... | HostStack test program on the specified DUT.
+| |
+| | ... | *Arguments:*
+| | ... | - ${node} - VPP DUT node Type: Node
+| | ... | - ${intf} - VPP DUT node interface key Type: string
+| | ... | - ${ip4_addr} - VPP DUT node interface ip4 address Type: string
+| | ... | - ${ip4_mask} - VPP DUT node interface ip4 network mask Type: string
+| | ... | - ${namespace} - Network namespace to run test program in Type: string
+| | ... | - ${cfg_vpp_feature} - VPP hoststack feature requiring
+| | ... | additional VPP configuration Type: string
+| | ... | - ${test_program} - Host Stack test program Type: dict
+| |
+| | ... | *Example:*
+| |
+| | ... | \| Run hoststack test program on DUT \| ${dut1} \| ${dut1_if1} \|
+| | ... | \| ${dut1_if1_ip4_addr} \| ${dut1_if1_ip4_mask} \| default \|
+| | ... | \| quic \| ${vpp_echo_server} \|
+| |
+| | [Arguments] | ${node} | ${intf} | ${ip4_addr} | ${ip4_mask}
+| | | ... | ${namespace} | ${cfg_vpp_feature} | ${test_program}
+| |
+| | Run Keyword If | ${vpp_nsim_attr}[output_feature_enable]
+| | ... | Configure VPP NSIM | ${node} | ${vpp_nsim_attr} | ${intf}
+| | Run Keyword If | '${cfg_vpp_feature}' != ''
+| | ... | Additional VPP Config for Feature ${cfg_vpp_feature} | ${node}
+| | VPP Get Interface Data | ${node}
+| | Set Interface State | ${node} | ${intf} | up
+| | VPP Interface Set IP Address | ${node} | ${intf} | ${ip4_addr}
+| | ... | ${ip4_mask}
+| | Vpp Node Interfaces Ready Wait | ${node}
+| | ${hoststack_test_program_pid}= | Start Hoststack Test Program
+| | ... | ${node} | ${namespace} | ${test_program}
+| | Return From Keyword | ${hoststack_test_program_pid}
+
+| Additional VPP Config For Feature quic
+| | [Documentation]
+| | ... | Configure VPP quic attributes on the specified DUT.
+| |
+| | ... | *Arguments:*
+| | ... | - ${node} - VPP DUT node Type: Node
+| |
+| | [Arguments] | ${node}
+| |
+| | Set hoststack quic fifo size | ${node} | ${quic_fifo_size}
+| | Set hoststack quic crypto engine | ${node} | ${quic_crypto_engine}
+
+| Configure VPP hoststack attributes on all DUTs
+| | [Documentation]
+| | ... | Configure VPP HostStack attributes on all DUTs.
+| |
+| | Add worker threads to all DUTs
+| | ... | ${vpp_hoststack_attr}[phy_cores] | ${vpp_hoststack_attr}[rxq]
+| | Add DPDK PCI devices to all DUTs
+| | ${duts}= | Get Matches | ${nodes} | DUT*
+| | FOR | ${dut} | IN | @{duts}
+| | | Import Library | resources.libraries.python.VppConfigGenerator
+| | | ... | WITH NAME | ${dut}
+| | | Run keyword | ${dut}.Add socksvr | ${vpp_hoststack_attr}[vpp_api_socket]
+| | | Run keyword | ${dut}.Add api segment global size
+| | | ... | ${vpp_hoststack_attr}[api_seg_global_size]
+| | | Run keyword | ${dut}.Add api segment api size
+| | | ... | ${vpp_hoststack_attr}[api_seg_api_size]
+| | | Run keyword | ${dut}.Add api segment gid | testuser
+| | | Run keyword | ${dut}.Add session enable
+| | | Run keyword | ${dut}.Add session event queues memfd segment
+| | | Run keyword | ${dut}.Add session event queues segment size
+| | | ... | ${vpp_hoststack_attr}[sess_evt_q_seg_size]
+| | | Run keyword | ${dut}.Add session event queue length
+| | | ... | ${vpp_hoststack_attr}[sess_evt_q_length]
+| | | Run keyword | ${dut}.Add session preallocated sessions
+| | | ... | ${vpp_hoststack_attr}[sess_prealloc_sess]
+| | | Run keyword | ${dut}.Add session v4 session table buckets
+| | | ... | ${vpp_hoststack_attr}[sess_v4_sess_tbl_buckets]
+| | | Run keyword | ${dut}.Add session v4 session table memory
+| | | ... | ${vpp_hoststack_attr}[sess_v4_sess_tbl_mem]
+| | | Run keyword | ${dut}.Add session v4 halfopen table buckets
+| | | ... | ${vpp_hoststack_attr}[sess_v4_sess_halfopen_buckets]
+| | | Run keyword | ${dut}.Add session v4 halfopen table memory
+| | | ... | ${vpp_hoststack_attr}[sess_v4_sess_halfopen_mem]
+| | | Run keyword | ${dut}.Add session local endpoints table buckets
+| | | ... | ${vpp_hoststack_attr}[sess_lcl_endpt_tbl_buckets]
+| | | Run keyword | ${dut}.Add session local endpoints table memory
+| | | ... | ${vpp_hoststack_attr}[sess_lcl_endpt_tbl_mem]
+| | END
+| | Apply startup configuration on all VPP DUTs
+
+| Get Test Results From Hoststack VPP Echo Test
+| | [Documentation]
+| | ... | Configure IP address on the port, set it up and start the specified
+| | ... | HostStack test programs on the DUTs. Gather test program
+| | ... | output and append test results in message.
+| | ... | Return boolean indicating when no results were available from
+| | ... | both the server and client test programs.
+| |
+| | Set To Dictionary | ${vpp_echo_server_attr} | uri_ip4_addr
+| | ... | ${dut2_if1_ip4_addr}
+| | Set To Dictionary | ${vpp_echo_client_attr} | uri_ip4_addr
+| | ... | ${dut2_if1_ip4_addr}
+| | Configure VPP Hoststack Attributes on all DUTs
+| | ${vpp_echo_server}= | Get VPP Echo Command | ${vpp_echo_server_attr}
+| | ${server_pid}= | Run hoststack test program on DUT
+| | ... | ${dut2} | ${dut2_if1} | ${dut2_if1_ip4_addr} | ${dut2_if1_ip4_prefix}
+| | ... | ${vpp_echo_server_attr}[namespace]
+| | ... | ${vpp_echo_server_attr}[cfg_vpp_feature] | ${vpp_echo_server}
+| | ${vpp_echo_client}= | Get VPP Echo Command | ${vpp_echo_client_attr}
+| | ${client_pid}= | Run hoststack test program on DUT
+| | ... | ${dut1} | ${dut1_if1} | ${dut1_if1_ip4_addr} | ${dut1_if1_ip4_prefix}
+| | ... | ${vpp_echo_client_attr}[namespace]
+| | ... | ${vpp_echo_client_attr}[cfg_vpp_feature] | ${vpp_echo_client}
+| | When Hoststack Test Program Finished | ${dut1} | ${client_pid}
+| | ${client_no_results} | ${client_output}=
+| | ... | Analyze hoststack test program output | ${dut1} | Client
+| | ... | ${vpp_nsim_attr} | ${vpp_echo_client}
+| | Then Set test message | ${client_output}
+| | And Hoststack Test Program Finished | ${dut2} | ${server_pid}
+| | ${server_no_results} | ${server_output}=
+| | ... | Analyze hoststack test program output | ${dut2} | Server
+| | ... | ${vpp_nsim_attr} | ${vpp_echo_server}
+| | Set test message | ${server_output} | append=True
+| | Run Keyword And Return | No Hoststack Test Program Results
+| | ... | ${server_no_results} | ${client_no_results}
diff --git a/resources/libraries/robot/tcp/tcp_setup.robot b/resources/libraries/robot/hoststack/tcp_setup.robot
index 718070979f..718070979f 100644
--- a/resources/libraries/robot/tcp/tcp_setup.robot
+++ b/resources/libraries/robot/hoststack/tcp_setup.robot
diff --git a/resources/libraries/robot/shared/default.robot b/resources/libraries/robot/shared/default.robot
index 3b8f2804c1..160ebc887b 100644
--- a/resources/libraries/robot/shared/default.robot
+++ b/resources/libraries/robot/shared/default.robot
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -113,6 +113,31 @@
| | Verify Kernel Module on All DUTs | ${nodes} | ${module}
| | ... | force_load=${force_load}
+| Get Keyname for DUT
+| | [Documentation]
+| | ... | Get the Keyname for the DUT in the keyname list.
+| | ... | Returns lowercase keyname value.
+| |
+| | ... | *Arguments:*
+| | ... | - dutx - DUT to find keyname. Type: dict
+| | ... | - dut_keys - DUT Keynames to search. Type: list
+| |
+| | ... | *Example:*
+| |
+| | ... | \| Get Keyname for DUT \| ${dutx} \| ${duts} \|
+| |
+| | [Arguments] | ${dutx} | ${dut_keys}
+| |
+| | FOR | ${key} | IN | @{dut_keys}
+| | | ${found_key} | ${value}= | Run Keyword and Ignore Error
+| | | ... | Dictionaries Should Be Equal | ${nodes['${key}']} | ${dutx}
+| | | Run Keyword If | '${found_key}' == 'PASS' | EXIT FOR LOOP
+| | END
+| | Run Keyword If | '${found_key}' != 'PASS'
+| | ... | Fail | Keyname for ${dutx} not found
+| | ${keyname}= | Convert To Lowercase | ${key}
+| | Return From Keyword | ${keyname}
+
| Create base startup configuration of VPP on all DUTs
| | [Documentation] | Create base startup configuration of VPP to all DUTs.
| |
diff --git a/resources/libraries/robot/shared/suite_setup.robot b/resources/libraries/robot/shared/suite_setup.robot
index 513cfe8045..0a78226962 100644
--- a/resources/libraries/robot/shared/suite_setup.robot
+++ b/resources/libraries/robot/shared/suite_setup.robot
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -20,6 +20,8 @@
| Library | resources.libraries.python.topology.Topology
| Library | resources.libraries.python.TrafficGenerator
| Library | resources.tools.wrk.wrk
+| Variables | resources/libraries/python/Constants.py
+| Resource | resources/libraries/robot/wrk/wrk_utils.robot
|
| Documentation | Suite setup keywords.
@@ -87,6 +89,64 @@
| | | Run Keyword | Additional Suite setup Action For ${action}
| | END
+| Setup suite single link no tg
+| | [Documentation]
+| | ... | Common suite setup for single link tests.
+| | ... |
+| | ... | Compute path for testing on two given nodes in circular topology
+| | ... | based on interface model provided as an argument and set
+| | ... | corresponding suite variables.
+| |
+| | ... | _NOTE:_ This KW sets following suite variables:
+| | ... | - duts - List of DUT nodes
+| | ... | - duts_count - Number of DUT nodes.
+| | ... | - dut{n} - DUTx node
+| | ... | - dut{n}_if1 - 1st DUT interface.
+| | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
+| | ... | - dut{n}_if2 - 2nd DUT interface.
+| | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
+| |
+| | ... | *Arguments:*
+| | ... | - ${actions} - Additional setup action. Type: list
+| |
+| | [Arguments] | @{actions}
+| |
+| | ${nic_model_list}= | Create list | ${nic_name}
+| | ${duts}= | Get Matches | ${nodes} | DUT*
+| | FOR | ${dut} | IN | @{duts}
+| | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
+| | END
+| | Append Node | ${nodes['@{duts}[0]']} | filter_list=${nic_model_list}
+| | Compute Path | always_same_link=${FALSE}
+| | FOR | ${i} | IN RANGE | 1 | ${DATAPATH_INTERFACES_MAX}
+| | | ${dutx_if} | ${dutx}= | Next Interface
+| | | Run Keyword If | '${dutx_if}' == 'None' | EXIT FOR LOOP
+| | | ${dutx_if_mac}= | Get Interface MAC | ${dutx} | ${dutx_if}
+| | | ${dutx_if_ip4_addr}= | Get Interface Ip4 | ${dutx} | ${dutx_if}
+| | | ${dutx_if_ip4_prefix_length}= | Get Interface Ip4 Prefix Length
+| | | ... | ${dutx} | ${dutx_if}
+| | | ${dut_str}= | Get Keyname For DUT | ${dutx} | ${duts}
+| | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
+| | | ... | Variable Should Exist | ${${dut_str}_if1}
+| | | ${if_name}= | Set Variable If | '${if1_status}' == 'PASS'
+| | | ... | if2 | if1
+| | | Set Suite Variable | ${${dut_str}} | ${dutx}
+| | | Set Suite Variable | ${${dut_str}_${if_name}} | ${dutx_if}
+| | | Set Suite Variable | ${${dut_str}_${if_name}_mac} | ${dutx_if_mac}
+| | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_addr}
+| | | ... | ${dutx_if_ip4_addr}
+| | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_prefix}
+| | | ... | ${dutx_if_ip4_prefix_length}
+| | END
+| | Run Keyword If | ${i}>${DATAPATH_INTERFACES_MAX}
+| | ... | Fatal Error | Datapath length exceeded
+| | ${duts_count}= | Get Length | ${duts}
+| | Set Suite Variable | ${duts}
+| | Set Suite Variable | ${duts_count}
+| | FOR | ${action} | IN | @{actions}
+| | | Run Keyword | Additional Suite setup Action For ${action}
+| | END
+
| Setup suite double link
| | [Documentation]
| | ... | Common suite setup for double link tests.
@@ -241,6 +301,7 @@
| | [Documentation]
| | ... | Additional Setup for suites which uses WRK TG.
| |
+| | Verify Program Installed | ${tg} | wrk
| | Iface update numa node | ${tg}
# Make sure TRex is stopped
| | ${running}= | Is TRex running | ${tg}
@@ -257,13 +318,11 @@
# Set IP on tg_if1
| | ${intf_name}= | Get Linux interface name | ${tg}
| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.10.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.20.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.30.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.40.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.50.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.60.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.70.1 | 24
-| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.80.1 | 24
+| | FOR | ${ip_addr} | IN | @{wrk_ip_addrs}
+| | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
+| | | ... | ${ip_addr} | ${wrk_ip_prefix}
+| | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
+| | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${wrk_ip_prefix}
+| | END
| | Set Linux interface up | ${tg} | ${intf_name}
| | Check wrk | ${tg}
diff --git a/resources/libraries/robot/shared/suite_teardown.robot b/resources/libraries/robot/shared/suite_teardown.robot
index 993d83838f..881f796284 100644
--- a/resources/libraries/robot/shared/suite_teardown.robot
+++ b/resources/libraries/robot/shared/suite_teardown.robot
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -48,3 +48,20 @@
| | | Cleanup DPDK Environment
| | | ... | ${nodes['${dut}']} | ${${dut}_if1} | ${${dut}_if2}
| | END
+
+| Additional Suite Tear Down Action For wrk
+| | [Documentation]
+| | ... | Additional teardown for suites which uses wrk.
+| |
+| | ${intf_name}= | Get Linux interface name | ${tg}
+| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
+| | FOR | ${ip_addr} | IN | @{wrk_ip_addrs}
+| | | ${ip_addr_on_intf}= | Linux Interface Has IP | ${tg} | ${intf_name}
+| | | ... | ${ip_addr} | ${wrk_ip_prefix}
+| | | Run Keyword If | ${ip_addr_on_intf}==${True} | Delete Linux Interface IP
+| | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${wrk_ip_prefix}
+| | END
+| | Run Keyword And Ignore Error | PCI Driver Unbind
+| | ... | ${tg} | ${tg['interfaces']['${tg_if1}']['pci_address']}
+| | Run Keyword And Ignore Error | PCI Driver Unbind
+| | ... | ${tg} | ${tg['interfaces']['${tg_if2}']['pci_address']}
diff --git a/resources/libraries/robot/wrk/wrk_utils.robot b/resources/libraries/robot/wrk/wrk_utils.robot
index 1f6261af5a..2a24bce9f3 100644
--- a/resources/libraries/robot/wrk/wrk_utils.robot
+++ b/resources/libraries/robot/wrk/wrk_utils.robot
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2020 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -12,15 +12,21 @@
# limitations under the License.
*** Settings ***
-| Library | resources.tools.wrk.wrk
-| Library | resources.libraries.python.IPUtil
-| Library | resources.libraries.python.DUTSetup
-| Library | resources.libraries.python.TrafficGenerator
-| Library | resources.libraries.python.topology.Topology
+| Library | resources.tools.wrk.wrk
+| Library | resources.libraries.python.IPUtil
+| Library | resources.libraries.python.DUTSetup
+| Library | resources.libraries.python.TrafficGenerator
+| Library | resources.libraries.python.topology.Topology
|
| Documentation | L2 keywords to set up wrk and to measure performance
| ... | parameters using wrk.
+*** Variables ***
+| ${wrk_ip_prefix}= | 24
+| @{wrk_ip_addrs}= | 192.168.10.1 | 192.168.20.1 | 192.168.30.1
+| ... | 192.168.40.1 | 192.168.50.1 | 192.168.60.1 | 192.168.70.1
+| ... | 192.168.80.1
+
*** Keywords ***
| Measure throughput
| | [Documentation]