diff --git a/.dockerignore b/.dockerignore index 6b8710a711..f2fc34583d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,7 @@ .git +**/*.a +**/*.o +**/*.la +**/*.lo +**/*.so +**/.libs diff --git a/tests/topotests/Dockerfile b/tests/topotests/Dockerfile index 72a876ed83..3613e23a6e 100644 --- a/tests/topotests/Dockerfile +++ b/tests/topotests/Dockerfile @@ -70,7 +70,7 @@ RUN echo "" >> /etc/security/limits.conf; \ echo "root hard core unlimited" >> /etc/security/limits.conf # Copy run scripts to facilitate users wanting to run the tests -COPY docker/inner /opt/topotests +COPY tests/topotests/docker/inner /opt/topotests WORKDIR /root/topotests ENV PATH "$PATH:/opt/topotests" diff --git a/tests/topotests/README.md b/tests/topotests/README.md index 3f1323c218..a495675ee9 100644 --- a/tests/topotests/README.md +++ b/tests/topotests/README.md @@ -1,5 +1,10 @@ # FRRouting Topology Tests with Mininet +## Running tests with docker + +There is a docker image which allows to run topotests. Instructions can be +found [here](docker/README.md). + ## Guidelines Instructions for use, write or debug topologies can be found in the @@ -11,11 +16,6 @@ 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 918594e6a3..cdc41fad52 100644 --- a/tests/topotests/docker/README.md +++ b/tests/topotests/docker/README.md @@ -3,34 +3,43 @@ ## 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 -from this repository: +The easiest way to do this, is to use the make targets from this +repository. + +Your current user needs to have access to the Docker daemon. Alternatively +you can run these commands as root. ```console -wget -O /usr/local/bin/frr-topotests \ - https://raw.githubusercontent.com/frrouting/topotests/master/docker/frr-topotests.sh -chmod +x /usr/local/bin/frr-topotests +make topotests-build +make topotests ``` -Once this script is in place, simply run it while you are inside your FRR repository: +The first command will build a docker image with all the dependencies needed +to run the topotests. -```console -frr-topotests -``` +The second command will spawn an instance of this image, compile FRR inside +of it, and run the topotests. ## 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`. +Internally, the topotests make target uses a shell script to spawn the docker +container. + +There are several environment variables which can be used to modify the behavior +of the script, these can be listed by calling it with `-h`: + +```console +./tests/topotests/docker/frr-topotests.sh -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 +TOPOTEST_CLEAN=1 ./tests/topotests/docker/frr-topotests.sh ``` -By default, `frr-topotests` will build frr and run pytest. If you append +By default, `frr-topotests.sh` will build frr and run pytest. If you append arguments and the first one starts 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. @@ -38,11 +47,11 @@ 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 +./tests/topotests/docker/frr-topotests.sh -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 +./tests/topotests/docker/frr-topotests.sh /bin/bash ``` diff --git a/tests/topotests/docker/build.sh b/tests/topotests/docker/build.sh index 344fb2ffcb..3bb6dbaad8 100755 --- a/tests/topotests/docker/build.sh +++ b/tests/topotests/docker/build.sh @@ -22,9 +22,10 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -cd "$(dirname "$0")"/.. +cd "$(dirname "$0")"/../../.. exec docker build --pull \ --compress \ -t frrouting/frr:topotests-latest \ + -f tests/topotests/Dockerfile \ . diff --git a/tests/topotests/docker/inner/entrypoint.sh b/tests/topotests/docker/inner/entrypoint.sh index f491d15f79..3050ec86d0 100755 --- a/tests/topotests/docker/inner/entrypoint.sh +++ b/tests/topotests/docker/inner/entrypoint.sh @@ -40,7 +40,10 @@ chmod 1777 /tmp if [ $# -eq 0 ] || ([[ "$1" != /* ]] && [[ "$1" != ./* ]]); then export TOPOTESTS_CHECK_MEMLEAK=/tmp/memleak_ export TOPOTESTS_CHECK_STDERR=Yes - set -- pytest --junitxml /tmp/topotests.xml "$@" + set -- pytest \ + --junitxml /tmp/topotests.xml \ + -o cache_dir=/tmp \ + "$@" fi exec "$@"