diff options
author | Yichen Wang <yicwang@cisco.com> | 2017-12-13 15:01:34 -0800 |
---|---|---|
committer | Yichen Wang <yicwang@cisco.com> | 2018-01-02 11:19:28 -0800 |
commit | b481ad4a6c6b98cac760b12e4190f9540869e673 (patch) | |
tree | cb772d754ba27d244dadd3c086293784c8acc286 | |
parent | efc678c9d3843dcfd373b5749a88c51228b0b27c (diff) |
Multiple bugfixes for NFVbench
[NFVBENCH-52] NFVbench should ignore the port security settings if not
available
[NFVBENCH-53] NFVbench should support to use software mode for TRex
[NFVBENCH-54] NFVbench container should also map kernel sources when
available to build KOs
[NFVBENCH-55] Documentation enhancements to have better examples for
using "$PWD"
[NFVBENCH-57] NFVbench should support to build kernel modules on redhat
distros
Change-Id: Id6792d6711393b07ca59396c276a026bec9f1e86
Signed-off-by: Yichen Wang <yicwang@cisco.com>
-rw-r--r-- | docker/Dockerfile | 1 | ||||
-rw-r--r-- | docs/testing/user/userguide/quickstart_docker.rst | 75 | ||||
-rw-r--r-- | nfvbench/cfg.default.yaml | 5 | ||||
-rw-r--r-- | nfvbench/chain_clients.py | 19 | ||||
-rw-r--r-- | nfvbench/traffic_server.py | 5 | ||||
-rw-r--r-- | test/test_nfvbench.py | 2 |
6 files changed, 68 insertions, 39 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index d30ef22..ec31b1a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,6 +14,7 @@ RUN apt-get update && apt-get install -y \ vim \ wget \ net-tools \ + libelf1 \ && mkdir /tmp/http_root \ && mkdir -p /opt/trex \ && mkdir /var/log/nfvbench \ diff --git a/docs/testing/user/userguide/quickstart_docker.rst b/docs/testing/user/userguide/quickstart_docker.rst index 01b5d7d..c5e5eda 100644 --- a/docs/testing/user/userguide/quickstart_docker.rst +++ b/docs/testing/user/userguide/quickstart_docker.rst @@ -25,31 +25,33 @@ To pull the latest NFVbench container image: The NFVbench container requires the following Docker options to operate properly. -+------------------------------------------------------+------------------------------------------------------+ -| Docker options | Description | -+======================================================+======================================================+ -| -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) | needed by kernel modules in the container | -+------------------------------------------------------+------------------------------------------------------+ -| -v /dev:/dev | needed by kernel modules in the container | -+------------------------------------------------------+------------------------------------------------------+ -| -v $PWD:/tmp/nfvbench | optional but recommended to pass files between the | -| | host and the docker space (see examples below) | -| | Here we map the current directory on the host to the | -| | /tmp/nfvbench director in the container but any | -| | other similar mapping can work as well | -+------------------------------------------------------+------------------------------------------------------+ -| --net=host | (optional) needed if you run the NFVbench ok | -| | server in the container (or use any appropriate | -| | docker network mode other than "host") | -+------------------------------------------------------+------------------------------------------------------+ -| --privileged | (optional) required if SELinux is enabled on the host| -+------------------------------------------------------+------------------------------------------------------+ -| -e HOST="127.0.0.1" | (optional) required if REST server is enabled | -+------------------------------------------------------+------------------------------------------------------+ -| -e PORT=7556 | (optional) required if REST server is enabled | -+------------------------------------------------------+------------------------------------------------------+ -| -e CONFIG_FILE="/root/nfvbenchconfig.json | (optional) required if REST server is enabled | -+------------------------------------------------------+------------------------------------------------------+ ++-------------------------------------------------------+-------------------------------------------------------+ +| Docker options | Description | ++=======================================================+=======================================================+ +| -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) | needed by kernel modules in the container | ++-------------------------------------------------------+-------------------------------------------------------+ +| -v /usr/src/kernels:/usr/src/kernels | needed by TRex to build kernel modules when needed | ++-------------------------------------------------------+-------------------------------------------------------+ +| -v /dev:/dev | needed by kernel modules in the container | ++-------------------------------------------------------+-------------------------------------------------------+ +| -v $PWD:/tmp/nfvbench | optional but recommended to pass files between the | +| | host and the docker space (see examples below) | +| | Here we map the current directory on the host to the | +| | /tmp/nfvbench director in the container but any | +| | other similar mapping can work as well | ++-------------------------------------------------------+-------------------------------------------------------+ +| --net=host | (optional) needed if you run the NFVbench ok | +| | server in the container (or use any appropriate | +| | docker network mode other than "host") | ++-------------------------------------------------------+-------------------------------------------------------+ +| --privileged | (optional) required if SELinux is enabled on the host | ++-------------------------------------------------------+-------------------------------------------------------+ +| -e HOST="127.0.0.1" | (optional) required if REST server is enabled | ++-------------------------------------------------------+-------------------------------------------------------+ +| -e PORT=7556 | (optional) required if REST server is enabled | ++-------------------------------------------------------+-------------------------------------------------------+ +| -e CONFIG_FILE="/root/nfvbenchconfig.json | (optional) required if REST server is enabled | ++-------------------------------------------------------+-------------------------------------------------------+ It can be convenient to write a shell script (or an alias) to automatically insert the necessary options. @@ -80,6 +82,7 @@ the 2 NIC ports to use for generating traffic have the PCI addresses "04:00.0" a "intf_speed": "10Gbps", "ip": "127.0.0.1", "name": "trex-local", + "software_mode": false, "tool": "TRex" } ] @@ -98,17 +101,21 @@ The second approach is more responsive as the delay is only incurred once when s We will take the second approach and start the NFVbench container in detached mode with the name "nfvbench" (this works with bash, prefix with "sudo" if you do not use the root login) +First create a new working directory, and change the current working directory to there. A "nfvbench_ws" directory under your home directory is good place for that, and this is where the OpenStack RC file and NFVbench config file will sit. + To run NFVBench without server mode .. code-block:: bash - docker run --detach --net=host --privileged -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) --name nfvbench opnfv/nfvbench + cd ~/nfvbench_ws + docker run --detach --net=host --privileged -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) -v /usr/src/kernels:/usr/src/kernels --name nfvbench opnfv/nfvbench To run NFVBench enabling REST server (mount the configuration json and the path for openrc) .. code-block:: bash - docker run --detach --net=host --privileged -e HOST="127.0.0.1" -e PORT=7556 --e CONFIG_FILE="/tmp/nfvbench/nfvbenchconfig.json -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) --name nfvbench opnfv/nfvbench start_rest_server + cd ~/nfvbench_ws + docker run --detach --net=host --privileged -e HOST="127.0.0.1" -e PORT=7556 --e CONFIG_FILE="/tmp/nfvbench/nfvbenchconfig.json -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) -v /usr/src/kernels:/usr/src/kernels --name nfvbench opnfv/nfvbench start_rest_server The create an alias to make it easy to execute nfvbench commands directly from the host shell prompt: @@ -141,6 +148,7 @@ Create a new file containing the minimal configuration for NFVbench, we can call tool: TRex ip: 127.0.0.1 cores: 3 + software_mode: false, interfaces: - port: 0 switch_port: @@ -176,22 +184,29 @@ PCI addresses "0a:00.0" and "0a:00.1" (first 2 ports of the quad port NIC): tool: TRex ip: 127.0.0.1 cores: 3 + software_mode: false, interfaces: - port: 0 switch_port: - pci: 0a:00.0 + pci: "0a:00.0" - port: 1 switch_port: - pci: 0a:00.1 + pci: "0a:00.1" intf_speed: 10Gbps +.. warning:: + + You have to put quotes around the pci addresses as shown in the above example, otherwise TRex will read it wrong. + Alternatively, the full template with comments can be obtained using the --show-default-config option in yaml format: .. code-block:: bash nfvbench --show-default-config > my_nfvbench.cfg -Edit the nfvbench.cfg file to only keep those properties that need to be modified (preserving the nesting) +Edit the nfvbench.cfg file to only keep those properties that need to be modified (preserving the nesting). + +Make sure you have your nfvbench configuration file (my_nfvbench.cfg) and OpenStack RC file in your pre-created working directory. 5. Run NFVbench diff --git a/nfvbench/cfg.default.yaml b/nfvbench/cfg.default.yaml index a8bdc2b..bc8921d 100644 --- a/nfvbench/cfg.default.yaml +++ b/nfvbench/cfg.default.yaml @@ -167,6 +167,10 @@ traffic_generator: # `tool`: Traffic generator tool to be used (currently supported is `TRex`). # `ip`: IP address of the traffic generator. # `cores`: Specify the number of cores for TRex traffic generator. ONLY applies to trex-local. + # `software_mode`: Advice TRex to use software mode which provides the best compability. But + # note that TRex will not use any hardware acceleration technology under + # software mode, therefore the performance of TRex will be significantly + # lower. ONLY applies to trex-local. # `interfaces`: Configuration of traffic generator interfaces. # `interfaces.port`: The port of the traffic generator to be used (leave as 0 and 1 resp.) # `interfaces.switch_port`: Leave empty (reserved for advanced use cases) @@ -178,6 +182,7 @@ traffic_generator: tool: TRex ip: 127.0.0.1 cores: 3 + software_mode: false interfaces: - port: 0 switch_port: diff --git a/nfvbench/chain_clients.py b/nfvbench/chain_clients.py index fa21359..7106129 100644 --- a/nfvbench/chain_clients.py +++ b/nfvbench/chain_clients.py @@ -346,13 +346,18 @@ class BasicStageClient(object): for net in self.nets: for port in self.ports[net['id']]: if port['device_id'] in vm_ids: - self.neutron.update_port(port['id'], { - 'port': { - 'security_groups': [], - 'port_security_enabled': False, - } - }) - LOG.info('Security disabled on port %s', port['id']) + try: + self.neutron.update_port(port['id'], { + 'port': { + 'security_groups': [], + 'port_security_enabled': False, + } + }) + LOG.info('Security disabled on port %s', port['id']) + except Exception: + LOG.warning('Failed to disable port security on port %s, ignoring...', + port['id']) + def get_loop_vm_hostnames(self): return [getattr(vm, 'OS-EXT-SRV-ATTR:hypervisor_hostname') for vm in self.vms] diff --git a/nfvbench/traffic_server.py b/nfvbench/traffic_server.py index b35e78b..fe9edd2 100644 --- a/nfvbench/traffic_server.py +++ b/nfvbench/traffic_server.py @@ -43,9 +43,10 @@ class TRexTrafficServer(TrafficServer): """ cfg = self.__save_config(traffic_profile, filename) cores = traffic_profile.cores + sw_mode = "--software" if traffic_profile.software_mode else "" subprocess.Popen(['nohup', '/bin/bash', '-c', - './t-rex-64 -i -c {} --iom 0 --no-scapy-server --close-at-end --vlan' - ' --cfg {} &> /tmp/trex.log & disown'.format(cores, cfg)], + './t-rex-64 -i -c {} --iom 0 --no-scapy-server --close-at-end {} ' + '--vlan --cfg {} &> /tmp/trex.log & disown'.format(cores, sw_mode, cfg)], cwd=self.trex_dir) LOG.info('TRex server is running...') diff --git a/test/test_nfvbench.py b/test/test_nfvbench.py index 05490e7..fc8174f 100644 --- a/test/test_nfvbench.py +++ b/test/test_nfvbench.py @@ -299,6 +299,8 @@ def test_parse_rate_str(): else: return False + return False + assert should_raise_error('101') assert should_raise_error('201%') assert should_raise_error('10Kbps') |