2. Python Library

2.11. Classify suite

2.12. Constants suite

Constants used in CSIT.

class resources.libraries.python.Constants.Constants

Bases: object

Constants used in CSIT.

TODO: Yaml files are easier for humans to edit. Figure out how to set the attributes by parsing a file that works regardless of current working directory.

CORE_DUMP_DIR = '/tmp'
CPU_CNT_MAIN = 1
CPU_CNT_SYSTEM = 1
KERNEL_CORE_PATTERN = '/tmp/%p-%u-%g-%s-%t-%h-%e.core'
NIC_NAME_TO_CODE = {'Intel-XXV710': '25ge2p1xxv710', 'Intel-X520-DA2': '10ge2p1x520', 'Intel-XL710': '40ge2p1xl710', 'Cisco-VIC-1385': '40ge2p1vic1385', 'Cisco-VIC-1227': '10ge2p1vic1227', 'Intel-X710': '10ge2p1x710', 'Intel-X553': '10ge2p1x553'}
NIC_NAME_TO_CRYPTO_HW = {'Intel-XL710': 'HW_DH895xcc', 'Intel-X553': 'HW_C3xxx', 'Intel-X710': 'HW_DH895xcc'}
NIC_NAME_TO_LIMIT = {'Intel-XXV710': 24500000000, 'Intel-X520-DA2': 10000000000, 'Intel-XL710': 24500000000, 'Cisco-VIC-1385': 24500000000, 'Cisco-VIC-1227': 10000000000, 'Intel-X710': 10000000000, 'Intel-X553': 10000000000}
ODL_PORT = 8181
PERF_TYPE_TO_KEYWORD = {'ndrpdr': 'Find NDR and PDR intervals using optimized search', 'soak': 'Find critical load using PLRsearch', 'mrr': 'Traffic should pass with maximum rate'}
PERF_TYPE_TO_SUITE_DOC_VER = {'ndrpdr': 'fication:* TG finds and reports throughput NDR (Non Drop\\\n| ... | Rate) with zero packet loss tolerance and throughput PDR (Partial Drop\\\n| ... | Rate) with non-zero packet loss tolerance (LT) expressed in percentage\\\n| ... | of packets transmitted. NDR and PDR are discovered for different\\\n| ... | Ethernet L2 frame sizes using MLRsearch library.\\', 'soak': 'fication:* TG sends traffic at dynamically computed\\\n| ... | rate as PLRsearch algorithm gathers data and improves its estimate\\\n| ... | of a rate at which a prescribed small fraction of packets\\\n| ... | would be lost. After set time, the serarch stops\\\n| ... | and the algorithm reports its current estimate.\\', 'mrr': 'fication:* In MaxReceivedRate tests TG sends traffic\\\n| ... | at line rate and reports total received packets over trial period.\\'}
PERF_TYPE_TO_TEMPLATE_DOC_VER = {'ndrpdr': 'Measure NDR and PDR values using MLRsearch algorithm.\\', 'soak': 'Estimate critical rate using PLRsearch algorithm.\\', 'mrr': 'Measure MaxReceivedRate for ${frame_size}B frames\\\n| | ... | using burst trials throughput test.\\'}
QEMU_BIN_PATH = '/usr/bin'
QEMU_VM_DPDK = '/opt/dpdk-19.02'
QEMU_VM_IMAGE = '/var/lib/vm/vhost-nested.img'
QEMU_VM_KERNEL = '/opt/boot/vmlinuz'
REMOTE_FW_DIR = '/tmp/openvpp-testing'
REMOTE_HC_DIR = '/opt/honeycomb'
REMOTE_HC_LOG = '/var/log/honeycomb/honeycomb.log'
REMOTE_HC_PERSIST = '/var/lib/honeycomb/persist'
RESOURCES_LIB_SH = 'resources/libraries/bash'
RESOURCES_PAPI_PROVIDER = 'resources/tools/papi/vpp_papi_provider.py'
RESOURCES_TPL_HC = 'resources/templates/honeycomb'
RESOURCES_TPL_K8S = 'resources/templates/kubernetes'
RESOURCES_TPL_VAT = 'resources/templates/vat'
RESOURCES_TPL_VM = 'resources/templates/vm'
TREX_INSTALL_DIR = '/opt/trex-core-2.35'
TREX_INSTALL_VERSION = '2.35'
VAT_BIN_NAME = 'vpp_api_test'
VPP_UNIT = 'vpp'

2.13. ContainerUtils suite

Library to manipulate Containers.

class resources.libraries.python.ContainerUtils.ContainerManager(engine)

Bases: object

Container lifecycle management class.

acquire_all_containers()

Acquire all containers.

build_all_containers()

Build all containers.

configure_vpp_in_all_containers(chain_topology, **kwargs)

Configure VPP in all containers.

Parameters:
  • chain_topology (str) – Topology used for chaining containers can be chain or cross_horiz. Chain topology is using 1 memif pair per container. Cross_horiz topology is using 1 memif and 1 physical interface in container (only single container can be configured).
  • kwargs – Named parameters.
  • kwargs – dict
construct_container(**kwargs)

Construct container object on node with specified parameters.

Parameters:
  • kwargs – Key-value pairs used to construct container.
  • kwargs – dict
construct_containers(**kwargs)

Construct 1..N container(s) on node with specified name.

Ordinal number is automatically added to the name of container as suffix.

Parameters:
  • kwargs – Named parameters.
  • kwargs – dict
create_all_containers()

Create all containers.

destroy_all_containers()

Destroy all containers.

execute_on_all_containers(command)

Execute command on all containers.

Parameters:command (str) – Command to execute.
execute_on_container(name, command)

Execute command on container with name.

Parameters:
  • name (str) – Container name.
  • command (str) – Command to execute.
get_container_by_name(name)

Get container instance.

Parameters:name (str) – Container name.
Returns:Container instance.
Return type:Container
Raises:RuntimeError – If failed to get container with name.
restart_vpp_in_all_containers()

Restart VPP in all containers.

start_vpp_in_all_containers()

Start VPP in all containers.

stop_all_containers()

Stop all containers.

class resources.libraries.python.ContainerUtils.ContainerEngine

Bases: object

Abstract class for container engine.

acquire(force)

Acquire/download container.

Parameters:force (bool) – Destroy a container if exists and create.
build()

Build container (compile).

create()

Create/deploy container.

create_base_vpp_startup_config()

Create base startup configuration of VPP on container.

Returns:Base VPP startup configuration.
Return type:VppConfigGenerator
create_vpp_exec_config(vat_template_file, **kwargs)

Create VPP exec configuration on container.

Parameters:
  • vat_template_file (str) – File name of a VAT template script.
  • kwargs (dict) – Parameters for VAT script.
create_vpp_startup_config()

Create startup configuration of VPP without DPDK on container.

create_vpp_startup_config_dpdk_dev(*devices)

Create startup configuration of VPP with DPDK on container.

Parameters:devices (list) – List of PCI devices to add.
create_vpp_startup_config_func_dev()

Create startup configuration of VPP on container for functional vpp_device tests.

destroy()

Destroy/remove container.

execute(command)

Execute process inside container.

Parameters:command (str) – Command to run inside container.
info()

Info about container.

initialize()

Initialize container object.

install_supervisor()

Install supervisord inside a container.

is_container_present()

Check if container is present.

is_container_running()

Check if container is running.

restart_vpp()

Restart VPP service inside a container.

start_vpp()

Start VPP inside a container.

stop()

Stop container.

system_info()

System info.

class resources.libraries.python.ContainerUtils.LXC

Bases: resources.libraries.python.ContainerUtils.ContainerEngine

LXC implementation.

acquire(force=True)

Acquire a privileged system object where configuration is stored.

Parameters:force (bool) – If a container exists, destroy it and create a new container.
Raises:RuntimeError – If creating the container or writing the container config fails.
create()

Create/deploy an application inside a container on system.

Raises:RuntimeError – If creating the container fails.
destroy()

Destroy a container.

Raises:RuntimeError – If destroying container failed.
execute(command)

Start a process inside a running container.

Runs the specified command inside the container specified by name. The container has to be running already.

Parameters:command (str) – Command to run inside container.
Raises:RuntimeError – If running the command failed.
info()

Query and shows information about a container.

Raises:RuntimeError – If getting info about a container failed.
is_container_present()

Check if container is existing on node.

Returns:True if container is present.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
is_container_running()

Check if container is running on node.

Returns:True if container is running.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
stop()

Stop a container.

Raises:RuntimeError – If stopping the container failed.
system_info()

Check the current kernel for LXC support.

Raises:RuntimeError – If checking LXC support failed.
class resources.libraries.python.ContainerUtils.Docker

Bases: resources.libraries.python.ContainerUtils.ContainerEngine

Docker implementation.

acquire(force=True)

Pull an image or a repository from a registry.

Parameters:force (bool) – Destroy a container if exists.
Raises:RuntimeError – If pulling a container failed.
create()

Create/deploy container.

Raises:RuntimeError – If creating a container failed.
destroy()

Remove a container.

Raises:RuntimeError – If removing a container failed.
execute(command)

Start a process inside a running container.

Runs the specified command inside the container specified by name. The container has to be running already.

Parameters:command (str) – Command to run inside container.
Raises:RuntimeError – If runnig the command in a container failed.
info()

Return low-level information on Docker objects.

Raises:RuntimeError – If getting info about a container failed.
is_container_present()

Check if container is present on node.

Returns:True if container is present.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
is_container_running()

Check if container is running on node.

Returns:True if container is running.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
stop()

Stop running container.

Raises:RuntimeError – If stopping a container failed.
system_info()

Display the docker system-wide information.

Raises:RuntimeError – If displaying system information failed.
class resources.libraries.python.ContainerUtils.Container

Bases: object

Container class.

2.14. Cop suite

2.15. CoreDumpUtil suite

Core dump library.

class resources.libraries.python.CoreDumpUtil.CoreDumpUtil

Bases: object

Class contains methods for processing core dumps.

ROBOT_LIBRARY_SCOPE = 'GLOBAL'
static enable_coredump_limit(node, pid)

Enable coredump for PID(s) by setting no core limits.

Parameters:
  • node (dict) – Node in the topology.
  • pid (list or int) – Process ID(s) to set core dump limit to unlimited.
enable_coredump_limit_vpp_on_all_duts(nodes)

Enable coredump for all VPP PIDs by setting no core limits on all DUTs if setting of core limit by this library is enabled.

Parameters:nodes (dict) – Nodes in the topology.
get_core_files_on_all_nodes(nodes, disable_on_success=True)

Compress all core files into single file and remove the original core files on all nodes.

Parameters:
  • nodes (dict) – Nodes in the topology.
  • disable_on_success (bool) – If True, disable setting of core limit by this instance of library. Default: True
is_core_limit_enabled()

Check if core limit is set for process.

Returns:True if core limit is set for process.
Return type:bool
set_core_limit_disabled()

Disable setting of core limit for PID.

set_core_limit_enabled()

Enable setting of core limit for PID.

setup_corekeeper_on_all_nodes(nodes)

Setup core dumps system wide on all nodes.

Parameters:nodes (dict) – Nodes in the topology.

2.16. CpuUtils suite

CPU utilities library.

class resources.libraries.python.CpuUtils.CpuUtils

Bases: object

CPU utilities

NR_OF_THREADS = 2
static cpu_list_per_node(node, cpu_node, smt_used=False)

Return node related list of CPU numbers.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

List of cpu numbers related to numa from argument.

Return type:

list of int

Raises:

RuntimeError – If node cpuinfo is not available or if SMT is not enabled.

static cpu_list_per_node_str(node, cpu_node, skip_cnt=0, cpu_cnt=0, sep=', ', smt_used=False)

Return string of node related list of CPU numbers.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_cnt (int) – Count of cpus to return, if 0 then return all.
  • sep (str) – Separator, default: 1,2,3,4,....
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

Cpu numbers related to numa from argument.

Return type:

str

static cpu_node_count(node)

Return count of numa nodes.

Parameters:node (dict) – Targeted node.
Returns:Count of numa nodes.
Return type:int
Raises:RuntimeError – If node cpuinfo is not available.
static cpu_range_per_node_str(node, cpu_node, skip_cnt=0, cpu_cnt=0, sep='-', smt_used=False)

Return string of node related range of CPU numbers, e.g. 0-4.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_cnt (int) – Count of cpus to return, if 0 then return all.
  • sep (str) – Separator, default: “-”.
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

String of node related range of CPU numbers.

Return type:

str

static cpu_slice_of_list_for_nf(node, cpu_node, nf_chains=1, nf_nodes=1, nf_chain=1, nf_node=1, nf_dtc=1, nf_mtcr=2, nf_dtcr=1, skip_cnt=0)

Return list of DUT node related list of CPU numbers. The main computing unit is physical core count.

Parameters:
  • node (dict) – DUT node.
  • cpu_node – Numa node number.
  • nf_chains (int) – Number of NF chains.
  • nf_nodes (int) – Number of NF nodes in chain.
  • nf_chain (int) – Chain number indexed from 1.
  • nf_node (int) – Node number indexed from 1.
  • vs_dtc (int) – Amount of physical cores for vswitch dataplane.
  • nf_dtc (int or float) – Amount of physical cores for NF dataplane.
  • nf_mtcr (int) – NF main thread per core ratio.
  • nf_dtcr (int) – NF dataplane thread per core ratio.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_node – int.
Returns:

List of CPUs allocated to NF.

Return type:

list

Raises:

RuntimeError – If we require more cpus than available or if

placement is not possible due to wrong parameters.

static cpu_slice_of_list_per_node(node, cpu_node, skip_cnt=0, cpu_cnt=0, smt_used=False)

Return string of node related list of CPU numbers.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_cnt (int) – Count of cpus to return, if 0 then return all.
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

Cpu numbers related to numa from argument.

Return type:

list

Raises:

RuntimeError – If we require more cpus than available.

static get_affinity_nf(nodes, node, nf_chains=1, nf_nodes=1, nf_chain=1, nf_node=1, vs_dtc=1, nf_dtc=1, nf_mtcr=2, nf_dtcr=1)

Get affinity of NF (network function). Result will be used to compute the amount of CPUs and also affinity.

Parameters:
  • nodes (dict) – Physical topology nodes.
  • node (dict) – SUT node.
  • nf_chains (int) – Number of NF chains.
  • nf_nodes (int) – Number of NF nodes in chain.
  • nf_chain (int) – Chain number indexed from 1.
  • nf_node (int) – Node number indexed from 1.
  • vs_dtc (int) – Amount of physical cores for vswitch dataplane.
  • nf_dtc (int or float) – Amount of physical cores for NF dataplane.
  • nf_mtcr (int) – NF main thread per core ratio.
  • nf_dtcr (int) – NF dataplane thread per core ratio.
Returns:

List of CPUs allocated to NF.

Return type:

list

static get_cpu_layout_from_all_nodes(nodes)
Retrieve cpu layout from all nodes, assuming all nodes
are Linux nodes.
Parameters:nodes (dict) – DICT__nodes from Topology.DICT__nodes.
Raises:RuntimeError – If the ssh command “lscpu -p” fails.
static is_smt_enabled(cpu_info)

Uses CPU mapping to find out if SMT is enabled or not. If SMT is enabled, the L1d,L1i,L2,L3 setting is the same for two processors. These two processors are two threads of one core.

Parameters:cpu_info (list) – CPU info, the output of “lscpu -p”.
Returns:True if SMT is enabled, False if SMT is disabled.
Return type:bool

2.17. DUTSetup suite

DUT setup library.

class resources.libraries.python.DUTSetup.DUTSetup

Bases: object

Contains methods for setting up DUTs.

static check_huge_page(node, huge_mnt, mem_size, allocate=False)

Check if there is enough HugePages in system. If allocate is set to true, try to allocate more HugePages.

Parameters:
  • node (dict) – Node in the topology.
  • huge_mnt (str) – HugePage mount point.
  • mem_size (str) – Requested memory in MB.
  • allocate (bool) – Whether to allocate more memory if not enough.
Raises:

RuntimeError – Mounting hugetlbfs failed or not enough HugePages

or increasing map count failed.

static crypto_device_init(node, crypto_type, numvfs)

Init Crypto QAT device virtual functions on DUT.

Parameters:
  • node (dict) – DUT node.
  • numvfs (int) – Number of VFs to initialize, 0 - disable the VFs.
Crypto_type:

Crypto device type - HW_DH895xcc or HW_C3xxx.

Returns:

nothing

Raises:

RuntimeError – If failed to stop VPP or QAT failed to initialize.

static crypto_device_verify(node, crypto_type, numvfs, force_init=False)

Verify if Crypto QAT device virtual functions are initialized on all DUTs. If parameter force initialization is set to True, then try to initialize or remove VFs on QAT.

Parameters:
  • node (dict) – DUT node.
  • numvfs (int) – Number of VFs to initialize, 0 - disable the VFs.
  • force_init (bool) – If True then try to initialize to specific value.
Crypto_type:

Crypto device type - HW_DH895xcc or HW_C3xxx.

Returns:

nothing

Raises:

RuntimeError – If QAT VFs are not created and force init is set to False.

static get_docker_mergeddir(node, uuid)

Get Docker overlay for MergedDir diff.

Parameters:
  • node (dict) – DUT node.
  • uuid (str) – Docker UUID.
Returns:

Docker container MergedDir.

Return type:

str

Raises:

RuntimeError – If getting output failed.

static get_huge_page_free(node, huge_size)

Get number of free huge pages in system.

Parameters:
  • node (dict) – Node in the topology.
  • huge_size (int) – Size of hugepages.
Returns:

Number of free huge pages in system.

Return type:

int

Raises:

RuntimeError – If reading failed for three times.

static get_huge_page_size(node)

Get default size of huge pages in system.

Parameters:node (dict) – Node in the topology.
Returns:Default size of free huge pages in system.
Return type:int
Raises:RuntimeError – If reading failed for three times.
static get_huge_page_total(node, huge_size)

Get total number of huge pages in system.

Parameters:
  • node (dict) – Node in the topology.
  • huge_size (int) – Size of hugepages.
Returns:

Total number of huge pages in system.

Return type:

int

Raises:

RuntimeError – If reading failed for three times.

static get_pci_dev_driver(node, pci_addr)

Get current PCI device driver on node.

Note

# lspci -vmmks 0000:00:05.0 Slot: 00:05.0 Class: Ethernet controller Vendor: Red Hat, Inc Device: Virtio network device SVendor: Red Hat, Inc SDevice: Device 0001 PhySlot: 5 Driver: virtio-pci

Parameters:
  • node (dict) – DUT node.
  • pci_addr (str) – PCI device address.
Returns:

Driver or None

Raises:
  • RuntimeError – If PCI rescan or lspci command execution failed.
  • RuntimeError – If it is not possible to get the interface driver information from the node.
static get_service_logs(node, service)

Get specific service unit logs from node.

Parameters:
  • node (dict) – Node in the topology.
  • service (str) – Service unit name.
static get_service_logs_on_all_duts(nodes, service)

Get specific service unit logs from all DUTs.

Parameters:
  • nodes (dict) – Nodes in the topology.
  • service (str) – Service unit name.
static get_sriov_numvfs(node, pf_pci_addr)

Get number of SR-IOV VFs.

Parameters:
  • node (dict) – DUT node.
  • pf_pci_addr (str) – Physical Function PCI device address.
Returns:

Number of VFs.

Return type:

int

Raises:

RuntimeError – If PCI device is not SR-IOV capable.

static get_virtfn_pci_addr(node, pf_pci_addr, vf_id)

Get PCI address of Virtual Function.

Parameters:
  • node (dict) – DUT node.
  • pf_pci_addr (str) – Physical Function PCI address.
  • vf_id (int) – Virtual Function number.
Returns:

Virtual Function PCI address.

Return type:

int

Raises:

RuntimeError – If failed to get Virtual Function PCI address.

static get_vpp_pid(node)

Get PID of running VPP process.

Parameters:node (dict) – DUT node.
Returns:PID
Return type:int
Raises:RuntimeError – If it is not possible to get the PID.
static get_vpp_pids(nodes)

Get PID of running VPP process on all DUTs.

Parameters:nodes (dict) – DUT nodes.
Returns:PIDs
Return type:dict
static install_vpp_on_all_duts(nodes, vpp_pkg_dir)

Install VPP on all DUT nodes.

Parameters:
  • nodes (dict) – Nodes in the topology.
  • vpp_pkg_dir (str) – Path to directory where VPP packages are stored.
Raises:

RuntimeError – If failed to remove or install VPP.

static load_kernel_module(node, module)

Load kernel module on node.

Parameters:
  • node (dict) – DUT node.
  • module (str) – Module to load.
Returns:

nothing

Raises:

RuntimeError – If loading failed.

static pci_driver_bind(node, pci_addr, driver)

Bind PCI device to driver on node.

Parameters:
  • node (dict) – DUT node.
  • pci_addr (str) – PCI device address.
  • driver (str) – Driver to bind.
Raises:

RuntimeError – If PCI device bind failed.

static pci_driver_unbind(node, pci_addr)

Unbind PCI device from current driver on node.

Parameters:
  • node (dict) – DUT node.
  • pci_addr (str) – PCI device address.
Raises:

RuntimeError – If PCI device unbind failed.

static pci_vf_driver_bind(node, pf_pci_addr, vf_id, driver)

Bind Virtual Function to driver on node.

Parameters:
  • node (dict) – DUT node.
  • pf_pci_addr (str) – PCI device address.
  • vf_id (int) – Virtual Function ID.
  • driver (str) – Driver to bind.
Raises:

RuntimeError – If PCI device bind failed.

static pci_vf_driver_unbind(node, pf_pci_addr, vf_id)

Unbind Virtual Function from driver on node.

Parameters:
  • node (dict) – DUT node.
  • pf_pci_addr (str) – PCI device address.
  • vf_id (int) – Virtual Function ID.
Raises:

RuntimeError – If Virtual Function unbind failed.

static running_in_container(node)

This method tests if topology node is running inside container.

Parameters:node (dict) – Topology node.
Returns:True if running in docker container, false if not or failed

to detect. :rtype: bool

static set_sriov_numvfs(node, pf_pci_addr, numvfs=0)

Init or reset SR-IOV virtual functions by setting its number on PCI device on DUT. Setting to zero removes all VFs.

Parameters:
  • node (dict) – DUT node.
  • pf_pci_addr (str) – Physical Function PCI device address.
  • numvfs (int) – Number of VFs to initialize, 0 - removes the VFs.
Raises:

RuntimeError – Failed to create VFs on PCI.

static setup_all_duts(nodes)

Run script over SSH to setup all DUT nodes.

Parameters:nodes (dict) – Topology nodes.
static setup_dut(node)

Run script over SSH to setup the DUT node.

Parameters:node (dict) – DUT node to set up.
Raises:Exception – If the DUT setup fails.
static start_service(node, service)

Start up the named service on node.

Parameters:
  • node (dict) – Node in the topology.
  • service (str) – Service unit name.
static start_service_on_all_duts(nodes, service)

Start up the named service on all DUTs.

Parameters:
  • node (dict) – Nodes in the topology.
  • service (str) – Service unit name.
static stop_service(node, service)

Stop the named service on node.

Parameters:
  • node (dict) – Node in the topology.
  • service (str) – Service unit name.
static stop_service_on_all_duts(nodes, service)

Stop the named service on all DUTs.

Parameters:
  • node (dict) – Nodes in the topology.
  • service (str) – Service unit name.
static verify_kernel_module(node, module, force_load=False)

Verify if kernel module is loaded on node. If parameter force load is set to True, then try to load the modules.

Parameters:
  • node (dict) – Node.
  • module (str) – Module to verify.
  • force_load (bool) – If True then try to load module.
Raises:

RuntimeError – If module is not loaded or failed to load.

static verify_kernel_module_on_all_duts(nodes, module, force_load=False)

Verify if kernel module is loaded on all DUTs. If parameter force load is set to True, then try to load the modules.

Parameters:
  • node (dict) – DUT nodes.
  • module (str) – Module to verify.
  • force_load (bool) – If True then try to load module.
static verify_uio_driver_on_all_duts(nodes)

Verify if uio driver kernel module is loaded on all DUTs. If module is not present it will try to load it.

Parameters:node (dict) – DUT nodes.

2.18. Dhcp suite

2.19. DpdkUtil suite

Dpdk Utilities Library.

class resources.libraries.python.DpdkUtil.DpdkUtil

Bases: object

Utilities for DPDK.

static dpdk_testpmd_start(node, **kwargs)

Start DPDK testpmd app on VM node.

Parameters:
  • node (dict) – VM Node to start testpmd on.
  • args (dict) – Key-value testpmd parameters.
Returns:

nothing

static dpdk_testpmd_stop(node)

Stop DPDK testpmd app on node.

Parameters:node (dict) – Node to stop testpmd on.
Returns:nothing
static get_eal_options(**args)

Create EAL parameters string.

Parameters:args (dict) – List of testpmd parameters.
Returns:EAL parameters string.
Return type:str
static get_pmd_options(**args)

Create PMD parameters string.

Parameters:args (dict) – List of testpmd parameters.
Returns:PMD parameters string.
Return type:str
static get_testpmd_cmdline(**kwargs)

Get DPDK testpmd command line arguments.

Parameters:args (dict) – Key-value testpmd parameters.
Returns:Command line string.
Return type:str

2.20. DropRateSearch suite

Drop rate search algorithms

class resources.libraries.python.DropRateSearch.DropRateSearch

Bases: object

Abstract class with search algorithm implementation.

Binary search of rate with loss below acceptance criteria.

Parameters:
  • b_min (float) – Min range rate.
  • b_max (float) – Max range rate.
  • traffic_type (str) – Traffic profile.
  • skip_max_rate (bool) – Start with max rate first
  • skip_warmup (bool) – Start TRex without warmup traffic if true.
Returns:

nothing

Raises:

ValueError – If input values are not valid.

Combined search of rate with loss below acceptance criteria.

Parameters:
  • start_rate (float) – Initial rate.
  • traffic_type (str) – Traffic profile.
Returns:

nothing

Raises:

RuntimeError – If linear search failed.

static floats_are_close_equal(num_a, num_b, rel_tol=1e-09, abs_tol=0.0)

Compares two float numbers for close equality.

Parameters:
  • num_a (float) – First number to compare.
  • num_b (float) – Second number to compare.
  • rel_tol=1e-9 – The relative tolerance.
  • abs_tol=0.0 – The minimum absolute tolerance level.
Returns:

Returns True if num_a is close in value to num_b or equal. False otherwise.

Return type:

boolean

Raises:

ValueError – If input values are not valid.

get_binary_convergence_threshold()

Get convergence for binary search.

Returns:Treshold value number.
Return type:float
get_duration()

Return configured duration of single traffic run.

Returns:Number of seconds for traffic to run.
Return type:int
get_latency()

Return min/avg/max latency.

Returns:Latency stats.
Return type:list
get_loss_acceptance()

Return configured loss acceptance treshold.

Returns:Loss acceptance treshold.
Return type:float
get_max_attempts()

Return maximum number of traffic runs during one rate step.

Returns:Number of traffic runs.
Return type:int
get_rate_type_str()

Return rate type representation.

Returns:String representation of rate type.
Return type:str
Raises:ValueError – If rate type is unknown.

Linear search of rate with loss below acceptance criteria.

Parameters:
  • start_rate (float) – Initial rate.
  • traffic_type (str) – Traffic profile.
Returns:

nothing

Raises:

ValueError – If start rate is not in range.

loss_acceptance_type_is_percentage()
Return true if loss acceptance treshold type is percentage,
false otherwise.
Returns:True if loss acceptance treshold type is percentage.
Return type:boolean
measure_loss(rate, frame_size, loss_acceptance, loss_acceptance_type, traffic_type, skip_warmup=False)

Send traffic from TG and measure count of dropped frames.

Parameters:
  • rate (int) – Offered traffic load.
  • frame_size (str) – Size of frame.
  • loss_acceptance (float) – Permitted drop ratio or frames count.
  • loss_acceptance_type (LossAcceptanceType) – Type of permitted loss.
  • traffic_type (bool) – Traffic profile ([2,3]-node-L[2,3], ...).
  • skip_warmup – Start TRex without warmup traffic if true.
Returns:

Drop threshold exceeded? (True/False)

Return type:

bool

set_binary_convergence_threshold(convergence)

Set convergence for binary search.

Parameters:convergence (float) – Treshold value number.
Returns:nothing
set_duration(duration)

Set the duration of single traffic run.

Parameters:duration (int) – Number of seconds for traffic to run.
Returns:nothing
set_loss_acceptance(loss_acceptance)

Set loss acceptance treshold for PDR search.

Parameters:loss_acceptance (str) – Loss acceptance treshold for PDR search.
Returns:nothing
Raises:ValueError – If loss acceptance is lower than zero.
set_loss_acceptance_type_frames()

Set loss acceptance treshold type to frames.

Returns:nothing
set_loss_acceptance_type_percentage()

Set loss acceptance treshold type to percentage.

Returns:nothing
set_max_attempts(max_attempts)

Set maximum number of traffic runs during one rate step.

Parameters:max_attempts (int) – Number of traffic runs.
Returns:nothing
Raises:ValueError – If max attempts is lower than zero.
set_search_frame_size(frame_size)

Set size of frames to send.

Parameters:frame_size (str) – Size of frames.
Returns:nothing
set_search_linear_step(step_rate)

Set step size for linear search.

Parameters:step_rate (float) – Linear search step size.
Returns:nothing
set_search_rate_boundaries(max_rate, min_rate)

Set search boundaries: min,max.

Parameters:
  • max_rate (float) – Upper value of search boundaries.
  • min_rate (float) – Lower value of search boundaries.
Returns:

nothing

Raises:

ValueError – If min rate is lower than 0 or higher than max rate.

set_search_rate_type_bps()

Set rate type to bits per second.

Returns:nothing
set_search_rate_type_percentage()

Set rate type to percentage of linerate.

Returns:nothing
set_search_rate_type_pps()

Set rate type to packets per second.

Returns:nothing
set_search_result_type_best_of_n()

Set type of search result evaluation to Best of N.

Returns:nothing
set_search_result_type_worst_of_n()

Set type of search result evaluation to Worst of N.

Returns:nothing
verify_search_result()

Fail if search was not successful.

Returns:Result rate and latency stats.
Return type:tuple
Raises:Exception – If search failed.
class resources.libraries.python.DropRateSearch.LossAcceptanceType

Bases: enum.Enum

Type of the loss acceptance criteria.

FRAMES = 1
PERCENTAGE = 2
class resources.libraries.python.DropRateSearch.RateType

Bases: enum.Enum

Type of rate units.

BITS_PER_SECOND = 3
PACKETS_PER_SECOND = 2
PERCENTAGE = 1
class resources.libraries.python.DropRateSearch.SearchDirection

Bases: enum.Enum

Direction of linear search.

BOTTOM_UP = 2
TOP_DOWN = 1
class resources.libraries.python.DropRateSearch.SearchResultType

Bases: enum.Enum

Type of search result evaluation.

BEST_OF_N = 1
WORST_OF_N = 2
class resources.libraries.python.DropRateSearch.SearchResults

Bases: enum.Enum

Result of the drop rate search.

FAILURE = 2
SUCCESS = 1
SUSPICIOUS = 3

2.21. HTTPRequest suite

Implementation of HTTP requests GET, PUT, POST and DELETE used in communication with Honeycomb.

The HTTP requests are implemented in the class HTTPRequest which uses requests.request.

class resources.libraries.python.HTTPRequest.HTTPCodes

Bases: enum.IntEnum

HTTP status codes

ACCEPTED = 201
CONFLICT = 409
FORBIDDEN = 403
INTERNAL_SERVER_ERROR = 500
NOT_FOUND = 404
OK = 200
SERVICE_UNAVAILABLE = 503
UNAUTHORIZED = 401
class resources.libraries.python.HTTPRequest.HTTPRequest

Bases: object

A class implementing HTTP requests GET, PUT, POST and DELETE used in communication with Honeycomb.

The communication with Honeycomb and processing of all exceptions is done in the method _http_request which uses requests.request to send requests and receive responses. The received status code and content of response are logged on the debug level. All possible exceptions raised by requests.request are also processed there.

The other methods (get, put, post and delete) use _http_request to send corresponding request.

These methods must not be used as keywords in tests. Use keywords implemented in the module HoneycombAPIKeywords instead.

static create_full_url(ip_addr, port, path)

Creates full url including host, port, and path to data.

Parameters:
  • ip_addr (str) – Server IP.
  • port (str or int) – Communication port.
  • path (str) – Path to data.
Returns:

Full url.

Return type:

str

static delete(node, path, timeout=15)

Sends a DELETE request and returns the response and status code.

Parameters:
  • node (dict) – Honeycomb node.
  • path (str) – URL path, e.g. /index.html.
  • timeout (float or tuple) – How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
Returns:

Status code and content of response.

Return type:

tuple

static get(node, path, headers=None, timeout=15, enable_logging=True)

Sends a GET request and returns the response and status code.

Parameters:
  • node (dict) – Honeycomb node.
  • path (str) – URL path, e.g. /index.html.
  • headers (dict) – Dictionary of HTTP Headers to send with the Request.
  • timeout (float or tuple) – How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
  • enable_logging (bool) – Used to suppress errors when checking Honeycomb state during suite setup and teardown. When True, logging is enabled, otherwise logging is disabled.
Returns:

Status code and content of response.

Return type:

tuple

static post(node, path, headers=None, payload=None, json=None, timeout=15, enable_logging=True)

Sends a POST request and returns the response and status code.

Parameters:
  • node (dict) – Honeycomb node.
  • path (str) – URL path, e.g. /index.html.
  • headers (dict) – Dictionary of HTTP Headers to send with the Request.
  • payload (dict, bytes, or file-like object) – Dictionary, bytes, or file-like object to send in the body of the Request.
  • json (str) – JSON formatted string to send in the body of the Request.
  • timeout (float or tuple) – How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
  • enable_logging (bool) – Used to suppress errors when checking ODL state during suite setup and teardown. When True, logging is enabled, otherwise logging is disabled.
Returns:

Status code and content of response.

Return type:

tuple

static put(node, path, headers=None, payload=None, json=None, timeout=15)

Sends a PUT request and returns the response and status code.

Parameters:
  • node (dict) – Honeycomb node.
  • path (str) – URL path, e.g. /index.html.
  • headers (dict) – Dictionary of HTTP Headers to send with the Request.
  • payload (dict, bytes, or file-like object) – Dictionary, bytes, or file-like object to send in the body of the Request.
  • json (str) – JSON formatted string to send in the body of the Request.
  • timeout (float or tuple) – How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
Returns:

Status code and content of response.

Return type:

tuple

exception resources.libraries.python.HTTPRequest.HTTPRequestError(msg, details='', enable_logging=True)

Bases: exceptions.Exception

Exception raised by HTTPRequest objects.

When raising this exception, put this information to the message in this order:

  • short description of the encountered problem,
  • relevant messages if there are any collected, e.g., from caught exception,
  • relevant data if there are any collected.

The logging is performed on two levels: 1. error - short description of the problem; 2. debug - detailed information.

2.22. IPUtil suite

Common IP utilities library.

class resources.libraries.python.IPUtil.IPUtil

Bases: object

Common IP utilities

static get_linux_interface_name(node, pci_addr)

Get the interface name.

Parameters:
  • node (dict) – Node where to execute command.
  • pci_addr (str) – PCI address
Returns:

Interface name

Return type:

str

Raises:

RuntimeError – If cannot get the information about interfaces.

static int_to_ip(ip_int)

Convert IP address from integer representation (e.g. 167772161) to string format (10.0.0.1).

Parameters:ip_int (int) – IP address in integer representation.
Returns:String representation of IP address.
Return type:str
static ip_addresses_should_be_equal(ip1, ip2)

Fails if the given IP addresses are unequal.

Parameters:
  • ip1 (str) – IPv4 or IPv6 address.
  • ip2 (str) – IPv4 or IPv6 address.
static ip_to_int(ip_str)

Convert IP address from string format (e.g. 10.0.0.1) to integer representation (167772161).

Parameters:ip_str (str) – IP address in string representation.
Returns:Integer representation of IP address.
Return type:int
static linux_enable_forwarding(node, ip_ver='ipv4')

Enable forwarding on a Linux node, e.g. VM.

Parameters:
  • node (dict) – Node to enable forwarding on.
  • ip_ver (str) – IP version, ‘ipv4’ or ‘ipv6’.
static set_linux_interface_ip(node, interface, ip_addr, prefix, namespace=None)

Set IP address to interface in linux.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
  • ip_addr (str) – IP to be set on interface.
  • prefix (int) – IP prefix.
  • namespace (str) – Execute command in namespace. Optional
Raises:

RuntimeError – IP could not be set.

static set_linux_interface_route(node, interface, route, namespace=None)

Set route via interface in linux.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
  • route (str) – Route to be added via interface.
  • namespace (str) – Execute command in namespace. Optional parameter.
static set_linux_interface_up(node, interface)

Set the specified interface up.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
Raises:

RuntimeError – If the interface could not be set up.

static setup_network_namespace(node, namespace_name, interface_name, ip_addr, prefix)

Setup namespace on given node and attach interface and IP to this namespace. Applicable also on TG node.

Parameters:
  • node (dict) – Node to set namespace on.
  • namespace_name (str) – Namespace name.
  • interface_name – Interface name.
  • ip_addr (str) – IP address of namespace’s interface.
  • prefix (int) – IP address prefix length.
static vpp_ip_probe(node, interface, addr, if_type='key')

Run ip probe on VPP node.

Parameters:
  • node (dict) – VPP node.
  • interface (str) – Interface key or name.
  • addr (str) – IPv4/IPv6 address.
  • if_type (str) – Interface type
Raises:
  • ValueError – If the if_type is unknown.
  • Exception – If vpp probe fails.
resources.libraries.python.IPUtil.convert_ipv4_netmask_prefix(network)

Convert network mask to equivalent network prefix length or vice versa.

Example: mask 255.255.0.0 -> prefix length 16 :param network: Network mask or network prefix length. :type network: str or int :returns: Network mask or network prefix length. :rtype: str or int

2.23. IPsecUtil suite

2.24. IPv4NodeAddress suite

Robot framework variable file.

Create dictionary variable nodes_ipv4_addr of IPv4 addresses from available networks.

class resources.libraries.python.IPv4NodeAddress.IPv4NetworkGenerator(networks)

Bases: object

IPv4 network generator.

TODO: Conform to https://docs.python.org/2/library/stdtypes.html#typeiter

next_network()

Pop and return network from internal list.

Returns:Next network in form (IPv4Network, subnet).
Raises:StopIteration – If there are no more elements.
resources.libraries.python.IPv4NodeAddress.get_variables(nodes, networks=['192.168.1.0/24', '192.168.2.0/24', '192.168.3.0/24', '192.168.4.0/24', '192.168.5.0/24', '192.168.6.0/24', '192.168.7.0/24', '192.168.8.0/24', '192.168.9.0/24', '192.168.10.0/24', '192.168.11.0/24', '192.168.12.0/24', '192.168.13.0/24', '192.168.14.0/24', '192.168.15.0/24', '192.168.16.0/24', '192.168.17.0/24', '192.168.18.0/24', '192.168.19.0/24', '192.168.20.0/24', '192.168.21.0/24', '192.168.22.0/24', '192.168.23.0/24', '192.168.24.0/24', '192.168.25.0/24', '192.168.26.0/24', '192.168.27.0/24', '192.168.28.0/24', '192.168.29.0/24', '192.168.30.0/24', '192.168.31.0/24', '192.168.32.0/24', '192.168.33.0/24', '192.168.34.0/24', '192.168.35.0/24', '192.168.36.0/24', '192.168.37.0/24', '192.168.38.0/24', '192.168.39.0/24', '192.168.40.0/24', '192.168.41.0/24', '192.168.42.0/24', '192.168.43.0/24', '192.168.44.0/24', '192.168.45.0/24', '192.168.46.0/24', '192.168.47.0/24', '192.168.48.0/24', '192.168.49.0/24', '192.168.50.0/24', '192.168.51.0/24', '192.168.52.0/24', '192.168.53.0/24', '192.168.54.0/24', '192.168.55.0/24', '192.168.56.0/24', '192.168.57.0/24', '192.168.58.0/24', '192.168.59.0/24', '192.168.60.0/24', '192.168.61.0/24', '192.168.62.0/24', '192.168.63.0/24', '192.168.64.0/24', '192.168.65.0/24', '192.168.66.0/24', '192.168.67.0/24', '192.168.68.0/24', '192.168.69.0/24', '192.168.70.0/24', '192.168.71.0/24', '192.168.72.0/24', '192.168.73.0/24', '192.168.74.0/24', '192.168.75.0/24', '192.168.76.0/24', '192.168.77.0/24', '192.168.78.0/24', '192.168.79.0/24', '192.168.80.0/24', '192.168.81.0/24', '192.168.82.0/24', '192.168.83.0/24', '192.168.84.0/24', '192.168.85.0/24', '192.168.86.0/24', '192.168.87.0/24', '192.168.88.0/24', '192.168.89.0/24', '192.168.90.0/24', '192.168.91.0/24', '192.168.92.0/24', '192.168.93.0/24', '192.168.94.0/24', '192.168.95.0/24', '192.168.96.0/24', '192.168.97.0/24', '192.168.98.0/24', '192.168.99.0/24'])

Special robot framework method that returns dictionary nodes_ipv4_addr, mapping of node and interface name to IPv4 address.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • networks (list) – List of available IPv4 networks.

Note

Robot framework calls it automatically.

2.25. IPv4Setup suite

2.26. IPv4Util suite

2.27. IPv6NodesAddr suite

2.28. IPv6Setup suite

2.29. IPv6Util suite

2.30. InterfaceUtil suite

2.31. KubernetesUtils suite

Library to control Kubernetes kubectl.

class resources.libraries.python.KubernetesUtils.KubernetesUtils

Bases: object

Kubernetes utilities class.

static apply_kubernetes_resource_on_all_duts(nodes, yaml_file, **kwargs)

Apply Kubernetes resource on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • yaml_file (str) – YAML configuration file.
  • kwargs (dict) – Key-value pairs to replace in YAML template.
static apply_kubernetes_resource_on_node(node, yaml_file, **kwargs)

Apply Kubernetes resource on node.

Parameters:
  • node (dict) – DUT node.
  • yaml_file (str) – YAML configuration file.
  • kwargs (dict) – Key-value pairs to replace in YAML template.
Raises:

RuntimeError – If applying Kubernetes template failed.

static create_kubernetes_cm_from_file_on_all_duts(nodes, nspace, name, **kwargs)

Create Kubernetes ConfigMap from file on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
  • name (str) – ConfigMap name.
  • kwargs – Named parameters.
  • kwargs – dict
static create_kubernetes_cm_from_file_on_node(node, nspace, name, **kwargs)

Create Kubernetes ConfigMap from file on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
  • name (str) – ConfigMap name.
  • kwargs – Named parameters.
  • kwargs – dict
Raises:

RuntimeError – If creating Kubernetes ConfigMap failed.

static create_kubernetes_vnf_startup_config(**kwargs)

Create Kubernetes VNF startup configuration.

Parameters:
  • kwargs – Key-value pairs used to create configuration.
  • kwargs – dict
static create_kubernetes_vswitch_startup_config(**kwargs)

Create Kubernetes VSWITCH startup configuration.

Parameters:
  • kwargs – Key-value pairs used to create configuration.
  • kwargs – dict
static delete_kubernetes_resource_on_all_duts(nodes, nspace, name=None, rtype='po, cm, deploy, rs, rc, svc')

Delete all Kubernetes resource on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
  • rtype (str) – Kubernetes resource type.
  • name (str) – Name of resource.
static delete_kubernetes_resource_on_node(node, nspace, name=None, rtype='po, cm, deploy, rs, rc, svc')

Delete Kubernetes resource on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
  • rtype (str) – Kubernetes resource type.
  • name (str) – Name of resource (Default: all).
Raises:

RuntimeError – If retrieving or deleting Kubernetes resource failed.

static describe_kubernetes_resource_on_all_duts(nodes, nspace)

Describe all Kubernetes PODs in namespace on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
static describe_kubernetes_resource_on_node(node, nspace)

Describe all Kubernetes PODs in namespace on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
static destroy_kubernetes_on_all_duts(nodes)

Destroy Kubernetes on all DUTs.

Parameters:nodes (dict) – Topology nodes.
static destroy_kubernetes_on_node(node)

Destroy Kubernetes on node.

Parameters:node (dict) – DUT node.
Raises:RuntimeError – If destroying Kubernetes failed.
static get_kubernetes_logs_on_all_duts(nodes, nspace)

Get Kubernetes logs from all PODs in namespace on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
static get_kubernetes_logs_on_node(node, nspace)

Get Kubernetes logs from all PODs in namespace on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
static load_docker_image_on_all_duts(nodes, image_path)

Load Docker container image from file on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • image_path (str) – Container image path.
static load_docker_image_on_node(node, image_path)

Load Docker container image from file on node.

Parameters:
  • node (dict) – DUT node.
  • image_path (str) – Container image path.
Raises:

RuntimeError – If loading image failed on node.

static set_kubernetes_pods_affinity_on_all_duts(nodes)

Set affinity for all Kubernetes PODs except VPP on all DUTs.

Parameters:nodes (dict) – Topology nodes.
static set_kubernetes_pods_affinity_on_node(node)

Set affinity for all Kubernetes PODs except VPP on node.

Parameters:node (dict) – DUT node.
static setup_kubernetes_on_all_duts(nodes)

Set up Kubernetes on all DUTs.

Parameters:nodes (dict) – Topology nodes.
static setup_kubernetes_on_node(node)

Set up Kubernetes on node.

Parameters:node (dict) – DUT node.
Raises:RuntimeError – If Kubernetes setup failed on node.
static wait_for_kubernetes_pods_on_all_duts(nodes, nspace)

Wait for Kubernetes to become ready on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
static wait_for_kubernetes_pods_on_node(node, nspace)

Wait for Kubernetes PODs to become ready on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
Raises:

RuntimeError – If Kubernetes PODs are not in Running state.

2.32. L2Util suite

2.33. LimitUtil suite

Linux limit library.

class resources.libraries.python.LimitUtil.LimitUtil

Bases: object

Class contains methods for getting or setting process resource limits.

static get_pid_limit(node, pid)

Get process resource limits.

Parameters:
  • node (dict) – Node in the topology.
  • pid (int) – Process ID.
static set_pid_limit(node, pid, resource, limit)

Set process resource limits.

Parameters:
  • node (dict) – Node in the topology.
  • pid (int) – Process ID.
  • resource (str) – Resource to set limits.
  • limit (str) – Limit value.

2.34. LispSetup suite

2.35. LispUtil suite

2.36. MacSwap suite

2.37. Map suite

2.38. Memif suite

2.39. NATUtil suite

2.40. Namespaces suite

Linux namespace utilities library.

class resources.libraries.python.Namespaces.Namespaces

Bases: object

Linux namespace utilities.

static attach_interface_to_namespace(node, namespace, interface)

Attach specific interface to namespace.

Parameters:
  • node (dict) – Node where to execute command.
  • namespace (str) – Namespace to execute command on.
  • interface (str) – Interface in namespace.
Raises:

RuntimeError – Interface could not be attached.

clean_up_namespaces(node)

Remove all old namespaces.

Parameters:node (dict) – Node where to execute command.
Raises:RuntimeError – Namespaces could not be cleaned properly.
static create_bridge_for_int_in_namespace(node, namespace, bridge_name, *interfaces)

Setup bridge domain and add interfaces to it.

Parameters:
  • node (dict) – Node where to execute command.
  • namespace (str) – Namespace to execute command on.
  • bridge_name (str) – Name of the bridge to be created.
  • interfaces (list) – List of interfaces to add to the namespace.
create_namespace(node, namespace_name)

Create namespace and add the name to the list for later clean-up.

Parameters:
  • node (dict) – Where to create namespace.
  • namespace_name (str) – Name for namespace.

2.41. NodePath suite

Path utilities library for nodes in the topology.

class resources.libraries.python.NodePath.NodePath

Bases: object

Path utilities for nodes in the topology.

Example:

node1–link1–>node2–link2–>node3–link3–>node2–link4–>node1 RobotFramework: | Library | resources/libraries/python/NodePath.py

Path test
| [Arguments] | ${node1} | ${node2} | ${node3}
| Append Node | ${nodes1}
| Append Node | ${nodes2}
| Append Nodes | ${nodes3} | ${nodes2}
| Append Node | ${nodes1}
| Compute Path | ${FALSE}
| ${first_int} | ${node}= | First Interface
| ${last_int} | ${node}= | Last Interface
| ${first_ingress} | ${node}= | First Ingress Interface
| ${last_egress} | ${node}= | Last Egress Interface
| ${next} | ${node}= | Next Interface

Python: >>> from NodePath import NodePath >>> path = NodePath() >>> path.append_node(node1) >>> path.append_node(node2) >>> path.append_nodes(node3, node2) >>> path.append_node(node1) >>> path.compute_path() >>> (interface, node) = path.first_interface() >>> (interface, node) = path.last_interface() >>> (interface, node) = path.first_ingress_interface() >>> (interface, node) = path.last_egress_interface() >>> (interface, node) = path.next_interface()

append_node(node, filter_list=None)

Append node to the path.

Parameters:
  • node (dict) – Node to append to the path.
  • filter_list (list of strings) – Filter criteria list.
append_nodes(*nodes)

Append nodes to the path.

Parameters:nodes (dict) – Nodes to append to the path.

Note

Node order does matter.

clear_path()

Clear path.

compute_path(always_same_link=True)

Compute path for added nodes.

Note

First add at least two nodes to the topology.

Parameters:always_same_link (bool) – If True use always same link between two nodes in path. If False use different link (if available) between two nodes if one link was used before.
Raises:RuntimeError – If not enough nodes for path.
first_ingress_interface()

Return first ingress interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

first_interface()

Return first interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

last_egress_interface()

Return last egress interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

last_interface()

Return last interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

next_interface()

Path interface iterator.

Returns:Interface and node or None if not next interface.
Return type:tuple (str, dict)

Note

Call compute_path before.

2.42. PacketVerifier suite

PacketVerifier module.

Example.

| >>> from scapy.all import *
| >>> from PacketVerifier import *
| >>> rxq = RxQueue('eth1')
| >>> txq = TxQueue('eth1')
| >>> src_mac = "AA:BB:CC:DD:EE:FF"
| >>> dst_mac = "52:54:00:ca:5d:0b"
| >>> src_ip = "11.11.11.10"
| >>> dst_ip = "11.11.11.11"
| >>> sent_packets = []
| >>> pkt_send = Ether(src=src_mac, dst=dst_mac) /
| ... IP(src=src_ip, dst=dst_ip) /
| ... ICMP()
| >>> sent_packets.append(pkt_send)
| >>> txq.send(pkt_send)
| >>> pkt_send = Ether(src=src_mac, dst=dst_mac) /
| ... ARP(hwsrc=src_mac, psrc=src_ip, hwdst=dst_mac, pdst=dst_ip, op=2)
| >>> sent_packets.append(pkt_send)
| >>> txq.send(pkt_send)
| >>> rxq.recv(100, sent_packets).show()
| ###[ Ethernet ]###
|   dst       = aa:bb:cc:dd:ee:ff
|   src       = 52:54:00:ca:5d:0b
|   type      = 0x800
| ###[ IP ]###
|   version   = 4L
|   ihl       = 5L
|   tos       = 0x0
|   len       = 28
|   id        = 43183
|   flags     =
|   frag      = 0L
|   ttl       = 64
|   proto     = icmp
|   chksum    = 0xa607
|   src       = 11.11.11.11
|   dst       = 11.11.11.10
|   options
| ###[ ICMP ]###
|   type      = echo-reply
|   code      = 0
|   chksum    = 0xffff
|   id        = 0x0
|   seq       = 0x0
| ###[ Padding ]###
|   load = 'RTÊ]

ª»ÌÝîÿ’

Example end.
class resources.libraries.python.PacketVerifier.RxQueue(interface_name)

Bases: resources.libraries.python.PacketVerifier.PacketVerifier

Receive queue object.

This object creates raw socket, reads packets from it and provides function to access them.

Parameters:interface_name (str) – Which interface to bind to.
recv(timeout=3, ignore=None, verbose=True)

Read next received packet.

Returns scapy’s Ether() object created from next packet in the queue. Queue is being filled in parallel in subprocess. If no packet arrives in given timeout queue.Empty exception will be risen.

Parameters:
  • timeout (int) – How many seconds to wait for next packet.
  • ignore (list) – List of packets that should be ignored.
  • verbose (bool) – Used to suppress detailed logging of received packets.
Returns:

Ether() initialized object from packet data.

Return type:

scapy.Ether

class resources.libraries.python.PacketVerifier.TxQueue(interface_name)

Bases: resources.libraries.python.PacketVerifier.PacketVerifier

Transmission queue object.

This object is used to send packets over RAW socket on a interface.

Parameters:interface_name (str) – Which interface to send packets from.
send(pkt, verbose=True)

Send packet out of the bound interface.

Parameters:
  • pkt (string or scapy Packet derivative.) – Packet to send.
  • verbose (bool) – Used to supress detailed logging of sent packets.
class resources.libraries.python.PacketVerifier.Interface(if_name)

Bases: object

Class for network interfaces. Contains methods for sending and receiving packets.

recv_pkt(timeout=3)

Read one packet from the interface’s receive queue.

Parameters:timeout (int) – Timeout value in seconds.
Returns:Ether() initialized object from packet data.
Return type:scapy.Ether
send_pkt(pkt)

Send the provided packet out the interface.

resources.libraries.python.PacketVerifier.create_gratuitous_arp_request(src_mac, src_ip)

Creates scapy representation of gratuitous ARP request.

resources.libraries.python.PacketVerifier.auto_pad(packet)

Pads zeroes at the end of the packet if the total len < 60 bytes.

resources.libraries.python.PacketVerifier.checksum_equal(chksum1, chksum2)

Compares two checksums in one’s complement notation.

Checksums to be compared are calculated as 16 bit one’s complement of the one’s complement sum of 16 bit words of some buffer. In one’s complement notation 0x0000 (positive zero) and 0xFFFF (negative zero) are equivalent.

Parameters:
  • chksum1 (uint16) – First checksum.
  • chksum2 (uint16) – Second checksum.
Returns:

True if checksums are equivalent, False otherwise.

Return type:

boolean

2.43. PapiExecutor suite

2.44. PapiHistory suite

2.45. Policer suite

2.46. ProxyArp suite

2.47. QemuManager suite

2.48. QemuUtils suite

2.49. Routing suite

2.50. SRv6 suite

2.51. SchedUtils suite

Linux scheduler util library

class resources.libraries.python.SchedUtils.SchedUtils

Bases: object

General class for any linux scheduler related methods/functions.

static set_proc_scheduling_other(node, pid)

Set normal scheduling of a process to SCHED_OTHER for specified PID.

Parameters:
  • node (dict) – Node where to apply scheduling changes.
  • pid (int) – Process ID.
Raises:
  • ValueError – Parameters out of allowed ranges.
  • RuntimeError – Failed to set policy for PID.
static set_proc_scheduling_rr(node, pid, priority=1)

Set real-time scheduling of a process to SCHED_RR with priority for specified PID.

Parameters:
  • node (dict) – Node where to apply scheduling changes.
  • pid (int) – Process ID.
  • priority (int) – Realtime priority in range 1-99. Default is 1.
Raises:
  • ValueError – Parameters out of allowed ranges.
  • RuntimeError – Failed to set policy for PID.
static set_vpp_scheduling_rr(node)

Set real-time scheduling attributes of VPP worker threads to SCHED_RR with priority 1.

Parameters:node (dict) – DUT node with running VPP.
Raises:RuntimeError – Failed to retrieve PID for VPP worker threads.

2.52. SetupFramework suite

This module exists to provide setup utilities for the framework on topology nodes. All tasks required to be run before the actual tests are started is supposed to end up here.

class resources.libraries.python.SetupFramework.SetupFramework

Bases: object

Setup suite run on topology nodes.

Many VAT/CLI based tests need the scripts at remote hosts before executing them. This class packs the whole testing directory and copies it over to all nodes in topology under /tmp/

static setup_framework(nodes)

Pack the whole directory and extract in temp on each node.

Parameters:nodes (dict) – Topology nodes.
Raises:RuntimeError – If setup framework failed.

2.53. SysctlUtil suite

Linux sysctl library.

class resources.libraries.python.SysctlUtil.SysctlUtil

Bases: object

Class contains methods for getting or setting sysctl settings.

static get_sysctl_value(node, key)

Get sysctl key.

Parameters:
  • node (dict) – Node in the topology.
  • key (str) – Key that will be set.
static set_sysctl_value(node, key, value)

Set sysctl key to specific value.

Parameters:
  • node (dict) – Node in the topology.
  • key (str) – Key that will be set.
  • value (str) – Value to set.

2.54. TGSetup suite

2.55. Tap suite

2.56. Trace suite

2.57. TrafficGenerator suite

Performance testing traffic generator library.

class resources.libraries.python.TrafficGenerator.TGDropRateSearchImpl

Bases: resources.libraries.python.DropRateSearch.DropRateSearch

Drop Rate Search implementation.

get_latency()

Returns min/avg/max latency.

Returns:Latency stats.
Return type:list
measure_loss(rate, frame_size, loss_acceptance, loss_acceptance_type, traffic_profile, skip_warmup=False)

Runs the traffic and evaluate the measured results.

Parameters:
  • rate (float) – Offered traffic load.
  • frame_size (str) – Size of frame.
  • loss_acceptance (float) – Permitted drop ratio or frames count.
  • loss_acceptance_type (LossAcceptanceType) – Type of permitted loss.
  • traffic_profile (str) – Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules.
  • skip_warmup (bool) – Start TRex without warmup traffic if true.
Returns:

Drop threshold exceeded? (True/False)

Return type:

bool

Raises:
  • NotImplementedError – If TG is not supported.
  • RuntimeError – If TG is not specified.
class resources.libraries.python.TrafficGenerator.TrafficGenerator

Bases: resources.libraries.python.MLRsearch.AbstractMeasurer.AbstractMeasurer

Traffic Generator.

FIXME: Describe API.

ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
fail_if_no_traffic_forwarded()

Fail if no traffic forwarded.

Returns:nothing
Raises:Exception – If no traffic forwarded.
get_latency_int()

Return rounded min/avg/max latency.

Returns:Latency stats.
Return type:list
get_loss()

Return number of lost packets.

Returns:Number of lost packets.
Return type:str
get_received()

Return number of received packets.

Returns:Number of received packets.
Return type:str
get_sent()

Return number of sent packets.

Returns:Number of sent packets.
Return type:str
initialize_traffic_generator(tg_node, tg_if1, tg_if2, tg_if1_adj_node, tg_if1_adj_if, tg_if2_adj_node, tg_if2_adj_if, test_type, tg_if1_dst_mac=None, tg_if2_dst_mac=None)

TG initialization.

TODO: Document why do we need (and how do we use) _ifaces_reordered.

Parameters:
  • tg_node (dict) – Traffic generator node.
  • tg_if1 (str) – TG - name of first interface.
  • tg_if2 (str) – TG - name of second interface.
  • tg_if1_adj_node (dict) – TG if1 adjecent node.
  • tg_if1_adj_if (str) – TG if1 adjecent interface.
  • tg_if2_adj_node (dict) – TG if2 adjecent node.
  • tg_if2_adj_if (str) – TG if2 adjecent interface.
  • test_type (str) – ‘L2’, ‘L3’ or ‘L7’ - OSI Layer testing type.
  • tg_if1_dst_mac (str) – Interface 1 destination MAC address.
  • tg_if2_dst_mac (str) – Interface 2 destination MAC address.
Returns:

nothing

Raises:

RuntimeError – In case of issue during initialization.

static is_trex_running(node)

Check if TRex is running using pidof.

Parameters:node (dict) – Traffic generator node.
Returns:True if TRex is running otherwise False.
Return type:bool
Raises:RuntimeError – If node type is not a TG.
measure(duration, transmit_rate)

Run bi-directional measurement, parse and return results.

Parameters:
  • duration (float) – Trial duration [s].
  • transmit_rate (float) – Target bidirectional transmit rate [pps].
Returns:

Structure containing the result of the measurement.

Return type:

ReceiveRateMeasurement

Raises:
  • RuntimeError – If TG is not set, or if node is not TG, or if subtype is not specified.
  • NotImplementedError – If TG is not supported.
no_traffic_loss_occurred()

Fail if loss occurred in traffic run.

Returns:nothing
Raises:Exception – If loss occured.
node

Getter.

Returns:Traffic generator node.
Return type:dict
partial_traffic_loss_accepted(loss_acceptance, loss_acceptance_type)

Fail if loss is higher then accepted in traffic run.

Parameters:
  • loss_acceptance (float) – Permitted drop ratio or frames count.
  • loss_acceptance_type (LossAcceptanceType) – Type of permitted loss.
Returns:

nothing

Raises:

Exception – If loss is above acceptance criteria.

send_traffic_on_tg(duration, rate, frame_size, traffic_profile, warmup_time=5, async_call=False, latency=True, unidirection=False, tx_port=0, rx_port=1)

Send traffic from all configured interfaces on TG.

Note that bidirectional traffic also contains flows transmitted from rx_port and received in tx_port. But some tests use asymmetric traffic, so those arguments are relevant.

Also note that traffic generator uses DPDK driver which might reorder port numbers based on wiring and PCI numbering. This method handles that, so argument values are invariant, but you can see swapped valued in debug logs.

TODO: Is it better to have less descriptive argument names just to make them less probable to be viewed as misleading or confusing? See https://gerrit.fd.io/r/#/c/17625/11/resources/libraries/python /TrafficGenerator.py@406

Parameters:
  • duration (str) – Duration of test traffic generation in seconds.
  • rate (str) – Offered load per interface (e.g. 1%, 3gbps, 4mpps, ...).
  • frame_size (str) – Frame size (L2) in Bytes.
  • traffic_profile (str) – Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules.
  • warmup_time (float) – Warmup phase in seconds.
  • async_call (bool) – Async mode.
  • latency (bool) – With latency measurement.
  • unidirection (bool) – Traffic is unidirectional. Default: False
  • tx_port (int) – Traffic generator transmit port for first flow. Default: 0
  • rx_port (int) – Traffic generator receive port for first flow. Default: 1
Returns:

TG output.

Return type:

str

Raises:
  • RuntimeError – If TG is not set, or if node is not TG, or if subtype is not specified.
  • NotImplementedError – If TG is not supported.
set_rate_provider_defaults(frame_size, traffic_profile, warmup_time=0.0)

Store values accessed by measure().

Parameters:
  • frame_size (str or int) – Frame size identifier or value [B].
  • traffic_profile (str) – Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules.
  • warmup_time (float) – Traffic duration before measurement starts [s].
stop_traffic_on_tg()

Stop all traffic on TG.

Returns:Nothing
Raises:RuntimeError – If TG is not set.
static teardown_traffic_generator(node)

TG teardown.

Parameters:node (dict) – Traffic generator node.
Returns:nothing
Raises:RuntimeError – If node type is not a TG, or if TRex teardown fails.
trex_stl_start_remote_exec(duration, rate, frame_size, traffic_profile, async_call=False, latency=True, warmup_time=5.0, unidirection=False, tx_port=0, rx_port=1)

Execute script on remote node over ssh to start traffic.

Parameters:
  • duration (float) – Time expresed in seconds for how long to send traffic.
  • rate (str) – Traffic rate expressed with units (pps, %)
  • frame_size (str) – L2 frame size to send (without padding and IPG).
  • traffic_profile (str) – Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules.
  • async_call (bool) – If enabled then don’t wait for all incomming trafic.
  • latency (bool) – With latency measurement.
  • warmup_time (float) – Warmup time period.
  • unidirection (bool) – Traffic is unidirectional. Default: False
  • tx_port (int) – Traffic generator transmit port for first flow. Default: 0
  • rx_port (int) – Traffic generator receive port for first flow. Default: 1
Raises:

RuntimeError – In case of TG driver issue.

static trex_stl_stop_remote_exec(node)

Execute script on remote node over ssh to stop running traffic.

Parameters:node (dict) – TRex generator node.
Returns:Nothing
Raises:RuntimeError – If stop traffic script fails.
class resources.libraries.python.TrafficGenerator.OptimizedSearch

Bases: object

Class to be imported as Robot Library, containing a single keyword.

Setup initialized TG, perform optimized search, return intervals.

Parameters:
  • frame_size (str or int) – Frame size identifier or value [B].
  • traffic_profile (str) – Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules.
  • minimum_transmit_rate (float) – Minimal bidirectional target transmit rate [pps].
  • maximum_transmit_rate (float) – Maximal bidirectional target transmit rate [pps].
  • packet_loss_ratio (float) – Fraction of packets lost, for PDR [1].
  • final_relative_width (float) – Final lower bound transmit rate cannot be more distant that this multiple of upper bound [1].
  • final_trial_duration (float) – Trial duration for the final phase [s].
  • initial_trial_duration (float) – Trial duration for the initial phase and also for the first intermediate phase [s].
  • number_of_intermediate_phases (int) – Number of intermediate phases to perform before the final phase [1].
  • timeout (float) – The search will fail itself when not finished before this overall time [s].
  • doublings (int) – How many doublings to do in external search step. Default 1 is suitable for fairly stable tests, less stable tests might get better overal duration with 2 or more.
Returns:

Structure containing narrowed down NDR and PDR intervals and their measurements.

Return type:

NdrPdrResult

Raises:

RuntimeError – If total duration is larger than timeout.

Setup initialized TG, perform soak search, return avg and stdev.

Parameters:
  • frame_size (str or int) – Frame size identifier or value [B].
  • traffic_profile (str) – Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules.
  • minimum_transmit_rate (float) – Minimal bidirectional target transmit rate [pps].
  • maximum_transmit_rate (float) – Maximal bidirectional target transmit rate [pps].
  • plr_target (float) – Fraction of packets lost to achieve [1].
  • tdpt – Trial duration per trial. The algorithm linearly increases trial duration with trial number, this is the increment between succesive trials, in seconds.
  • initial_count (int) – Offset to apply before the first trial. For example initial_count=50 makes first trial to be 51*tdpt long. This is needed because initial “search” phase of integrator takes significant time even without any trial results.
  • timeout (float) – The search will stop after this overall time [s].
Returns:

Average and stdev of estimated bidirectional rate giving PLR.

Return type:

2-tuple of float

2.58. TrafficScriptArg suite

Traffic scripts argument parser library.

class resources.libraries.python.TrafficScriptArg.TrafficScriptArg(more_args=None, opt_args=None)

Bases: object

Traffic scripts argument parser.

Parse arguments for traffic script. Default has two arguments ‘–tx_if’ and ‘–rx_if’. You can provide more arguments. All arguments have string representation of the value. You can add also optional arguments. Default value for optional arguments is empty string.

Parameters:
  • more_args (list) – List of additional arguments (optional).
  • opt_args (list) – List of optional arguments (optional).
Example:
>>> from TrafficScriptArg import TrafficScriptArg
>>> args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip'])
get_arg(arg_name)

Get argument value.

Parameters:arg_name (str) – Argument name.
Returns:Argument value.
Return type:str

2.59. TrafficScriptExecutor suite

Traffic script executor library.

class resources.libraries.python.TrafficScriptExecutor.TrafficScriptExecutor

Bases: object

Traffic script executor utilities.

static run_traffic_script_on_node(script_file_name, node, script_args, timeout=60)

Run traffic script on the TG node.

Parameters:
  • script_file_name (str) – Traffic script name.
  • node (dict) – Node to run traffic script on.
  • script_args (str) – Traffic scripts arguments.
  • timeout (int) – Timeout (optional).
Raises:
  • RuntimeError – ICMP echo Rx timeout.
  • RuntimeError – DHCP REQUEST Rx timeout.
  • RuntimeError – DHCP DISCOVER Rx timeout.
  • RuntimeError – TCP/UDP Rx timeout.
  • RuntimeError – ARP reply timeout.
  • RuntimeError – Traffic script execution failed.
static traffic_script_gen_arg(rx_if, tx_if, src_mac, dst_mac, src_ip, dst_ip)

Generate traffic script basic arguments string.

Parameters:
  • rx_if (str) – Interface that receives traffic.
  • tx_if (str) – Interface that sends traffic.
  • src_mac (str) – Source MAC address.
  • dst_mac (str) – Destination MAC address.
  • src_ip (str) – Source IP address.
  • dst_ip (str) – Destination IP address.
Returns:

Traffic script arguments string.

Return type:

str

2.60. VPPUtil suite

2.61. VatExecutor suite

2.62. VatJsonUtil suite

Utilities to work with JSON data format from VAT.

class resources.libraries.python.VatJsonUtil.VatJsonUtil

Bases: object

Utilities to work with JSON data format from VAT.

static get_interface_mac_from_json(interface_dump_json, sw_if_index)

Get interface MAC address from given JSON output by sw_if_index.

Parameters:
  • interface_dump_json (str) – JSON output from dump_interface_list VAT command.
  • sw_if_index (int) – SW interface index.
Returns:

Interface MAC address.

Return type:

str

Raises:

ValueError – If interface not found in interface_dump_json.

static get_interface_name_from_json(interface_dump_json, sw_if_index)

Get interface name from given JSON output by sw_if_index.

Parameters:
  • interface_dump_json (str) – JSON output from dump_interface_list VAT command.
  • sw_if_index (int) – SW interface index.
Returns:

Interface name.

Return type:

str

Raises:

ValueError – If interface not found in interface_dump_json.

static get_interface_sw_index_from_json(interface_dump_json, interface_name)

Get sw_if_index from given JSON output by interface name.

Parameters:
  • interface_dump_json (str) – JSON output from dump_interface_list VAT command.
  • interface_name (str) – Interface name.
Returns:

SW interface index.

Return type:

int

Raises:

ValueError – If interface not found in interface_dump_json.

static get_vpp_interface_by_mac(interfaces_list, mac_address)

Return interface dictionary from interface_list by MAC address.

Extracts interface dictionary from all of the interfaces in interfaces list parsed from JSON according to mac_address of the interface.

Parameters:
  • interfaces_list (dict) – Interfaces parsed from JSON.
  • mac_address (str) – MAC address of interface we are looking for.
Returns:

Interface from JSON.

Return type:

dict

static update_vpp_interface_data_from_json(node, interface_dump_json)

Update vpp node data in node__DICT from JSON interface dump.

This method updates vpp interface names and sw if indexes according to interface MAC addresses found in interface_dump_json.

Parameters:
  • node (dict) – Node dictionary.
  • interface_dump_json (str) – JSON output from dump_interface_list VAT command.
static verify_vat_retval(vat_out, exp_retval=0, err_msg='VAT cmd failed')

Verify return value of VAT command.

VAT command JSON output should be object (dict in python) or array. We are looking for something like this: { “retval”: 0 }. Verification is skipped if VAT output does not contain return value element or root elemet is array.

Parameters:
  • vat_out (dict or list) – VAT command output in python representation of JSON.
  • exp_retval (int) – Expected return value (default 0).
Err_msg:

Message to be displayed in case of error (optional).

Raises:

RuntimeError – If VAT command return value is incorrect.

2.63. VhostUser suite

2.64. VppConfigGenerator suite

VPP Configuration File Generator library.

class resources.libraries.python.VppConfigGenerator.VppConfigGenerator

Bases: object

VPP Configuration File Generator.

add_api_segment_api_size(value)

Add API-SEGMENT api-size configuration.

Parameters:value (str) – API size.
add_api_segment_gid(value='vpp')

Add API-SEGMENT gid configuration.

Parameters:value (str) – Gid.
add_api_segment_global_size(value)

Add API-SEGMENT global-size configuration.

Parameters:value (str) – Global size.
add_api_trace()

Add API trace configuration.

add_buffers_per_numa(value)

Increase number of buffers allocated.

Parameters:value (int) – Number of buffers allocated.
add_config_item(config, value, path)

Add startup configuration item.

Parameters:
  • config (dict) – Startup configuration of node.
  • value (str) – Value to insert.
  • path (list) – Path where to insert item.
add_cpu_corelist_workers(value)

Add CPU corelist-workers configuration.

Parameters:value (str) – Corelist-workers option.
add_cpu_main_core(value)

Add CPU main core configuration.

Parameters:value (str) – Main core option.
add_dpdk_cryptodev(count)

Add DPDK Crypto PCI device configuration.

Parameters:count (int) – Number of HW crypto devices to add.
add_dpdk_dev(*devices)

Add DPDK PCI device configuration.

Parameters:devices (tuple) – PCI device(s) (format xxxx:xx:xx.x)
add_dpdk_dev_default_rxd(value)

Add DPDK dev default rxd configuration.

Parameters:value (str) – Default number of rxds.
add_dpdk_dev_default_rxq(value)

Add DPDK dev default rxq configuration.

Parameters:value (str) – Default number of rxqs.
add_dpdk_dev_default_txd(value)

Add DPDK dev default txd configuration.

Parameters:value (str) – Default number of txds.
add_dpdk_dev_default_txq(value)

Add DPDK dev default txq configuration.

Parameters:value (str) – Default number of txqs.
add_dpdk_dev_parameter(device, parameter, value)

Add parameter for DPDK device.

Parameters:
  • device (str) – PCI device (format xxxx:xx:xx.x).
  • parameter (str) – Parameter name.
  • value (str) – Parameter value.
add_dpdk_eth_bond_dev(ethbond_id, mode, xmit_policy, *slaves)

Add DPDK Eth_bond device configuration.

Parameters:
  • ethbond_id (str or int) – Eth_bond device ID.
  • mode (str or int) – Link bonding mode.
  • xmit_policy (str) – Transmission policy.
  • slaves (list) – PCI device(s) to be bonded (format xxxx:xx:xx.x).
add_dpdk_log_level(value)

Add DPDK log-level configuration.

Parameters:value (str) – Log level.
add_dpdk_no_multi_seg()

Add DPDK no-multi-seg configuration.

add_dpdk_no_pci()

Add DPDK no-pci.

add_dpdk_no_tx_checksum_offload()

Add DPDK no-tx-checksum-offload configuration.

add_dpdk_sw_cryptodev(sw_pmd_type, socket_id, count)

Add DPDK SW Crypto device configuration.

Parameters:
  • sw_pmd_type (str) – Type of SW crypto device PMD to add.
  • socket_id (int) – Socket ID.
  • count (int) – Number of SW crypto devices to add.
add_dpdk_uio_driver(value=None)

Add DPDK uio-driver configuration.

Parameters:value (str) – DPDK uio-driver configuration. By default, driver will be loaded automatically from Topology file, still leaving option to manually override by parameter.
add_heapsize(value)

Add Heapsize configuration.

Parameters:value (str) – Amount of heapsize.
add_ip6_hash_buckets(value)

Add IP6 hash buckets configuration.

Parameters:value (str) – Number of IP6 hash buckets.
add_ip6_heap_size(value)

Add IP6 heap-size configuration.

Parameters:value (str) – IP6 Heapsize amount.
add_ip_heap_size(value)

Add IP heap-size configuration.

Parameters:value (str) – IP Heapsize amount.
add_nat(value='deterministic')

Add NAT configuration.

Parameters:value (str) – NAT mode.
add_plugin(state, *plugins)

Add plugin section for specific plugin(s).

Parameters:
  • state (str) – State of plugin [enable|disable].
  • plugins (list) – Plugin(s) to disable.
add_session_event_queue_length(value)

Add session event queue length.

Parameters:value (int) – Session event queue length.
add_session_local_endpoints_table_buckets(value)

Add the number of local endpoints table buckets.

Parameters:value (int) – Number of local endpoints table buckets.
add_session_local_endpoints_table_memory(value)

Add the size of local endpoints table memory.

Parameters:value (str) – Size of local endpoints table memory.
add_session_preallocated_sessions(value)

Add the number of pre-allocated sessions.

Parameters:value (int) – Number of pre-allocated sessions.
add_session_v4_halfopen_table_buckets(value)

Add the number of v4 halfopen table buckets.

Parameters:value (int) – Number of v4 halfopen table buckets.
add_session_v4_halfopen_table_memory(value)

Add the size of v4 halfopen table memory.

Parameters:value (str) – Size of v4 halfopen table memory.
add_session_v4_session_table_buckets(value)

Add number of v4 session table buckets to the config.

Parameters:value (int) – Number of v4 session table buckets.
add_session_v4_session_table_memory(value)

Add the size of v4 session table memory.

Parameters:value (str) – Size of v4 session table memory.
add_statseg_size(value)

Add stats segment heap size configuration.

Parameters:value (str) – Stats heapsize amount.
add_tcp_preallocated_connections(value)

Add TCP pre-allocated connections.

Parameters:value (int) – The number of pre-allocated connections.
add_tcp_preallocated_half_open_connections(value)

Add TCP pre-allocated half open connections.

Parameters:value (int) – The number of pre-allocated half open connections.
add_unix_cli_listen(value='/run/vpp/cli.sock')

Add UNIX cli-listen configuration.

Parameters:value (str) – CLI listen address and port or path to CLI socket.
add_unix_coredump()

Add UNIX full-coredump configuration.

add_unix_exec(value)

Add UNIX exec configuration.

add_unix_gid(value='vpp')

Add UNIX gid configuration.

Parameters:value (str) – Gid.
add_unix_log(value=None)

Add UNIX log configuration.

Parameters:value (str) – Log file.
add_unix_nodaemon()

Add UNIX nodaemon configuration.

apply_config(filename=None, retries=60, restart_vpp=True)

Generate and apply VPP configuration for node.

Use data from calls to this class to form a startup.conf file and replace /etc/vpp/startup.conf with it on node.

Parameters:
  • filename (str) – Startup configuration file name.
  • retries (int) – Number of times (default 60) to re-try waiting.
  • restart_vpp (bool.) – Whether to restart VPP.
Raises:

RuntimeError – If writing config file failed or restart of VPP failed or backup of VPP startup.conf failed.

dump_config(obj, level=-1)

Dump the startup configuration in VPP config format.

Parameters:
  • obj (Obj) – Python Object to print.
  • level (int) – Nested level for indentation.
Returns:

nothing

get_config_str()

Get dumped startup configuration in VPP config format.

Returns:Startup configuration in VPP config format.
Return type:str
restore_config()

Restore VPP startup.conf from backup.

Raises:RuntimeError – When restoration of startup.conf file failed.
set_node(node)

Set DUT node.

Parameters:node (dict) – Node to store configuration on.
Raises:RuntimeError – If Node type is not DUT.
set_vpp_logfile(logfile)

Set VPP logfile location.

Parameters:logfile (str) – VPP logfile location.
set_vpp_startup_conf_backup(backup='/etc/vpp/startup.backup')

Set VPP startup configuration backup.

Parameters:backup (str) – VPP logfile location.

2.65. VppCounters suite

2.66. ssh suite

Library for SSH connection management.

resources.libraries.python.ssh.exec_cmd(node, cmd, timeout=600, sudo=False)

Convenience function to ssh/exec/return rc, out & err.

Returns (rc, stdout, stderr).

Parameters:
  • node (dict) – The node to execute command on.
  • cmd (str) – Command to execute.
  • timeout (int) – Timeout value in seconds. Default: 600.
  • sudo (bool) – Sudo privilege execution flag. Default: False.
Returns:

RC, Stdout, Stderr.

Return type:

tuple(int, str, str)

resources.libraries.python.ssh.exec_cmd_no_error(node, cmd, timeout=600, sudo=False, message=None)

Convenience function to ssh/exec/return out & err.

Verifies that return code is zero.

Parameters:
  • node (dict) – DUT node.
  • cmd (str) – Command to be executed.
  • timeout (int) – Timeout value in seconds. Default: 600.
  • sudo (bool) – Sudo privilege execution flag. Default: False.
  • message (str) – Error message in case of failure. Default: None.
Returns:

Stdout, Stderr.

Return type:

tuple(str, str)

Raises:

RuntimeError – If bash return code is not 0.

2.67. tcp suite

2.68. topology suite

Defines nodes and topology structure.

class resources.libraries.python.topology.Topology

Bases: object

Topology data manipulation and extraction methods.

Defines methods used for manipulation and extraction of data from the active topology.

“Active topology” contains initially data from the topology file and can be extended with additional data from the DUTs like internal interface indexes or names. Additional data which can be filled to the active topology are

  • additional internal representation (index, name, ...)
  • operational data (dynamic ports)

To access the port data it is recommended to use a port key because the key does not rely on the data retrieved from nodes, this allows to call most of the methods without having filled active topology with internal nodes data.

static add_new_port(node, ptype)

Add new port to the node to active topology.

Parameters:
  • node (dict) – Node to add new port on.
  • ptype (str) – Port type, used as key prefix.
Returns:

Port key or None

Return type:

string or None

static convert_interface_reference(node, interface, wanted_format)

Takes interface reference in any format (name, link name, topology key or sw_if_index) and returns its equivalent in the desired format.

Parameters:
  • node (dict) – Node in topology.
  • interface (str or int) – Name, sw_if_index, link name or key of an interface on the node.
  • wanted_format (str) – Format of return value wanted. Valid options are: sw_if_index, key, name.
Returns:

Interface name, interface key or sw_if_index.

Return type:

str or int

Raises:
  • TypeError, ValueError – If provided with invalid arguments.
  • RuntimeError – If the interface does not exist in topology.
static convert_interface_reference_to_key(node, interface)

Takes interface reference in any format (name, link name, interface key or sw_if_index) and converts to interface key using Topology methods.

Parameters:
  • node (dict) – Node in topology.
  • interface (str or int) – Name, sw_if_index, link name or key of an interface on the node.
Returns:

Interface key.

Return type:

str

Raises:
  • TypeError – If provided with invalid interface argument.
  • RuntimeError – If the interface does not exist in topology.

Return list of link names that connect together node1 and node2.

Parameters:
  • node1 (dict) – Node topology dictionary.
  • node2 (dict) – Node topology dictionary.
  • filter_list_node1 (list of strings) – Link filter criteria for node1.
  • filter_list_node2 (list of strings) – Link filter criteria for node2.
Returns:

List of strings that represent connecting link names.

Return type:

list

static get_adjacent_node_and_interface(nodes_info, node, iface_key)

Get node and interface adjacent to specified interface on local network.

Parameters:
  • nodes_info (dict) – Dictionary containing information on all nodes in topology.
  • node (dict) – Node that contains specified interface.
  • iface_key (str) – Interface key from topology file.
Returns:

Return (node, interface_key) tuple or None if not found.

Return type:

(dict, str)

static get_cryptodev(node)

Return Crytodev configuration of the node.

Parameters:node (dict) – Node created from topology.
Returns:Cryptodev configuration string.
Return type:str
get_egress_interfaces_name_for_nodes(node1, node2)

Get egress interfaces on node1 for link with node2.

Parameters:
  • node1 (dict) – First node, node to get egress interface on.
  • node2 (dict) – Second node.
Returns:

Egress interfaces.

Return type:

list

Parameters:
  • node1 (dict) – Connected node.
  • node2 (dict) – Connected node.
Returns:

Name of a link connecting the two nodes together.

Return type:

str

Raises:

RuntimeError – If no links are found.

get_first_egress_interface_for_nodes(node1, node2)

Get first egress interface on node1 for link with node2.

Parameters:
  • node1 (dict) – First node, node to get egress interface name on.
  • node2 (dict) – Second node.
Returns:

Egress interface name.

Return type:

str

Return interface key of link on node.

This method returns the interface name associated with a given link for a given node.

Parameters:
  • node (dict) – The node topology dictionary.
  • link_name (string) – Name of the link that a interface is connected to.
Returns:

Interface key of the interface connected to the given link.

Return type:

str

static get_interface_by_name(node, iface_name)

Return interface key based on name from DUT/TG.

This method returns interface key based on interface name retrieved from the DUT, or TG.

Parameters:
  • node (dict) – The node topology dictionary.
  • iface_name (string) – Interface name (string form).
Returns:

Interface key.

Return type:

str

static get_interface_by_sw_index(node, sw_index)

Return interface name of link on node.

This method returns the interface name associated with a software interface index assigned to the interface by vpp for a given node.

Parameters:
  • node (dict) – The node topology dictionary.
  • sw_index (int) – Sw_index of the link that a interface is connected to.
Returns:

Interface name of the interface connected to the given link.

Return type:

str

static get_interface_driver(node, iface_key)

Get interface driver.

Parameters:
  • node (dict) – Node to get interface driver on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return interface driver or None if not found.

static get_interface_ip4(node, iface_key)

Get IP4 address for the interface.

Parameters:
  • node (dict) – Node to get interface mac on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return IP4 or None if not found.

static get_interface_mac(node, iface_key)

Get MAC address for the interface.

Parameters:
  • node (dict) – Node to get interface mac on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return MAC or None if not found.

static get_interface_mtu(node, iface_key)

Get interface MTU.

Returns physical layer MTU (max. size of Ethernet frame). :param node: Node to get interface MTU on. :param iface_key: Interface key from topology file. :type node: dict :type iface_key: str :returns: MTU or None if not found. :rtype: int

static get_interface_name(node, iface_key)

Get interface name (retrieved from DUT/TG).

Returns name in string format, retrieved from the node. :param node: Node to get interface name on. :param iface_key: Interface key from topology file. :type node: dict :type iface_key: str :returns: Interface name or None if not found. :rtype: str

static get_interface_numa_node(node, iface_key)

Get interface numa node.

Returns physical relation to numa node, numa_id.

Parameters:
  • node (dict) – Node to get numa id on.
  • iface_key (str) – Interface key from topology file.
Returns:

numa node id, None if not available.

Return type:

int

static get_interface_pci_addr(node, iface_key)

Get interface PCI address.

Parameters:
  • node (dict) – Node to get interface PCI address on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return PCI address or None if not found.

static get_interface_sw_index(node, iface_key)

Get VPP sw_if_index for the interface using interface key.

Parameters:
  • node (dict) – Node to get interface sw_if_index on.
  • iface_key (str/int) – Interface key from topology file, or sw_index.
Returns:

Return sw_if_index or None if not found.

Return type:

int or None

static get_interface_sw_index_by_name(node, iface_name)

Get VPP sw_if_index for the interface using interface name.

Parameters:
  • node (dict) – Node to get interface sw_if_index on.
  • iface_name (str) – Interface name.
Returns:

Return sw_if_index or None if not found.

Raises:

TypeError – If provided interface name is not a string.

Return dictionary of dictionaries {“interfaceN”, interface name}.

This method returns the interface names associated with given links for a given node.

Parameters:
  • node (dict) – The node topology directory.
  • link_names (list) – List of names of the link that a interface is connected to.
Returns:

Dictionary of interface names that are connected to the given links.

Return type:

dict

static get_interfaces_numa_node(node, *iface_keys)

Get numa node on which are located most of the interfaces.

Return numa node with highest count of interfaces provided as arguments. Return 0 if the interface does not have numa_node information available. If all interfaces have unknown location (-1), then return 0. If most of interfaces have unknown location (-1), but there are some interfaces with known location, then return the second most location of the provided interfaces.

Parameters:
  • node (dict) – Node from DICT__nodes.
  • iface_keys (strings) – Interface keys for lookup.
Returns:

Numa node of most given interfaces or 0.

Return type:

int

Get list of links(networks) in the topology.

Parameters:nodes (dict) – Nodes of the test topology.
Returns:Links in the topology.
Return type:list

Return link combinations used in tests in circular topology.

For the time being it returns links from the Node path: TG->DUT1->DUT2->TG The naming convention until changed to something more general is implemented is this: DUT1_DUT2_LINK: link name between DUT! and DUT2 DUT1_TG_LINK: link name between DUT1 and TG DUT2_TG_LINK: link name between DUT2 and TG TG_TRAFFIC_LINKS: list of link names that generated traffic is sent to and from DUT1_BD_LINKS: list of link names that will be connected by the bridge domain on DUT1 DUT2_BD_LINKS: list of link names that will be connected by the bridge domain on DUT2

Parameters:
  • tgen (dict) – Traffic generator node data.
  • dut1 (dict) – DUT1 node data.
  • dut2 (dict) – DUT2 node data.
Returns:

Dictionary of possible link combinations.

Return type:

dict

static get_node_arch(node)
Return arch of the node.
Default to x86_64 if no arch present
Parameters:node (dict) – Node created from topology.
Returns:Node architecture
Return type:str
static get_node_by_hostname(nodes, hostname)

Get node from nodes of the topology by hostname.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • hostname (str) – Host name.
Returns:

Node dictionary or None if not found.

static get_node_hostname(node)

Return host (hostname/ip address) of the node.

Parameters:node (dict) – Node created from topology.
Returns:Hostname or IP address.
Return type:str
static get_node_interfaces(node)

Get all node interfaces.

Parameters:node (dict) – Node to get list of interfaces from.
Returns:Return list of keys of all interfaces.
Return type:list

Return interface mac address by link name.

Parameters:
  • node (dict) – Node to get interface sw_index on.
  • link_name (str) – Link name.
Returns:

MAC address string.

Return type:

str

static get_uio_driver(node)

Return uio-driver configuration of the node.

Parameters:node (dict) – Node created from topology.
Returns:uio-driver configuration string.
Return type:str
static is_tg_node(node)

Find out whether the node is TG.

Parameters:node (dict) – Node to examine.
Returns:True if node is type of TG, otherwise False.
Return type:bool
static remove_all_added_ports_on_all_duts_from_topology(nodes)

Remove all added ports on all DUT nodes in the topology.

Parameters:nodes (dict) – Nodes in the topology.
Returns:Nothing
static remove_all_ports(node, ptype)

Remove all ports with ptype as prefix.

Parameters:node (dict) – Node to remove ports on.
Param:ptype: Port type, used as key prefix.
Returns:Nothing
static remove_port(node, iface_key)

Remove required port from active topology.

Parameters:node (dict) – Node to remove port on.
Param:iface_key: Topology key of the interface.
Returns:Nothing
static set_interface_numa_node(node, iface_key, numa_node_id)

Set interface numa_node location.

Parameters:
  • node (dict) – Node to set numa_node on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return iface_key or None if not found.

static update_interface_mac_address(node, iface_key, mac_address)

Update mac_address on the interface from the node.

Parameters:
  • node (dict) – Node to update MAC on.
  • iface_key (str) – Topology key of the interface.
  • mac_address (str) – MAC address.
static update_interface_memif_id(node, iface_key, memif_id)

Update memif ID on the interface from the node.

Parameters:
  • node (dict) – Node to update memif ID on.
  • iface_key (str) – Topology key of the interface.
  • memif_id (str) – Memif interface ID.
static update_interface_memif_role(node, iface_key, memif_role)

Update memif role on the interface from the node.

Parameters:
  • node (dict) – Node to update memif role on.
  • iface_key (str) – Topology key of the interface.
  • memif_role (str) – Memif role.
static update_interface_memif_socket(node, iface_key, memif_socket)

Update memif socket name on the interface from the node.

Parameters:
  • node (dict) – Node to update socket name on.
  • iface_key (str) – Topology key of the interface.
  • memif_socket (str) – Path to named socket on node.
static update_interface_name(node, iface_key, name)

Update name on the interface from the node.

Parameters:
  • node (dict) – Node to update name on.
  • iface_key (str) – Topology key of the interface.
  • name (str) – Interface name to store.
static update_interface_pci_address(node, iface_key, pci_address)

Update pci_address on the interface from the node.

Parameters:
  • node (dict) – Node to update PCI on.
  • iface_key (str) – Topology key of the interface.
  • pci_address (str) – PCI address.
static update_interface_sw_if_index(node, iface_key, sw_if_index)

Update sw_if_index on the interface from the node.

Parameters:
  • node (dict) – Node to update sw_if_index on.
  • iface_key (str) – Topology key of the interface.
  • sw_if_index (int) – Internal index to store.
static update_interface_tap_dev_name(node, iface_key, dev_name)

Update device name on the tap interface from the node.

Parameters:
  • node (dict) – Node to update tap device name on.
  • iface_key (str) – Topology key of the interface.
  • dev_name (str) – Device name of the tap interface.
Returns:

Nothing

static update_interface_vhost_socket(node, iface_key, vhost_socket)

Update vhost socket name on the interface from the node.

Parameters:
  • node (dict) – Node to update socket name on.
  • iface_key (str) – Topology key of the interface.
  • vhost_socket (str) – Path to named socket on node.
class resources.libraries.python.topology.NodeType

Bases: object

Defines node types used in topology dictionaries.

DUT = 'DUT'
TG = 'TG'
VM = 'VM'