summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Franke <chris@opensourcerouting.org>2018-10-18 11:31:20 +0200
committerChristian Franke <chris@opensourcerouting.org>2018-11-29 16:51:27 +0100
commit7b75f8cce379485a95cbb36597b2bb2ffd6998cd (patch)
tree561be7be8968ca571826525eb64eda243f027ec3 /tests
parentdocker: Install topotests into image (diff)
downloadfrr-7b75f8cce379485a95cbb36597b2bb2ffd6998cd.tar.xz
frr-7b75f8cce379485a95cbb36597b2bb2ffd6998cd.zip
Docker: Update buildscripts to be more efficient
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/Dockerfile1
-rwxr-xr-xtests/topotests/docker/compile_frr.sh60
-rwxr-xr-xtests/topotests/docker/entrypoint.sh11
-rwxr-xr-xtests/topotests/docker/funcs.sh11
-rw-r--r--tests/topotests/docker/motd.txt11
-rwxr-xr-xtests/topotests/docker/topotests_run.sh33
6 files changed, 62 insertions, 65 deletions
diff --git a/tests/topotests/Dockerfile b/tests/topotests/Dockerfile
index ecc91bc54..d6a395a94 100644
--- a/tests/topotests/Dockerfile
+++ b/tests/topotests/Dockerfile
@@ -8,6 +8,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
bison \
flex \
gdb \
+ git \
inetutils-ping \
install-info \
iproute2 \
diff --git a/tests/topotests/docker/compile_frr.sh b/tests/topotests/docker/compile_frr.sh
index 55046f9ed..6b64f79d6 100755
--- a/tests/topotests/docker/compile_frr.sh
+++ b/tests/topotests/docker/compile_frr.sh
@@ -22,6 +22,8 @@
# 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
@@ -29,36 +31,47 @@ CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#
# Script begin
#
-if [ ! -f .sync_source -o $SYNC_SOURCE -ne 0 ]; then
- log_info "Syncing FRR source with host..."
- mkdir -p $FRR_BUILD_DIR >/dev/null 2>&1
- rsync -a --info=progress2 --chown root:root $FRR_HOST_DIR/. $FRR_BUILD_DIR/
- touch .sync_source
-fi
-log_info "Building FRR..."
+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 || \
+cd "$FRR_BUILD_DIR" || \
log_fatal "failed to find frr directory"
-if [ $CLEAN -ne 0 ]; then
- make distclean >/dev/null 2>&1
- rm -f Makefile configure
+if [ "${TOPOTEST_VERBOSE}" != "0" ]; then
+ exec 3>&1
+else
+ exec 3>/dev/null
+fi
+
+if [ "${TOPOTEST_CLEAN}" != "0" ]; then
+ log_info "Cleaning FRR builddir..."
+ git clean -xdf > /dev/null
fi
-if [ ! -f configure ]; then
- bash bootstrap.sh || \
+log_info "Building FRR..."
+
+if [ ! -e configure ]; then
+ bash bootstrap.sh >&3 || \
log_fatal "failed to bootstrap configuration"
fi
-if [ $DOC -ne 0 ]; then
+if [ "${TOPOTEST_DOC}" != "0" ]; then
EXTRA_CONFIGURE+=" --enable-doc "
else
EXTRA_CONFIGURE+=" --disable-doc "
fi
-if [ ! -f Makefile ]; then
- if [ $SANITIZER -ne 0 ]; then
+if [ ! -e Makefile ]; then
+ if [ "${TOPOTEST_SANITIZER}" != "0" ]; then
export CC="gcc"
export CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
export LD="gcc"
@@ -69,7 +82,7 @@ if [ ! -f Makefile ]; then
rm -f .address_sanitizer
fi
- bash configure >/dev/null \
+ bash configure >&3 \
--enable-multipath=64 \
--prefix=/usr \
--localstatedir=/var/run/frr \
@@ -82,18 +95,11 @@ 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
+ make -C lib CFLAGS="-g -O2" LDFLAGS="-g" clippy >&3
fi
-if [ $VERBOSE -ne 0 ]; then
- make -j$(cpu_count) || \
- log_fatal "failed to build the sources"
-else
- make -j$(cpu_count) >/dev/null || \
- log_fatal "failed to build the sources"
-fi
+make -j$(cpu_count) >&3 || \
+ log_fatal "failed to build the sources"
make install >/dev/null || \
log_fatal "failed to install frr"
-
-exit 0
diff --git a/tests/topotests/docker/entrypoint.sh b/tests/topotests/docker/entrypoint.sh
index e22702958..707c52188 100755
--- a/tests/topotests/docker/entrypoint.sh
+++ b/tests/topotests/docker/entrypoint.sh
@@ -57,11 +57,7 @@ ovs-vsctl --no-wait -- set-manager ptcp:6640
ovs-appctl -t ovsdb-server \
ovsdb-server/add-remote db:Open_vSwitch,Open_vSwitch,manager_options
-# Build FRR
-env \
- CLEAN=1 \
- VERBOSE=0 \
- bash "${CDIR}/compile_frr.sh"
+bash "${CDIR}/compile_frr.sh"
log_info "Setting permissions on /tmp so we can generate logs"
chmod -v 1777 /tmp
@@ -69,7 +65,4 @@ chmod -v 1777 /tmp
log_info "Starting bash shell to interact with topotests"
echo ''
-tmux
-
-log_info "Stopping OpenvSwitch"
-service openvswitch-switch stop
+exec bash
diff --git a/tests/topotests/docker/funcs.sh b/tests/topotests/docker/funcs.sh
index dae71de32..acb8b55e9 100755
--- a/tests/topotests/docker/funcs.sh
+++ b/tests/topotests/docker/funcs.sh
@@ -23,18 +23,17 @@
# SOFTWARE.
FRR_HOST_DIR=/root/host-frr
+FRR_SYNC_DIR=/root/persist/frr-sync
FRR_BUILD_DIR=/root/persist/frr-build
-TOPOTESTS_DIR=/root/topotests
if [ ! -L "/root/frr" ]; then
ln -s $FRR_BUILD_DIR /root/frr
fi
-[ -z $CLEAN ] && CLEAN=0
-[ -z $VERBOSE ] && VERBOSE=1
-[ -z $DOC ] && DOC=0
-[ -z $SANITIZER ] && SANITIZER=1
-[ -z $SYNC_SOURCE ] && SYNC_SOURCE=0
+[ -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
diff --git a/tests/topotests/docker/motd.txt b/tests/topotests/docker/motd.txt
index cb02540f5..1e2f34f8f 100644
--- a/tests/topotests/docker/motd.txt
+++ b/tests/topotests/docker/motd.txt
@@ -4,13 +4,12 @@ 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:
- - CLEAN: whether we should distclean or not (disabled by default)
- - VERBOSE: show build messages (enabled by default)
- - DOC: whether we should build docs or not (disabled by default)
- - SANITIZER: whether we should use the address sanitizer (enabled by default)
- - SYNC_SOURCE: copy new changes from host FRR sources (disabled by default)
+ - 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 CLEAN=1 SYNC_SOURCE=1 DOC=1 compile_frr.sh
+ 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/topotests_run.sh b/tests/topotests/docker/topotests_run.sh
index a68896789..e5e91156a 100755
--- a/tests/topotests/docker/topotests_run.sh
+++ b/tests/topotests/docker/topotests_run.sh
@@ -114,21 +114,20 @@ if [ -z "$TOPOTEST_BUILDCACHE" ]; then
|| docker volume create "${TOPOTEST_BUILDCACHE}"
fi
-if [ -z "$TOPOTEST_PATH" ]; then
- docker run --rm -ti \
- -v "$TOPOTEST_LOGS:/tmp" \
- -v "$TOPOTEST_FRR:/root/host-frr:ro" \
- -v "$TOPOTEST_BUILDCACHE:/root/persist" \
- --privileged \
- $TOPOTEST_OPTIONS \
- frrouting/topotests "$@"
-else
- docker run --rm -ti \
- -v "$TOPOTEST_LOGS:/tmp" \
- -v "$TOPOTEST_FRR:/root/host-frr:ro" \
- -v "$TOPOTEST_BUILDCACHE:/root/persist" \
- -v "$TOPOTEST_PATH:/root/topotests:ro" \
- --privileged \
- $TOPOTEST_OPTIONS \
- frrouting/topotests "$@"
+set -- --rm -ti \
+ -v "$TOPOTEST_LOGS:/tmp" \
+ -v "$TOPOTEST_FRR:/root/host-frr: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/topotests "$@"
+
+if [ -n "TOPOTEST_PATH" ]; then
+ set -- -v "$TOPOTEST_PATH:/root/topotests:ro" "$@"
fi
+
+exec docker run "$@"