Testing NFVbench

tox

NFVbench project uses tox to orchestrate the testing of the code base:

  • run unit tests

  • check code style

  • run linter

  • check links in the docs

In addition to testing, tox is also used to generate the documentation in HTML format.

What tox should do is specified in a tox.ini file located at the project root.

tox is used in continuous integration (jenkins-ci today, gitlab-ci in the near future): all the actions performed by tox must succeed before a patchset can be merged. As a developer, it is also useful to run tox locally to detect and fix the issues before pushing the code for review.

Using tox on a developer’s machine

Requirement: Python 3.6

The current version of Python used by NFVbench is Python 3.6. In particular, this means that Python 3.6 is used:

  • by tox in CI

  • in nfvbench Docker image

  • in nfvbench traffic generator VM image

Python 3.6 is needed to be able to run tox locally. If it is not available through the package manager, it can be installed using pyenv. In that case, it will also be necessary to install the pyenv-virtualenv plugin. Refer to the documentation of those projects for installation instructions.

tox installation

Install tox with:

$ pip install tox tox-pip-version

Running tox

In nfvbench root directory, simply run tox with:

$ tox

If all goes well, tox shows a green summary such as:

py36: commands succeeded
pep8: commands succeeded
lint: commands succeeded
docs: commands succeeded
docs-linkcheck: commands succeeded
congratulations :)

It is possible to run only a subset of tox environments with the -e command line option. For instance, to check the code style only, do:

$ tox -e pep8

Each tox environment uses a dedicated python virtual environment. The -r command line option can be used to force the recreation of the virtual environment(s). For instance:

$ tox -r