diff --git a/Makefile.am b/Makefile.am index d12d452645..c56a551aa5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -149,6 +149,7 @@ include yang/libyang_plugins/subdir.am include vtysh/subdir.am include tests/subdir.am +include tests/topotests/subdir.am if PKGSRC rcdir=@pkgsrcrcdir@ diff --git a/tests/topotests/Dockerfile b/tests/topotests/Dockerfile new file mode 100644 index 0000000000..72a876ed83 --- /dev/null +++ b/tests/topotests/Dockerfile @@ -0,0 +1,81 @@ +FROM ubuntu:18.04 + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update \ + && apt-get install -y \ + autoconf \ + binutils \ + bison \ + flex \ + gdb \ + git \ + install-info \ + iputils-ping \ + iproute2 \ + less \ + libtool \ + libjson-c-dev \ + libpcre3-dev \ + libpython-dev \ + libreadline-dev \ + libc-ares-dev \ + man \ + mininet \ + pkg-config \ + python-pip \ + python-sphinx \ + rsync \ + strace \ + tcpdump \ + texinfo \ + tmux \ + valgrind \ + vim \ + wget \ + x11-xserver-utils \ + xterm \ + && pip install \ + exabgp==3.4.17 \ + ipaddr \ + pytest + +RUN cd /tmp \ + && wget -q https://ci1.netdef.org/artifact/LIBYANG-YANGRELEASE/shared/build-1/Ubuntu-18.04-x86_64-Packages/libyang-dev_0.16.46_amd64.deb \ + -O libyang-dev.deb \ + && wget -q https://ci1.netdef.org/artifact/LIBYANG-YANGRELEASE/shared/build-1/Ubuntu-18.04-x86_64-Packages/libyang_0.16.46_amd64.deb \ + -O libyang.deb \ + && echo "039252cc66eb254a97e160b1c325af669470cde8a02d73ec9f7b920ed3c7997c libyang.deb" | sha256sum -c - \ + && echo "e7e2d5bfc7b33b3218df8bef404432970f9b4ad10d6dbbdcb0e0be2babbb68e9 libyang-dev.deb" | sha256sum -c - \ + && dpkg -i libyang*.deb \ + && rm libyang*.deb + +RUN groupadd -r -g 92 frr \ + && groupadd -r -g 85 frrvty \ + && useradd -c "FRRouting suite" \ + -d /var/run/frr \ + -g frr \ + -G frrvty \ + -r \ + -s /sbin/nologin \ + frr \ + && useradd -d /var/run/exabgp/ \ + -s /bin/false \ + exabgp + +# Configure coredumps +RUN echo "" >> /etc/security/limits.conf; \ + echo "* soft core unlimited" >> /etc/security/limits.conf; \ + echo "root soft core unlimited" >> /etc/security/limits.conf; \ + echo "* hard core unlimited" >> /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 + +WORKDIR /root/topotests +ENV PATH "$PATH:/opt/topotests" + +RUN echo "cat /opt/topotests/motd.txt" >> /root/.profile && \ + echo "export PS1='(topotests) $PS1'" >> /root/.profile + +ENTRYPOINT [ "bash", "/opt/topotests/entrypoint.sh" ] diff --git a/tests/topotests/README.md b/tests/topotests/README.md index 47668f4bba..3f1323c218 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 new file mode 100644 index 0000000000..918594e6a3 --- /dev/null +++ b/tests/topotests/docker/README.md @@ -0,0 +1,48 @@ +# Topotests in Docker + +## 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: + +```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 +``` + +Once this script is in place, simply run it while you are inside your FRR repository: + +```console +frr-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`. + +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 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. + +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/build.sh b/tests/topotests/docker/build.sh new file mode 100755 index 0000000000..344fb2ffcb --- /dev/null +++ b/tests/topotests/docker/build.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cd "$(dirname "$0")"/.. + +exec docker build --pull \ + --compress \ + -t frrouting/frr:topotests-latest \ + . diff --git a/tests/topotests/docker/frr-topotests.sh b/tests/topotests/docker/frr-topotests.sh new file mode 100755 index 0000000000..673354f5da --- /dev/null +++ b/tests/topotests/docker/frr-topotests.sh @@ -0,0 +1,150 @@ +#!/bin/bash +# +# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set -e + +if [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then + cat >&2 <<-EOF + + This script runs the FRRouting topotests on the FRR tree + in the current working directory. + + Usage: $0 [args...] + + If any arguments are provided and the first argument starts with / or ./ + the arguments are interpreted as command and will be executed instead + of pytest. + + Behavior can be further modified by the following environment variables: + + TOPOTEST_AUTOLOAD If set to 1, the script will try to load necessary + kernel modules without asking for confirmation first. + + TOPOTEST_BUILDCACHE Docker volume used for caching multiple FRR builds + over container runs. By default a + \`topotest-buildcache\` volume will be created for + that purpose. + + TOPOTEST_CLEAN Clean all previous build artifacts prior to + building. Disabled by default, set to 1 to enable. + + TOPOTEST_DOC Build the documentation associated with FRR. + Disabled by default, set to 1 to enable. + + TOPOTEST_FRR If set, don't test the FRR in the current working + directory, but the one at the given path. + + TOPOTEST_LOGS If set, don't use \`/tmp/topotest_logs\` directory + but use the provided path instead. + + TOPOTEST_OPTIONS These options are appended to the docker-run + command for starting the tests. + + TOPOTEST_SANITIZER Controls whether to use the address sanitizer. + Enabled by default, set to 0 to disable. + + TOPOTEST_VERBOSE Show detailed build output. + Enabled by default, set to 0 to disable. + + EOF + exit 1 +fi + +# +# These two modules are needed to run the MPLS tests. +# They are often not automatically loaded. +# +# We cannot load them from the container since we don't +# have host kernel modules available there. If we load +# them from the host however, they can be used just fine. +# + +for module in mpls-router mpls-iptunnel; do + if modprobe -n $module 2> /dev/null; then + : + else + # If the module doesn't exist, we cannot do anything about it + continue + fi + + if [ $(grep -c ${module/-/_} /proc/modules) -ne 0 ]; then + # If the module is loaded, we don't have to do anything + continue + fi + + if [ "$TOPOTEST_AUTOLOAD" != "1" ]; then + echo "To run all the possible tests, we need to load $module." + echo -n "Do you want to proceed? [y/n] " + read answer + if [ x"$answer" != x"y" ]; then + echo "Not loading." + continue + fi + fi + + if [ x"$(whoami)" = x"root" ]; then + modprobe $module + else + sudo modprobe $module + fi +done + +if [ -z "$TOPOTEST_LOGS" ]; then + mkdir -p /tmp/topotest_logs + TOPOTEST_LOGS="/tmp/topotest_logs" +fi + +if [ -z "$TOPOTEST_FRR" ]; then + TOPOTEST_FRR="$(git rev-parse --show-toplevel || true)" + if [ -z "$TOPOTEST_FRR" ]; then + echo "Could not determine base of FRR tree." >&2 + echo "frr-topotests only works if you have your tree in git." >&2 + exit 1 + fi +fi + +if [ -z "$TOPOTEST_BUILDCACHE" ]; then + TOPOTEST_BUILDCACHE=topotest-buildcache + docker volume inspect "${TOPOTEST_BUILDCACHE}" &> /dev/null \ + || docker volume create "${TOPOTEST_BUILDCACHE}" +fi + +set -- --rm -i \ + -v "$TOPOTEST_LOGS:/tmp" \ + -v "$TOPOTEST_FRR:/root/host-frr:ro" \ + -v "$TOPOTEST_FRR/tests/topotests:/root/topotests:ro" \ + -v "$TOPOTEST_BUILDCACHE:/root/persist" \ + -e "TOPOTEST_CLEAN=$TOPOTEST_CLEAN" \ + -e "TOPOTEST_VERBOSE=$TOPOTEST_VERBOSE" \ + -e "TOPOTEST_DOC=$TOPOTEST_DOC" \ + -e "TOPOTEST_SANITIZER=$TOPOTEST_SANITIZER" \ + --privileged \ + $TOPOTEST_OPTIONS \ + frrouting/frr:topotests-latest "$@" + +if [ -t 0 ]; then + set -- -t "$@" +fi + +exec docker run "$@" diff --git a/tests/topotests/docker/inner/compile_frr.sh b/tests/topotests/docker/inner/compile_frr.sh new file mode 100755 index 0000000000..2d72082c1e --- /dev/null +++ b/tests/topotests/docker/inner/compile_frr.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set -e + +# Load shared functions +CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +. $CDIR/funcs.sh + +# +# Script begin +# + +if [ "${TOPOTEST_CLEAN}" != "0" ]; then + log_info "Cleaning FRR builddir..." + rm -rf $FRR_SYNC_DIR $FRR_BUILD_DIR &> /dev/null +fi + +log_info "Syncing FRR source with host..." +mkdir -p $FRR_SYNC_DIR +rsync -a --info=progress2 \ + --exclude '*.o' \ + --exclude '*.lo'\ + --chown root:root \ + $FRR_HOST_DIR/. $FRR_SYNC_DIR/ +(cd $FRR_SYNC_DIR && git clean -xdf > /dev/null) +mkdir -p $FRR_BUILD_DIR +rsync -a --info=progress2 --chown root:root $FRR_SYNC_DIR/. $FRR_BUILD_DIR/ + +cd "$FRR_BUILD_DIR" || \ + log_fatal "failed to find frr directory" + +if [ "${TOPOTEST_VERBOSE}" != "0" ]; then + exec 3>&1 +else + exec 3>/dev/null +fi + +log_info "Building FRR..." + +if [ ! -e configure ]; then + bash bootstrap.sh >&3 || \ + log_fatal "failed to bootstrap configuration" +fi + +if [ "${TOPOTEST_DOC}" != "0" ]; then + EXTRA_CONFIGURE+=" --enable-doc " +else + EXTRA_CONFIGURE+=" --disable-doc " +fi + +if [ ! -e Makefile ]; then + if [ "${TOPOTEST_SANITIZER}" != "0" ]; then + export CC="gcc" + export CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer" + export LDFLAGS="-g -fsanitize=address -ldl" + touch .address_sanitizer + else + rm -f .address_sanitizer + fi + + bash configure >&3 \ + --enable-static-bin \ + --enable-static \ + --enable-shared \ + --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" +fi + +# if '.address_sanitizer' file exists it means we are using address sanitizer. +if [ -f .address_sanitizer ]; then + make -C lib CFLAGS="-g -O2" LDFLAGS="-g" clippy >&3 +fi + +make -j$(cpu_count) >&3 || \ + log_fatal "failed to build the sources" + +make install >/dev/null || \ + log_fatal "failed to install frr" diff --git a/tests/topotests/docker/inner/entrypoint.sh b/tests/topotests/docker/inner/entrypoint.sh new file mode 100755 index 0000000000..f491d15f79 --- /dev/null +++ b/tests/topotests/docker/inner/entrypoint.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Load shared functions +CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +. $CDIR/funcs.sh + +set -e + +# +# Script begin +# +"${CDIR}/compile_frr.sh" +"${CDIR}/openvswitch.sh" + +log_info "Setting permissions on /tmp so we can generate logs" +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 "$@" +fi + +exec "$@" diff --git a/tests/topotests/docker/inner/funcs.sh b/tests/topotests/docker/inner/funcs.sh new file mode 100755 index 0000000000..acb8b55e97 --- /dev/null +++ b/tests/topotests/docker/inner/funcs.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FRR_HOST_DIR=/root/host-frr +FRR_SYNC_DIR=/root/persist/frr-sync +FRR_BUILD_DIR=/root/persist/frr-build + +if [ ! -L "/root/frr" ]; then + ln -s $FRR_BUILD_DIR /root/frr +fi + +[ -z $TOPOTEST_CLEAN ] && TOPOTEST_CLEAN=0 +[ -z $TOPOTEST_VERBOSE ] && TOPOTEST_VERBOSE=1 +[ -z $TOPOTEST_DOC ] && TOPOTEST_DOC=0 +[ -z $TOPOTEST_SANITIZER ] && TOPOTEST_SANITIZER=1 + +log_info() { + local msg=$1 + + echo -e "=> $msg" +} + +log_error() { + local msg=$1 + + echo -e "E: $msg" 2>&1 +} + +log_warning() { + local msg=$1 + + echo -e "W: $msg" 2>&1 +} + +log_fatal() { + local msg=$1 + + echo -e "F: $msg" 2>&1 + + exit 1 +} + +cpu_count() { + local cpu_count + + cpu_count=$(cat /proc/cpuinfo | grep -w processor | wc -l) + if [ $? -eq 0 ]; then + echo -n $cpu_count + else + echo -n 2 + fi +} diff --git a/tests/topotests/docker/inner/motd.txt b/tests/topotests/docker/inner/motd.txt new file mode 100644 index 0000000000..1e2f34f8fb --- /dev/null +++ b/tests/topotests/docker/inner/motd.txt @@ -0,0 +1,15 @@ +Welcome to the topotests container. + +Here are some useful tips: +* After changing the FRR/Topotests sources, you may rebuild them + using the command `compile_frr.sh`. The build command has the + following environment variables: + - TOPOTEST_CLEAN: whether we should distclean or not (disabled by default) + - TOPOTEST_VERBOSE: show build messages (enabled by default) + - TOPOTEST_DOC: whether we should build docs or not (disabled by default) + - TOPOTEST_SANITIZER: whether we should use the address sanitizer (enabled by default) + + Usage example: env TOPOTEST_CLEAN=1 compile_frr.sh + +* The topotests log directory can be found on your host machine on + `/tmp/topotests_logs`. diff --git a/tests/topotests/docker/inner/openvswitch.sh b/tests/topotests/docker/inner/openvswitch.sh new file mode 100755 index 0000000000..67142f04ce --- /dev/null +++ b/tests/topotests/docker/inner/openvswitch.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Load shared functions +CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +. $CDIR/funcs.sh + +# +# Script begin +# + +log_info "Configuring OpenvSwitch...." + +# Configure OpenvSwitch so we are able to run mininet +mkdir -p /var/run/openvswitch +ovsdb-tool create /etc/openvswitch/conf.db \ + /usr/share/openvswitch/vswitch.ovsschema +ovsdb-server /etc/openvswitch/conf.db \ + --remote=punix:/var/run/openvswitch/db.sock \ + --remote=ptcp:6640 --pidfile=ovsdb-server.pid >/dev/null 2>/dev/null & \ + disown +ovs-vswitchd >/dev/null 2>/dev/null & disown + +sleep 2 + +ovs-vsctl --no-wait -- init +ovs_version=$(ovs-vsctl -V | grep ovs-vsctl | awk '{print $4}') +ovs_db_version=$(\ + ovsdb-tool schema-version /usr/share/openvswitch/vswitch.ovsschema) +ovs-vsctl --no-wait -- set Open_vSwitch . db-version="${ovs_db_version}" +ovs-vsctl --no-wait -- set Open_vSwitch . ovs-version="${ovs_version}" +ovs-vsctl --no-wait -- set Open_vSwitch . system-type="docker-ovs" +ovs-vsctl --no-wait -- set Open_vSwitch . system-version="0.1" +ovs-vsctl --no-wait -- \ + set Open_vSwitch . external-ids:system-id=`cat /proc/sys/kernel/random/uuid` +ovs-vsctl --no-wait -- set-manager ptcp:6640 +ovs-appctl -t ovsdb-server \ + ovsdb-server/add-remote db:Open_vSwitch,Open_vSwitch,manager_options diff --git a/tests/topotests/pytest.ini b/tests/topotests/pytest.ini index 7362fae0c4..119ab93857 100644 --- a/tests/topotests/pytest.ini +++ b/tests/topotests/pytest.ini @@ -1,6 +1,6 @@ # Skip pytests example directory [pytest] -norecursedirs = .git example-test lib +norecursedirs = .git example-test lib docker [topogen] # Default configuration values diff --git a/tests/topotests/subdir.am b/tests/topotests/subdir.am new file mode 100644 index 0000000000..e489f92bfa --- /dev/null +++ b/tests/topotests/subdir.am @@ -0,0 +1,7 @@ +TOPOTESTS_DIR = tests/topotests + +topotests-build: ## Builds docker images for topotests + $(TOPOTESTS_DIR)/docker/build.sh + +topotests: ## Runs topotests + $(TOPOTESTS_DIR)/docker/frr-topotests.sh