osmith has submitted this change. (
https://gerrit.osmocom.org/c/docker-playground/+/30995
)
Change subject: network_create: put SUBNET in NET_NAME
......................................................................
network_create: put SUBNET in NET_NAME
Fix the bug that running a test twice on the same host results in the
second test stopping the containers and network of the first test:
* Have the subnet name in the network name, so there's no collision of
network names when cleaning up the network.
* Don't clean up the network when creating a new network. Rely on the
clean up trap to clean up the network instead.
* Don't set NET_NAME when sourcing jenkins-common.sh anymore, as
network_create will set it. There's also network_bridge_create, which
only gets used by osmo-ran (which we don't run in jenkins). Add a
check to this function to ensure NET_NAME is set before calling it,
which osmo-ran is already doing.
Related: OS#5802
Change-Id: Ifcd384272c56d585e220e2588f2186dc110902ed
---
M jenkins-common.sh
M ttcn3-bsc-test/jenkins-sccplite.sh
M ttcn3-ggsn-test/jenkins-ogs.sh
3 files changed, 9 insertions(+), 18 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/jenkins-common.sh b/jenkins-common.sh
index 758c4d0..c7c282c 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -195,19 +195,12 @@
docker network inspect $NET_NAME | grep Name | cut -d : -f2 | awk -F\"
'NR>1{print $2}' | xargs -rn1 docker kill
}
-# Create network and find a free subnet automatically. The global variable
-# SUBNET gets set to the subnet number that has been used.
+# Create network and find a free subnet automatically. The global variables
+# SUBNET (subnet number) and NET_NAME (name of the docker network) get set.
network_create() {
- if docker network ls | grep -q $NET_NAME; then
- set +x
- echo "Removing stale network and containers..."
- set -x
- network_clean
- network_remove
- fi
-
SUBNET="$PPID"
for i in $(seq 1 30); do
+ NET_NAME="$SUITE_NAME-$SUBNET"
SUBNET="$(echo "($SUBNET + 1) % 256" | bc)"
SUB4="172.18.$SUBNET.0/24"
SUB6="fd02:db8:$SUBNET::/64"
@@ -235,6 +228,12 @@
}
network_bridge_create() {
+ if [ -z "$NET_NAME" ]; then
+ set +x
+ echo "ERROR: network_bridge_create: NET_NAME needs to be set"
+ exit 1
+ fi
+
NET=$1
if docker network ls | grep -q $NET_NAME; then
set +x
@@ -518,5 +517,3 @@
fi
SUITE_NAME=`basename $PWD`
-
-NET_NAME=$SUITE_NAME
diff --git a/ttcn3-bsc-test/jenkins-sccplite.sh b/ttcn3-bsc-test/jenkins-sccplite.sh
index 2343b4a..7ba8c9e 100755
--- a/ttcn3-bsc-test/jenkins-sccplite.sh
+++ b/ttcn3-bsc-test/jenkins-sccplite.sh
@@ -10,9 +10,6 @@
set_clean_up_trap
set -e
-#Make sure NET_NAME doesn't clash with the AoIP BSC test
-NET_NAME=ttcn3-bsc_sccplite-test
-
mkdir $VOL_BASE_DIR/bsc-tester
cp sccplite/BSC_Tests.cfg $VOL_BASE_DIR/bsc-tester/
write_mp_osmo_repo "$VOL_BASE_DIR/bsc-tester/BSC_Tests.cfg"
diff --git a/ttcn3-ggsn-test/jenkins-ogs.sh b/ttcn3-ggsn-test/jenkins-ogs.sh
index 93cc33a..5875b75 100755
--- a/ttcn3-ggsn-test/jenkins-ogs.sh
+++ b/ttcn3-ggsn-test/jenkins-ogs.sh
@@ -11,9 +11,6 @@
set_clean_up_trap
set -e
-#Make sure NET_NAME doesn't clash with the AoIP BSC test
-NET_NAME=ttcn3-ggsn-test-ogs
-
mkdir $VOL_BASE_DIR/ggsn-tester
cp ogs/GGSN_Tests.cfg $VOL_BASE_DIR/ggsn-tester/
write_mp_osmo_repo "$VOL_BASE_DIR/ggsn-tester/GGSN_Tests.cfg"
--
To view, visit
https://gerrit.osmocom.org/c/docker-playground/+/30995
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: Ifcd384272c56d585e220e2588f2186dc110902ed
Gerrit-Change-Number: 30995
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged