summaryrefslogtreecommitdiffstats
path: root/tests/topotests/docker/inner
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
commite2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch)
treef0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tests/topotests/docker/inner
parentInitial commit. (diff)
downloadfrr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz
frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/docker/inner')
-rwxr-xr-xtests/topotests/docker/inner/compile_frr.sh87
-rwxr-xr-xtests/topotests/docker/inner/entrypoint.sh31
-rwxr-xr-xtests/topotests/docker/inner/funcs.sh53
-rw-r--r--tests/topotests/docker/inner/motd.txt15
-rwxr-xr-xtests/topotests/docker/inner/openvswitch.sh40
5 files changed, 226 insertions, 0 deletions
diff --git a/tests/topotests/docker/inner/compile_frr.sh b/tests/topotests/docker/inner/compile_frr.sh
new file mode 100755
index 0000000..3b296a1
--- /dev/null
+++ b/tests/topotests/docker/inner/compile_frr.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+#
+# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF")
+
+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_BUILD_DIR &> /dev/null
+fi
+
+log_info "Syncing FRR source with host..."
+mkdir -p $FRR_BUILD_DIR
+rsync -a --info=progress2 \
+ --from0 --files-from=/tmp/git-ls-files \
+ --chown root:root \
+ $FRR_HOST_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 \
+ --enable-dev-build \
+ --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 0000000..44e16db
--- /dev/null
+++ b/tests/topotests/docker/inner/entrypoint.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+#
+# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF")
+
+# Load shared functions
+CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+. $CDIR/funcs.sh
+
+set -e
+
+#
+# Script begin
+#
+"${CDIR}/compile_frr.sh"
+"${CDIR}/openvswitch.sh"
+
+cd "${FRR_BUILD_DIR}/tests/topotests"
+
+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 0000000..4ebacbb
--- /dev/null
+++ b/tests/topotests/docker/inner/funcs.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+#
+# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF")
+
+FRR_HOST_DIR=/root/host-frr
+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 0000000..1e2f34f
--- /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 0000000..926a25c
--- /dev/null
+++ b/tests/topotests/docker/inner/openvswitch.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-License-Identifier: MIT
+#
+# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF")
+
+# 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