osmith has submitted this change. (
https://gerrit.osmocom.org/c/docker-playground/+/31103
)
Change subject: FR testsuites: clean up all networks before start
......................................................................
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
---
M jenkins-common.sh
M ttcn3-fr-test/jenkins.sh
M ttcn3-gbproxy-test-fr/jenkins.sh
M ttcn3-ns-test/jenkins-fr.sh
4 files changed, 32 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, but someone else must approve
osmith: Looks good to me, approved
Jenkins Builder: Verified
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 @@
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 @@
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 @@
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 @@
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
--
To view, visit
https://gerrit.osmocom.org/c/docker-playground/+/31103
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I6a9464a11edcba978be08764bec9de19760a5c77
Gerrit-Change-Number: 31103
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged