1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. SPDX-License-Identifier: CC-BY-4.0
5 NFVbench Xtesting test cases and Xtesting CI integration
6 --------------------------------------------------------
8 NFVbench can leverages on `Xtesting CI <https://galaxy.ansible.com/collivier/xtesting>`_ and the common test case execution proposed by `Xtesting <https://xtesting.readthedocs.io/en/latest/>`_.
9 Thanks to a simple test case list, this tool deploys anywhere plug-and-play `CI/CD toolchains in a few commands <https://wiki.opnfv.org/pages/viewpage.action?pageId=32015004>`_.
10 In addition, it supports multiple components such as Jenkins and Gitlab CI (test schedulers) and multiple deployment models such as all-in-one or centralized services.
12 NFVbench using Xtesting and Xtesting CI will permit:
14 - smoothly assemble multiple heterogeneous test cases
15 - generate the Jenkins jobs
16 - deploy local CI/CD toolchains everywhere
17 - dump all test case results and logs for third-party conformance review
19 Xtesting CI only requires GNU/Linux as Operating System and asks for a few dependencies as described in Deploy your own Xtesting CI/CD toolchains:
25 Please note the next two points depending on the GNU/Linux distributions and the network settings:
27 - SELinux: you may have to add --system-site-packages when creating the virtualenv ("Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!")
28 - Proxy: you may set your proxy in env for Ansible and in systemd for Docker https://docs.docker.com/config/daemon/systemd/#httphttps-proxy
30 Here is the default NFVbench tree as proposed in ``xtesting/ansible/host_vars/127.0.0.1`` file:
32 - ``/home/opnfv/nfvbench``
41 - /lib/modules/$(uname -r):/lib/modules/$(uname -r)
42 - /usr/src/kernels:/usr/src/kernels -v /dev:/dev
43 - /home/opnfv/nfvbench:/tmp/nfvbench
45 Please note: replace ``/home/opnfv/nfvbench`` with appropriate path to permit NFVbench container to access config file
47 To deploy your own CI toolchain running NFVbench:
52 . nfvbench/bin/activate
54 ansible-galaxy install collivier.xtesting
55 git clone https://gerrit.opnfv.org/gerrit/nfvbench nfvbench
56 ansible-playbook nfvbench/xtesting/ansible/site.yml
59 NFVbench Xtesting test cases and existing CI chain
60 --------------------------------------------------
62 For test automation purpose, Xtesting framework can be used as an executor of NFVbench test cases and called by a CI chain (Jenkins, Gitlab CI ...).
63 Xtesting use a testcases.yaml file to list and run test case. One basic testcases.yaml is provided by NFVbench natively but can be override.
65 Example of CI scenario:
67 .. image:: images/nfvbench-xtesting.png
69 1. Run NFVbench container using Xtesting python library
71 The NFVbench container can be started using docker run command.
73 To run NFVbench using docker run:
78 -e S3_ENDPOINT_URL=http://127.0.0.1:9000 \
79 -e S3_DST_URL=s3://xtesting/$BUILD_TAG/$JOB_NAME-$BUILD_ID \
80 -e HTTP_DST_URL=http://127.0.0.1:8181/$BUILD_TAG/$JOB_NAME-$BUILD_ID \
81 -e AWS_ACCESS_KEY_ID=xtesting \
82 -e AWS_SECRET_ACCESS_KEY=xtesting \
83 -e TEST_DB_URL=http://127.0.0.1:8000/api/v1/results \
84 -e NODE_NAME=nfvbench \
85 -e BUILD_TAG=$BUILD_TAG \
87 -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) \
88 -v /usr/src/kernels:/usr/src/kernels -v /dev:/dev \
89 -v $HOME/nfvbench:/tmp/nfvbench \
90 -v $HOME/workspace/$JOB_NAME/results:/var/lib/xtesting/results \
91 opnfv/nfvbench run_tests -t 10kpps-pvp-run -r -p
93 +---------------------------------------------------------------+----------------------------------------------------------------------------+
94 | Docker options | Description |
95 +===============================================================+============================================================================+
96 | --rm | clean up container after execution |
97 +---------------------------------------------------------------+----------------------------------------------------------------------------+
98 | -e S3_ENDPOINT_URL | (Xtesting) Environnement variable used to store NFVbench artifacts to Minio|
99 +---------------------------------------------------------------+----------------------------------------------------------------------------+
100 | -e S3_DST_URL | (Xtesting) Environnement variable used for S3 storage destination |
101 +---------------------------------------------------------------+----------------------------------------------------------------------------+
102 | -e HTTP_DST_URL | (Xtesting) Environnement variable used for S3www service |
103 +---------------------------------------------------------------+----------------------------------------------------------------------------+
104 | -e AWS_ACCESS_KEY_ID | (Xtesting) Environnement variable used for S3 access key |
105 +---------------------------------------------------------------+----------------------------------------------------------------------------+
106 | -e AWS_SECRET_ACCESS_KEY | (Xtesting) Environnement variable used for S3 access secret |
107 +---------------------------------------------------------------+----------------------------------------------------------------------------+
108 | -e TEST_DB_URL | (Xtesting) Environnement variable used to export NFVbench results in DB |
109 +---------------------------------------------------------------+----------------------------------------------------------------------------+
110 | -e NODE_NAME | (Xtesting) Environnement variable used as result key identifier in DB |
111 +---------------------------------------------------------------+----------------------------------------------------------------------------+
112 | -e BUILD_TAG | (Xtesting) Environnement variable used as result key identifier in DB |
113 +---------------------------------------------------------------+----------------------------------------------------------------------------+
114 | --privileged | (optional) required if SELinux is enabled on the host |
115 +---------------------------------------------------------------+----------------------------------------------------------------------------+
116 | -v /lib/modules:/lib/modules | needed by kernel modules in the container |
117 +---------------------------------------------------------------+----------------------------------------------------------------------------+
118 | -v /usr/src/kernels:/usr/src/kernels | needed by TRex to build kernel modules when needed |
119 +---------------------------------------------------------------+----------------------------------------------------------------------------+
120 | -v /dev:/dev | needed by kernel modules in the container |
121 +---------------------------------------------------------------+----------------------------------------------------------------------------+
122 | -v $HOME/nfvbench:/tmp/nfvbench | folder mapping to pass files between the |
123 | | host and the docker space (see examples below) |
124 | | Here we map the $HOME/nfvbench directory on the host |
125 | | to the /tmp/nfvbench director in the container. |
126 | | Any other mapping can work as well |
127 +---------------------------------------------------------------+----------------------------------------------------------------------------+
128 | -v $HOME/workspace/$JOB_NAME/results:/var/lib/xtesting/results| (Xtesting) folder mapping to pass files between the |
129 | | CI chain workspace and the docker space to store Xtesting result files |
130 | | in orchestrator (Jenkins, Gitlab ...) |
131 +---------------------------------------------------------------+----------------------------------------------------------------------------+
132 | opnfv/nfvbench | container image name |
133 +---------------------------------------------------------------+----------------------------------------------------------------------------+
134 | run_tests | (Xtesting) Xtesting command to run test cases |
135 +---------------------------------------------------------------+----------------------------------------------------------------------------+
136 | -t 10kpps-pvp-run | (Xtesting) Xtesting parameter: Test case or tier (group of tests) |
137 | | to be executed. It will run all the test if not specified. |
138 +---------------------------------------------------------------+----------------------------------------------------------------------------+
139 | -r | (Xtesting) Xtesting parameter: publish result to database |
140 +---------------------------------------------------------------+----------------------------------------------------------------------------+
141 | -p | (Xtesting) Xtesting parameter: publish artifacts to a S3 service |
142 +---------------------------------------------------------------+----------------------------------------------------------------------------+
144 2. Run Xtesting test cases
146 Executed directly by NFVbench docker entrypoint after docker start.
148 3. Perform NFVbench test
150 Xtesting call NFVbench python script to execute test case scenario and wait for run to be terminated.
152 4. Export NFVbench result
154 If ``-r`` option is used, results are pushed to a DB through Xtesting.
155 If ``-p`` option is used, results are pushed to a S3 service through Xtesting.
158 Override testcases.yaml file
159 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161 To replace existing testcases.yaml file, using Xtesting CI add the volume mapping in ``xtesting/ansible/host_vars/127.0.0.1`` file:
168 - /lib/modules/$(uname -r):/lib/modules/$(uname -r)
169 - /usr/src/kernels:/usr/src/kernels -v /dev:/dev
170 - /home/opnfv/nfvbench:/tmp/nfvbench
171 - /home/opnfv/nfvbench/xtesting/testcases.yaml:/usr/local/lib/python3.6/dist-packages/xtesting/ci/testcases.yaml
173 * ``/home/opnfv/nfvbench/xtesting/testcases.yaml:/usr/local/lib/python3.6/dist-packages/xtesting/ci/testcases.yaml`` : volume mapping to pass testcases.yaml file between the host and the docker space. Host path required testcases.yaml file inside.
176 To replace existing testcases.yaml file, using NFVbench container:
180 docker run --name nfvbench --detach --privileged -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) -v /usr/src/kernels:/usr/src/kernels -v /dev:/dev -v $HOME/nfvbench:/tmp/nfvbench \
181 -v $HOME/nfvbench/xtesting/testcases.yaml:/usr/local/lib/python3.6/dist-packages/xtesting/ci/testcases.yaml \
185 * ``$HOME/nfvbench/xtesting/testcases.yaml:/usr/local/lib/python3.6/dist-packages/xtesting/ci/testcases.yaml`` : volume mapping to pass testcases.yaml file between the host and the docker space. Host path required testcases.yaml file inside.
188 Example of Xtesting test case
189 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198 description: 'Data Plane Performance Testing'
201 case_name: 10kpps-pvp-run
202 project_name: nfvbench
211 - nfvbench -c /tmp/nfvbench/nfvbench.cfg --rate 10kpps
214 Examples of manual run
215 ~~~~~~~~~~~~~~~~~~~~~~
217 If NFVbench container is already started in CLI mode (see Starting NFVbench in CLI mode dedicated chapter).
218 To do a single run at 10,000pps bi-directional (or 5kpps in each direction) using the PVP packet path:
222 docker exec -it nfvbench run_tests -t 10kpps-pvp-run
224 Xtesting option used:
226 * ``-t 10kpps-pvp-run`` : specify the test case to run
228 To pass all test cases:
232 docker exec -it nfvbench run_tests -t all
234 Xtesting option used:
236 * ``-t all`` : select all test cases existing in testcases.yaml file