From 46e4362ae261296b35f8278bf90ab839360f39f2 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 30 Jan 2023 13:16:28 +0100 Subject: [PATCH] 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 --- jenkins-common.sh | 29 +++++++++++++++++++++++++++++ ttcn3-fr-test/jenkins.sh | 1 + ttcn3-gbproxy-test-fr/jenkins.sh | 1 + ttcn3-ns-test/jenkins-fr.sh | 1 + 4 files changed, 32 insertions(+) diff --git a/jenkins-common.sh b/jenkins-common.sh index ef0a3fc6..a607f9a3 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 91220635..12e14a5e 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 ab62bc10..1c53173e 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 3b609ab6..b6af67f0 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