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.

Change-Id: I6a9464a11edcba978be08764bec9de19760a5c77
This commit is contained in:
Oliver Smith 2023-01-30 13:16:28 +01:00
parent 7a49258ca7
commit bb2b1d9e52
4 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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