]> git.puffer.fish Git - mirror/frr.git/commitdiff
Docker: Allow executing topotests while in subdir of FRR repo
authorChristian Franke <chris@opensourcerouting.org>
Thu, 18 Oct 2018 10:27:37 +0000 (12:27 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Thu, 29 Nov 2018 15:51:27 +0000 (16:51 +0100)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
12 files changed:
tests/topotests/Dockerfile
tests/topotests/docker/build.sh [new file with mode: 0755]
tests/topotests/docker/compile_frr.sh [deleted file]
tests/topotests/docker/docker.sh [deleted file]
tests/topotests/docker/entrypoint.sh [deleted file]
tests/topotests/docker/frr-topotests.sh
tests/topotests/docker/funcs.sh [deleted file]
tests/topotests/docker/inner/compile_frr.sh [new file with mode: 0755]
tests/topotests/docker/inner/entrypoint.sh [new file with mode: 0755]
tests/topotests/docker/inner/funcs.sh [new file with mode: 0755]
tests/topotests/docker/inner/motd.txt [new file with mode: 0644]
tests/topotests/docker/motd.txt [deleted file]

index d7b2cae354f8e0b58e6a60a52cf0767d44f8f80f..4f418b3acb7ad5508493fea313c00214ec851708 100644 (file)
@@ -58,11 +58,13 @@ 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 . /root/topotests
-WORKDIR /root
-ENV PATH "$PATH:/root/topotests/docker"
 
-RUN echo "cat /root/topotests/docker/motd.txt" >> /root/.profile && \
+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", "/root/topotests/docker/entrypoint.sh" ]
+ENTRYPOINT [ "bash", "/opt/topotests/entrypoint.sh" ]
diff --git a/tests/topotests/docker/build.sh b/tests/topotests/docker/build.sh
new file mode 100755 (executable)
index 0000000..47b14df
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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.
+
+exec docker build --pull \
+                 --compress \
+                 -t frrouting/topotests \
+                 .
diff --git a/tests/topotests/docker/compile_frr.sh b/tests/topotests/docker/compile_frr.sh
deleted file mode 100755 (executable)
index 579994f..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/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 LD="gcc"
-               export LDFLAGS="-g -fsanitize=address -ldl"
-               EXTRA_CONFIGURE+=" --enable-shared=no "
-               touch .address_sanitizer
-       else
-               rm -f .address_sanitizer
-       fi
-
-       bash configure >&3 \
-               --enable-multipath=64 \
-               --prefix=/usr \
-               --localstatedir=/var/run/frr \
-               --sbindir=/usr/lib/frr \
-               --sysconfdir=/etc/frr \
-               $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/docker.sh b/tests/topotests/docker/docker.sh
deleted file mode 100755 (executable)
index 4dcee21..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/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
-#
-
-exec docker build --pull \
-                 --compress \
-                 -t frrrouting/topotests \
-                 .
diff --git a/tests/topotests/docker/entrypoint.sh b/tests/topotests/docker/entrypoint.sh
deleted file mode 100755 (executable)
index 707c521..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/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
-
-bash "${CDIR}/compile_frr.sh"
-
-log_info "Setting permissions on /tmp so we can generate logs"
-chmod -v 1777 /tmp
-
-log_info "Starting bash shell to interact with topotests"
-echo ''
-
-exec bash
index e5e91156a56d9ae9c3ff9d4c5f0b1e91eae61b60..3df31c5d6385b4789e8e53e9278dc1e07a2c805b 100755 (executable)
@@ -105,7 +105,12 @@ if [ -z "$TOPOTEST_LOGS" ]; then
 fi
 
 if [ -z "$TOPOTEST_FRR" ]; then
-       TOPOTEST_FRR="$(pwd)"
+       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
diff --git a/tests/topotests/docker/funcs.sh b/tests/topotests/docker/funcs.sh
deleted file mode 100755 (executable)
index acb8b55..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/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/compile_frr.sh b/tests/topotests/docker/inner/compile_frr.sh
new file mode 100755 (executable)
index 0000000..579994f
--- /dev/null
@@ -0,0 +1,105 @@
+#!/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 LD="gcc"
+               export LDFLAGS="-g -fsanitize=address -ldl"
+               EXTRA_CONFIGURE+=" --enable-shared=no "
+               touch .address_sanitizer
+       else
+               rm -f .address_sanitizer
+       fi
+
+       bash configure >&3 \
+               --enable-multipath=64 \
+               --prefix=/usr \
+               --localstatedir=/var/run/frr \
+               --sbindir=/usr/lib/frr \
+               --sysconfdir=/etc/frr \
+               $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 (executable)
index 0000000..707c521
--- /dev/null
@@ -0,0 +1,68 @@
+#!/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
+
+bash "${CDIR}/compile_frr.sh"
+
+log_info "Setting permissions on /tmp so we can generate logs"
+chmod -v 1777 /tmp
+
+log_info "Starting bash shell to interact with topotests"
+echo ''
+
+exec bash
diff --git a/tests/topotests/docker/inner/funcs.sh b/tests/topotests/docker/inner/funcs.sh
new file mode 100755 (executable)
index 0000000..acb8b55
--- /dev/null
@@ -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 (file)
index 0000000..1e2f34f
--- /dev/null
@@ -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/motd.txt b/tests/topotests/docker/motd.txt
deleted file mode 100644 (file)
index 1e2f34f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-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`.