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
This commit is contained in:
parent
f997b4e771
commit
d2827d91ce
|
@ -195,19 +195,12 @@ network_clean() {
|
|||
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_create() {
|
|||
}
|
||||
|
||||
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 @@ if [ "x$BUILD_TAG" = "x" ]; then
|
|||
fi
|
||||
|
||||
SUITE_NAME=`basename $PWD`
|
||||
|
||||
NET_NAME=$SUITE_NAME
|
||||
|
|
|
@ -10,9 +10,6 @@ docker_images_require \
|
|||
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"
|
||||
|
|
|
@ -11,9 +11,6 @@ docker_images_require \
|
|||
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"
|
||||
|
|
Loading…
Reference in New Issue