aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2023-01-30 13:16:28 +0100
committerOliver Smith <osmith@sysmocom.de>2023-01-30 13:45:30 +0100
commit46e4362ae261296b35f8278bf90ab839360f39f2 (patch)
tree0e767d118a0f880888bb071015d27abc34f903f0
parent7a49258ca7fcaabecf363084ad82f1b33de1cb89 (diff)
FR testsuites: clean up all networks before start
Add a new network_clean_remove_all_ttcn3 function and use it in the fr related testsuites to ensure no network is running before the test starts. We just had the situation where the network link between gtp0-deb10fr (where these testsuites run exclusively, and only one at a time) and the jenkins host went down. And so the clean up trap apparently did not run and starting a new test fails as the old network still exists and has the network devices attached. Related: OS#5802 Change-Id: I6a9464a11edcba978be08764bec9de19760a5c77
-rw-r--r--jenkins-common.sh29
-rwxr-xr-xttcn3-fr-test/jenkins.sh1
-rwxr-xr-xttcn3-gbproxy-test-fr/jenkins.sh1
-rwxr-xr-xttcn3-ns-test/jenkins-fr.sh1
4 files changed, 32 insertions, 0 deletions
diff --git a/jenkins-common.sh b/jenkins-common.sh
index ef0a3fc..a607f9a 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -262,6 +262,35 @@ network_remove() {
docker network remove $NET_NAME
}
+# Clean and remove all docker networks related to ttcn3 testing. This prevents
+# running testsuites in parallel, so usually we don't want this and rely on the
+# clean_up_trap to clean the network. But on e.g. gtp0-deb10fr this gets used
+# as we only run one testsuite at once and it has dahdi netdevices attached.
+# Due connection loss, it may not be cleaned up there and so another testsuite
+# cannot start.
+network_clean_remove_all_ttcn3() {
+ local networks
+ local i
+
+ networks="$(docker network ls --format '{{.Name}}' | grep ^ttcn3- || true)"
+
+ if [ -z "$networks" ]; then
+ return
+ fi
+
+ set +x
+ echo "Removing stale network and containers..."
+ set -x
+
+ for i in $networks; do
+ NET_NAME="$i"
+ network_clean
+ network_remove
+ done
+
+ unset NET_NAME
+}
+
network_replace_subnet_in_configs() {
set +x
diff --git a/ttcn3-fr-test/jenkins.sh b/ttcn3-fr-test/jenkins.sh
index 9122063..12e14a5 100755
--- a/ttcn3-fr-test/jenkins.sh
+++ b/ttcn3-fr-test/jenkins.sh
@@ -30,6 +30,7 @@ cp FRNET_Tests.cfg $VOL_BASE_DIR/frnet/
mkdir $VOL_BASE_DIR/unix
+network_clean_remove_all_ttcn3
network_create
network_replace_subnet_in_configs
diff --git a/ttcn3-gbproxy-test-fr/jenkins.sh b/ttcn3-gbproxy-test-fr/jenkins.sh
index ab62bc1..1c53173 100755
--- a/ttcn3-gbproxy-test-fr/jenkins.sh
+++ b/ttcn3-gbproxy-test-fr/jenkins.sh
@@ -33,6 +33,7 @@ cp osmo-gbproxy.cfg $VOL_BASE_DIR/gbproxy/
mkdir $VOL_BASE_DIR/unix
+network_clean_remove_all_ttcn3
network_create
network_replace_subnet_in_configs
diff --git a/ttcn3-ns-test/jenkins-fr.sh b/ttcn3-ns-test/jenkins-fr.sh
index 3b609ab..b6af67f 100755
--- a/ttcn3-ns-test/jenkins-fr.sh
+++ b/ttcn3-ns-test/jenkins-fr.sh
@@ -29,6 +29,7 @@ write_mp_osmo_repo "$VOL_BASE_DIR/ns-tester/NS_Tests.cfg"
mkdir $VOL_BASE_DIR/ns
cp fr/osmo-ns-dummy.cfg $VOL_BASE_DIR/ns/
+network_clean_remove_all_ttcn3
network_create
network_replace_subnet_in_configs