From 4242d6e2ae668ea6761db039f9f06e56f7416107 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Thu, 18 Oct 2018 13:48:55 +0200 Subject: [PATCH] Docker: Use pytest as default command Signed-off-by: Christian Franke --- tests/topotests/README.md | 4 +++ tests/topotests/docker/README.md | 33 +++++++++++++++++++-- tests/topotests/docker/inner/compile_frr.sh | 6 +++- tests/topotests/docker/inner/entrypoint.sh | 11 ++++--- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/tests/topotests/README.md b/tests/topotests/README.md index 47668f4bb..3f1323c21 100644 --- a/tests/topotests/README.md +++ b/tests/topotests/README.md @@ -11,6 +11,10 @@ that does what you need. If nothing is similar, then you may create a new topology, preferably, using the newest [template](example-test/test_template.py). +## Running tests with docker + +There is a docker image which allows to run topotests. Instructions can be +found [here](docker/README.md). ## Installation of Mininet for running tests Only tested with Ubuntu 16.04 and Ubuntu 18.04 (which uses Mininet 2.2.x) diff --git a/tests/topotests/docker/README.md b/tests/topotests/docker/README.md index b506fd6fb..25b18da7d 100644 --- a/tests/topotests/docker/README.md +++ b/tests/topotests/docker/README.md @@ -1,6 +1,6 @@ # Topotests in Docker -## Usage +## Quickstart If you have Docker installed, you can run the topotests in Docker. The easiest way to do this, is to use the `frr-topotests.sh` script @@ -14,8 +14,35 @@ chmod +x /usr/local/bin/frr-topotests Once this script is in place, simply run it while you are inside your FRR repository: -``` +```console frr-topotests ``` -It should build FRR inside of the container and run the topotests on it. +## Advanced Usage + +There are several environtment variables which can be used to modify the behavior of +the image. Those can be listed using `frr-topotests -h`. + +For example, a volume is used to cache build artifacts between multiple runs +of the image. If you need to force a complete recompile, you can set `TOPOTEST_CLEAN`: + +```console +TOPOTEST_CLEAN=1 frr-topotests +``` + +By default, `frr-topotests` will execute pytest without any arguments. If you append an +arguments with the first one starting with `/` or `./`, they will replace the call to +pytest. If the appended arguments do not match this patttern, they will be provided to +pytest as arguments. + +So, to run a specific test with more verbose logging: + +```console +frr-topotests -vv -s all-protocol-startup/test_all_protocol_startup.py +``` + +And to compile FRR but drop into a shell instead of running pytest: + +```console +frr-topotests /bin/bash +``` diff --git a/tests/topotests/docker/inner/compile_frr.sh b/tests/topotests/docker/inner/compile_frr.sh index 579994f83..896514b5d 100755 --- a/tests/topotests/docker/inner/compile_frr.sh +++ b/tests/topotests/docker/inner/compile_frr.sh @@ -83,11 +83,15 @@ if [ ! -e Makefile ]; then fi bash configure >&3 \ - --enable-multipath=64 \ + --enable-static-bin \ + --with-moduledir=/usr/lib/frr/modules \ --prefix=/usr \ --localstatedir=/var/run/frr \ --sbindir=/usr/lib/frr \ --sysconfdir=/etc/frr \ + --enable-multipath=0 \ + --enable-fpm \ + --enable-sharpd \ $EXTRA_CONFIGURE \ --with-pkg-extra-version=-topotests \ || log_fatal "failed to configure the sources" diff --git a/tests/topotests/docker/inner/entrypoint.sh b/tests/topotests/docker/inner/entrypoint.sh index dd329619f..37c5b75bf 100755 --- a/tests/topotests/docker/inner/entrypoint.sh +++ b/tests/topotests/docker/inner/entrypoint.sh @@ -33,9 +33,12 @@ CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" "${CDIR}/openvswitch.sh" log_info "Setting permissions on /tmp so we can generate logs" -chmod -v 1777 /tmp +chmod 1777 /tmp -log_info "Starting bash shell to interact with topotests" -echo '' +if [ $# -eq 0 ] || ([[ "$1" != /* ]] && [[ "$1" != ./* ]]); then + export TOPOTESTS_CHECK_MEMLEAK=/tmp/memleak_ + export TOPOTESTS_CHECK_STDERR=Yes + set -- pytest --junitxml /tmp/topotests.xml "$@" +fi -exec bash +exec "$@" -- 2.39.2