aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2018-05-14 13:22:42 +0200
committerPeter Mikus <pmikus@cisco.com>2018-06-08 07:44:26 +0000
commit28b344a6ade7624278835cff242b3e0c9d891346 (patch)
treec191837a72b62ea1a70b5b007890530c32b6f3b0 /resources/libraries
parent5b9b416f2f073a4102f3dc5ba219c81505e092ed (diff)
CSIT-1081 Container VPP configuration refactor
Adopt code for various topology configurations. Change-Id: Iaf9d7995ab8cd06da0c56c5e5664d57d19e74d7c Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries')
-rw-r--r--resources/libraries/python/ContainerUtils.py117
-rw-r--r--resources/libraries/python/Memif.py15
-rw-r--r--resources/libraries/robot/performance/performance_configuration.robot92
-rw-r--r--resources/libraries/robot/shared/container.robot3
-rw-r--r--resources/libraries/robot/shared/memif.robot30
5 files changed, 220 insertions, 37 deletions
diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py
index 4d5f8ee4d6..5e1ab5ab4f 100644
--- a/resources/libraries/python/ContainerUtils.py
+++ b/resources/libraries/python/ContainerUtils.py
@@ -21,6 +21,7 @@ from collections import OrderedDict, Counter
from resources.libraries.python.ssh import SSH
from resources.libraries.python.constants import Constants
from resources.libraries.python.CpuUtils import CpuUtils
+from resources.libraries.python.topology import Topology
from resources.libraries.python.VppConfigGenerator import VppConfigGenerator
@@ -162,33 +163,68 @@ class ContainerManager(object):
self.engine.container = self.containers[container]
self.engine.restart_vpp()
- def configure_vpp_in_all_containers(self, vat_template_file):
+ def configure_vpp_in_all_containers(self, chain_topology,
+ dut1_if=None, dut2_if=None):
"""Configure VPP in all containers.
- :param vat_template_file: Template file name of a VAT script.
- :type vat_template_file: str
+ :param chain_topology: 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).
+ :param dut1_if: Interface on DUT1 directly connected to DUT2.
+ :param dut2_if: Interface on DUT2 directly connected to DUT1.
+ :type container_topology: str
+ :type dut1_if: str
+ :type dut2_if: str
"""
# Count number of DUTs based on node's host information
dut_cnt = len(Counter([self.containers[container].node['host']
for container in self.containers]))
- container_cnt = len(self.containers)
- mod = container_cnt/dut_cnt
-
- for i, container in enumerate(self.containers):
- mid1 = i % mod + 1
- mid2 = i % mod + 1
- sid1 = i % mod * 2 + 1
- sid2 = i % mod * 2 + 2
- self.engine.container = self.containers[container]
- self.engine.create_vpp_startup_config()
- self.engine.create_vpp_exec_config(vat_template_file, mid1=mid1,
- mid2=mid2, sid1=sid1, sid2=sid2,
- socket1='memif-{c.name}-{sid}'
- .format(c=self.engine.container,
- sid=sid1),
- socket2='memif-{c.name}-{sid}'
- .format(c=self.engine.container,
- sid=sid2))
+ mod = len(self.containers)/dut_cnt
+ container_vat_template = 'memif_create_{topology}.vat'.format(
+ topology=chain_topology)
+
+ if chain_topology == 'chain':
+ for i, container in enumerate(self.containers):
+ mid1 = i % mod + 1
+ mid2 = i % mod + 1
+ sid1 = i % mod * 2 + 1
+ sid2 = i % mod * 2 + 2
+ self.engine.container = self.containers[container]
+ self.engine.create_vpp_startup_config()
+ self.engine.create_vpp_exec_config(container_vat_template, \
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2, \
+ socket1='memif-{c.name}-{sid}'. \
+ format(c=self.engine.container, sid=sid1), \
+ socket2='memif-{c.name}-{sid}'. \
+ format(c=self.engine.container, sid=sid2))
+ elif chain_topology == 'cross_horiz':
+ if mod > 1:
+ raise RuntimeError('Container chain topology {topology} '
+ 'supports only single container.'.
+ format(topology=chain_topology))
+ for i, container in enumerate(self.containers):
+ mid1 = i % mod + 1
+ sid1 = i % mod * 2 + 1
+ self.engine.container = self.containers[container]
+ if 'DUT1' in self.engine.container.name:
+ if_pci = Topology.get_interface_pci_addr( \
+ self.engine.container.node, dut1_if)
+ if_name = Topology.get_interface_name( \
+ self.engine.container.node, dut1_if)
+ if 'DUT2' in self.engine.container.name:
+ if_pci = Topology.get_interface_pci_addr( \
+ self.engine.container.node, dut2_if)
+ if_name = Topology.get_interface_name( \
+ self.engine.container.node, dut2_if)
+ self.engine.create_vpp_startup_config_dpdk_dev(if_pci)
+ self.engine.create_vpp_exec_config(container_vat_template, \
+ mid1=mid1, sid1=sid1, if_name=if_name, \
+ socket1='memif-{c.name}-{sid}'. \
+ format(c=self.engine.container, sid=sid1))
+ else:
+ raise RuntimeError('Container topology {topology} not implemented'.
+ format(topology=chain_topology))
def stop_all_containers(self):
"""Stop all containers."""
@@ -310,12 +346,11 @@ class ContainerEngine(object):
self.execute('supervisorctl restart vpp')
self.execute('cat /tmp/supervisord.log')
- def create_vpp_startup_config(self,
- config_filename='/etc/vpp/startup.conf'):
+ def create_base_vpp_startup_config(self):
"""Create base startup configuration of VPP on container.
- :param config_filename: Startup configuration file name.
- :type config_filename: str
+ :returns: Base VPP startup configuration.
+ :rtype: VppConfigGenerator
"""
cpuset_cpus = self.container.cpuset_cpus
@@ -331,12 +366,38 @@ class ContainerEngine(object):
if cpuset_cpus:
corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
vpp_config.add_cpu_corelist_workers(corelist_workers)
+
+ return vpp_config
+
+ def create_vpp_startup_config(self):
+ """Create startup configuration of VPP without DPDK on container.
+ """
+ vpp_config = self.create_base_vpp_startup_config()
vpp_config.add_plugin('disable', 'dpdk_plugin.so')
+ # Apply configuration
+ self.execute('mkdir -p /etc/vpp/')
+ self.execute('echo "{config}" | tee /etc/vpp/startup.conf'
+ .format(config=vpp_config.get_config_str()))
+
+ def create_vpp_startup_config_dpdk_dev(self, *devices):
+ """Create startup configuration of VPP with DPDK on container.
+
+ :param devices: List of PCI devices to add.
+ :type devices: list
+ """
+ vpp_config = self.create_base_vpp_startup_config()
+ vpp_config.add_dpdk_dev(*devices)
+ vpp_config.add_dpdk_no_tx_checksum_offload()
+ vpp_config.add_dpdk_log_level('debug')
+ vpp_config.add_plugin('disable', 'default')
+ vpp_config.add_plugin('enable', 'dpdk_plugin.so')
+ vpp_config.add_plugin('enable', 'memif_plugin.so')
+
+ # Apply configuration
self.execute('mkdir -p /etc/vpp/')
- self.execute('echo "{c}" | tee {f}'
- .format(c=vpp_config.get_config_str(),
- f=config_filename))
+ self.execute('echo "{config}" | tee /etc/vpp/startup.conf'
+ .format(config=vpp_config.get_config_str()))
def create_vpp_exec_config(self, vat_template_file, **kwargs):
"""Create VPP exec configuration on container.
diff --git a/resources/libraries/python/Memif.py b/resources/libraries/python/Memif.py
index b4c184e1be..acde3ecc17 100644
--- a/resources/libraries/python/Memif.py
+++ b/resources/libraries/python/Memif.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2017 Cisco and/or its affiliates.
+# Copyright (c) 2018 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -15,7 +15,7 @@
from resources.libraries.python.ssh import SSH
from resources.libraries.python.VatExecutor import VatExecutor, VatTerminal
-from resources.libraries.python.topology import Topology
+from resources.libraries.python.topology import NodeType, Topology
class Memif(object):
@@ -99,6 +99,17 @@ class Memif(object):
vat.execute_script("show_memif.vat", node, json_out=False)
@staticmethod
+ def show_memif_on_all_duts(nodes):
+ """Show Memif data on all DUTs.
+
+ :param nodes: Topology nodes.
+ :type nodes: dict
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ Memif.show_memif(node)
+
+ @staticmethod
def clear_memif_socks(node, *socks):
"""Clear Memif sockets for the given node.
diff --git a/resources/libraries/robot/performance/performance_configuration.robot b/resources/libraries/robot/performance/performance_configuration.robot
index 0eb4e612df..c2f591ad0c 100644
--- a/resources/libraries/robot/performance/performance_configuration.robot
+++ b/resources/libraries/robot/performance/performance_configuration.robot
@@ -1712,6 +1712,18 @@
| | Set Test Variable | ${dut2_if1_pci}
| | Set Test Variable | ${dut2_if2_pci}
+| Add single PCI device to DUTs in 3-node single link topology
+| | [Documentation]
+| | ... | Add single (first) PCI device on DUT1 to VPP configuration file.
+| | ... | Add single (last) PCI device on DUT2 to VPP configuration file.
+| | ...
+| | ${dut1_if1_pci}= | Get Interface PCI Addr | ${dut1} | ${dut1_if1}
+| | ${dut2_if2_pci}= | Get Interface PCI Addr | ${dut2} | ${dut2_if2}
+| | Run keyword | DUT1.Add DPDK Dev | ${dut1_if1_pci}
+| | Run keyword | DUT2.Add DPDK Dev | ${dut2_if2_pci}
+| | Set Test Variable | ${dut1_if1_pci}
+| | Set Test Variable | ${dut2_if2_pci}
+
| Add PCI devices to DUTs in 2-node single link topology
| | [Documentation]
| | ... | Add PCI devices to VPP configuration file.
@@ -1722,6 +1734,14 @@
| | Set Test Variable | ${dut1_if1_pci}
| | Set Test Variable | ${dut1_if2_pci}
+| Add single PCI device to DUTs in 2-node single link topology
+| | [Documentation]
+| | ... | Add single (first) PCI device on DUT1 to VPP configuration file.
+| | ...
+| | ${dut1_if1_pci}= | Get Interface PCI Addr | ${dut1} | ${dut1_if1}
+| | Run keyword | DUT1.Add DPDK Dev | ${dut1_if1_pci}
+| | Set Test Variable | ${dut1_if1_pci}
+
| Add VLAN Strip Offload switch off between DUTs in 3-node single link topology
| | [Documentation]
| | ... | Add VLAN Strip Offload switch off on PCI devices between DUTs to VPP
@@ -2504,9 +2524,7 @@
| | | Run Keyword If | ${number}==${nr} | Configure L2XC
| | | ... | ${dut2} | ${dut2-memif-${number}-if2} | ${dut2_if2}
| | All Vpp Interfaces Ready Wait | ${nodes}
-| | ${duts}= | Get Matches | ${nodes} | DUT*
-| | :FOR | ${dut} | IN | @{duts}
-| | | Show Memif | ${nodes['${dut}']}
+| | Show Memif on all DUTs | ${nodes}
| Initialize L2 Bridge Domain for '${nr}' memif pairs and '${rxq}' rxqueues in 3-node circular topology
| | [Documentation]
@@ -2552,6 +2570,68 @@
| | | Add interface to bridge domain | ${dut2}
| | | ... | ${dut2-memif-${number}-if2} | ${bd_id2}
| | All Vpp Interfaces Ready Wait | ${nodes}
-| | ${duts}= | Get Matches | ${nodes} | DUT*
-| | :FOR | ${dut} | IN | @{duts}
-| | | Show Memif | ${nodes['${dut}']}
+| | Show Memif on all DUTs | ${nodes}
+
+| Initialize L2 xconnect for single memif in 3-node circular topology
+| | [Documentation]
+| | ... | Create single Memif interface on all defined VPP nodes. Cross
+| | ... | connect Memif interface with one physical interface.
+| | ...
+| | ... | *Arguments:*
+| | ... | - ${rxq} - Number of Memif RX queues. Type: integer
+| | ... | - ${number} - Memif ID. Type: integer
+| | ...
+| | ... | *Note:*
+| | ... | Socket paths for Memif are defined in following format:
+| | ... | - /tmp/memif-DUT1_VNF${number}-${sid}
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Initialize L2 xconnect for single memif in 3-node circular \
+| | ... | topology \| 1 \| 1 \|
+| | ...
+| | [Arguments] | ${rxq}=${1} | ${number}=${1}
+| | ${sock}= | Set Variable | memif-DUT1_VNF
+| | Set up single memif interface on DUT node | ${dut1} | ${sock}
+| | ... | ${number} | dut1-memif-${number}-if1 | ${rxq} | ${rxq}
+| | Configure L2XC | ${dut1} | ${dut1_if1} | ${dut1-memif-${number}-if1}
+| | ${sock}= | Set Variable | memif-DUT2_VNF
+| | Set up single memif interface on DUT node | ${dut2} | ${sock}
+| | ... | ${number} | dut2-memif-${number}-if1 | ${rxq} | ${rxq}
+| | Configure L2XC | ${dut2} | ${dut2_if2} | ${dut2-memif-${number}-if1}
+| | All Vpp Interfaces Ready Wait | ${nodes}
+| | Show Memif on all DUTs | ${nodes}
+
+| Initialize L2 Bridge Domain for single memif in 3-node circular topology
+| | [Documentation]
+| | ... | Create single Memif interface on all defined VPP nodes. Put Memif
+| | ... | interface to separate L2 bridge domain with one physical interface.
+| | ...
+| | ... | *Arguments:*
+| | ... | - ${rxq} - Number of Memif RX queues. Type: integer
+| | ... | - ${number} - Memif ID. Type: integer
+| | ...
+| | ... | *Note:*
+| | ... | Socket paths for Memif are defined in following format:
+| | ... | - /tmp/memif-DUT1_VNF${number}-${sid}
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Initialize L2 Bridge Domain for single memif in 3-node circular \
+| | ... | topology \| 1 \| 1 \|
+| | ...
+| | [Arguments] | ${rxq}=${1} | ${number}=${1}
+| | ${sock}= | Set Variable | memif-DUT1_VNF
+| | Set up single memif interface on DUT node | ${dut1} | ${sock}
+| | ... | ${number} | dut1-memif-${number}-if1 | ${rxq} | ${rxq}
+| | Add interface to bridge domain | ${dut1} | ${dut1_if1} | ${number}
+| | Add interface to bridge domain | ${dut1} | ${dut1-memif-${number}-if1}
+| | ... | ${number}
+| | ${sock}= | Set Variable | memif-DUT2_VNF
+| | Set up single memif interface on DUT node | ${dut2} | ${sock}
+| | ... | ${number} | dut2-memif-${number}-if1 | ${rxq} | ${rxq}
+| | Add interface to bridge domain | ${dut2} | ${dut2_if2} | ${number}
+| | Add interface to bridge domain | ${dut2} | ${dut2-memif-${number}-if1}
+| | ... | ${number}
+| | All Vpp Interfaces Ready Wait | ${nodes}
+| | Show Memif on all DUTs | ${nodes}
diff --git a/resources/libraries/robot/shared/container.robot b/resources/libraries/robot/shared/container.robot
index b44e4386a6..201cadcb73 100644
--- a/resources/libraries/robot/shared/container.robot
+++ b/resources/libraries/robot/shared/container.robot
@@ -109,7 +109,8 @@
| | ... | group on all DUT nodes.
| | ...
| | Run Keyword | ${group}.Configure VPP In All Containers
-| | ... | memif_create_cnt.vat
+| | ... | chain_topology=${container_chain_topology}
+| | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if1}
| Stop all '${group}' containers
| | [Documentation] | Stop all container(s) in specific container group on all
diff --git a/resources/libraries/robot/shared/memif.robot b/resources/libraries/robot/shared/memif.robot
index 172376ffde..ea080a1b83 100644
--- a/resources/libraries/robot/shared/memif.robot
+++ b/resources/libraries/robot/shared/memif.robot
@@ -59,3 +59,33 @@
| | Set Interface State | ${dut_node} | ${memif_2} | up
| | Set Test Variable | ${${memif_if1}} | ${memif_1}
| | Set Test Variable | ${${memif_if2}} | ${memif_2}
+
+| Set up single memif interface on DUT node
+| | [Documentation] | Create single Memif interface on given VPP node.
+| | ...
+| | ... | *Arguments:*
+| | ... | - ${dut_node} - DUT node. Type: dictionary
+| | ... | - ${filename} - Socket filename for Memif interface. Type: string
+| | ... | - ${mid} - Memif interface ID. Type: integer
+| | ... | - ${memif_if} - Name of the Memif interface (Optional).
+| | ... | Type: string
+| | ... | - ${rxq} - RX queues. Type: integer
+| | ... | - ${txq} - TX queues. Type: integer
+| | ... | - ${role} - Memif role. Type: string
+| | ...
+| | ... | _NOTE:_ This KW sets following test case variable:
+| | ... | - ${${memif_if}} - Memif interface.
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Set up single memif interface on DUT node \
+| | ... | \| ${nodes['DUT1']} \| sock1 \| 1 \| dut1_memif_if1 \| 1 \| 1 \
+| | ... | \| slave \|
+| | ...
+| | [Arguments] | ${dut_node} | ${filename} | ${mid}=${1}
+| | ... | ${memif_if}=memif_if1 | ${rxq}=${1} | ${txq}=${1} | ${role}=slave
+| | ${sid}= | Evaluate | (${mid}*2)-1
+| | ${memif}= | Create memif interface | ${dut_node} | ${filename}${mid}-${sid}
+| | ... | ${mid} | ${sid} | rxq=${rxq} | txq=${txq} | role=${role}
+| | Set Interface State | ${dut_node} | ${memif} | up
+| | Set Test Variable | ${${memif_if}} | ${memif}