docker kill: wait until containers are stopped
As "docker kill" / "docker container kill" (alias) doesn't block until the given container stops, make sure to always run "docker wait" afterwards. Closes: OS#5928 Change-Id: I0242ece96541d8036ebbf8b0f498ebf231db26b5
This commit is contained in:
parent
c163d5d854
commit
4f459b779e
|
@ -190,9 +190,19 @@ docker_images_require() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Kill a docker container and ensure it has actually stopped (OS#5928)
|
||||||
|
docker_kill_wait() {
|
||||||
|
docker kill "$@"
|
||||||
|
docker wait "$@" || true
|
||||||
|
}
|
||||||
|
|
||||||
#kills all containers attached to network
|
#kills all containers attached to network
|
||||||
network_clean() {
|
network_clean() {
|
||||||
docker network inspect $NET_NAME | grep Name | cut -d : -f2 | awk -F\" 'NR>1{print $2}' | xargs -rn1 docker kill
|
local containers="$(docker network inspect $NET_NAME | grep Name | cut -d : -f2 | awk -F\" 'NR>1{print $2}')"
|
||||||
|
|
||||||
|
if [ -n "$containers" ]; then
|
||||||
|
docker_kill_wait $containers
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create network and find a free subnet automatically. The global variables
|
# Create network and find a free subnet automatically. The global variables
|
||||||
|
|
|
@ -28,6 +28,6 @@ docker run --rm \
|
||||||
|
|
||||||
echo Stopping containers
|
echo Stopping containers
|
||||||
|
|
||||||
docker container kill osmo-cn
|
docker_kill_wait osmo-cn
|
||||||
|
|
||||||
network_remove
|
network_remove
|
||||||
|
|
|
@ -68,9 +68,7 @@ run_image() {
|
||||||
}
|
}
|
||||||
|
|
||||||
kill_containers() {
|
kill_containers() {
|
||||||
for i in "${docker_names[@]}"; do
|
docker_kill_wait "${docker_names[@]}"
|
||||||
docker kill $i
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_networks() {
|
remove_networks() {
|
||||||
|
|
|
@ -51,6 +51,6 @@ ${OSMO_INTERACT_VTY} \
|
||||||
-H "172.18.$SUBNET.23" \
|
-H "172.18.$SUBNET.23" \
|
||||||
-O "$VTYFILE"
|
-O "$VTYFILE"
|
||||||
|
|
||||||
docker container kill "${BUILD_TAG}-$NAME-$IMAGE_SUFFIX"
|
docker_kill_wait "${BUILD_TAG}-$NAME-$IMAGE_SUFFIX"
|
||||||
|
|
||||||
network_remove
|
network_remove
|
||||||
|
|
|
@ -168,9 +168,9 @@ start_testsuite generic
|
||||||
# 2) some GPRS tests require virt_phy
|
# 2) some GPRS tests require virt_phy
|
||||||
echo "Changing to virtphy configuration"
|
echo "Changing to virtphy configuration"
|
||||||
# switch from osmo-bts-trx + trxcon + faketrx to virtphy + osmo-bts-virtual
|
# switch from osmo-bts-trx + trxcon + faketrx to virtphy + osmo-bts-virtual
|
||||||
docker container kill ${BUILD_TAG}-trxcon
|
docker_kill_wait ${BUILD_TAG}-trxcon
|
||||||
docker container kill ${BUILD_TAG}-fake_trx
|
docker_kill_wait ${BUILD_TAG}-fake_trx
|
||||||
docker container kill ${BUILD_TAG}-bts
|
docker_kill_wait ${BUILD_TAG}-bts
|
||||||
cp virtphy/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
|
cp virtphy/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
|
||||||
network_replace_subnet_in_configs
|
network_replace_subnet_in_configs
|
||||||
start_bts virtual 0
|
start_bts virtual 0
|
||||||
|
@ -179,10 +179,10 @@ start_virtphy
|
||||||
#start_testsuite virtphy
|
#start_testsuite virtphy
|
||||||
|
|
||||||
# 3) OML tests require us to run without BSC
|
# 3) OML tests require us to run without BSC
|
||||||
docker container kill ${BUILD_TAG}-bsc
|
docker_kill_wait ${BUILD_TAG}-bsc
|
||||||
# switch back from virtphy + osmo-bts-virtual to osmo-bts-trx
|
# switch back from virtphy + osmo-bts-virtual to osmo-bts-trx
|
||||||
docker container kill ${BUILD_TAG}-virtphy
|
docker_kill_wait ${BUILD_TAG}-virtphy
|
||||||
docker container kill ${BUILD_TAG}-bts
|
docker_kill_wait ${BUILD_TAG}-bts
|
||||||
|
|
||||||
cp oml/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
|
cp oml/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
|
||||||
network_replace_subnet_in_configs
|
network_replace_subnet_in_configs
|
||||||
|
@ -196,7 +196,7 @@ start_testsuite oml
|
||||||
cp fh/osmo-bsc.gen.cfg $VOL_BASE_DIR/bsc/
|
cp fh/osmo-bsc.gen.cfg $VOL_BASE_DIR/bsc/
|
||||||
cp generic/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
|
cp generic/osmo-bts.gen.cfg $VOL_BASE_DIR/bts/
|
||||||
# restart the BSC/BTS and run the testsuite again
|
# restart the BSC/BTS and run the testsuite again
|
||||||
docker container kill ${BUILD_TAG}-bts
|
docker_kill_wait ${BUILD_TAG}-bts
|
||||||
network_replace_subnet_in_configs
|
network_replace_subnet_in_configs
|
||||||
start_bsc
|
start_bsc
|
||||||
start_bts trx 1
|
start_bts trx 1
|
||||||
|
|
|
@ -10,7 +10,7 @@ set -e
|
||||||
|
|
||||||
clean_up() {
|
clean_up() {
|
||||||
# kill the frnet container to avoid "You cannot remove a running container " below in 'rm'
|
# kill the frnet container to avoid "You cannot remove a running container " below in 'rm'
|
||||||
docker kill ${BUILD_TAG}-frnet || true
|
docker_kill_wait ${BUILD_TAG}-frnet || true
|
||||||
|
|
||||||
# store execution logs for both containers
|
# store execution logs for both containers
|
||||||
docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test > $VOL_BASE_DIR/fr-tester/exec.log || true
|
docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test > $VOL_BASE_DIR/fr-tester/exec.log || true
|
||||||
|
|
|
@ -74,8 +74,8 @@ run_tests() {
|
||||||
$REPO_USER/ttcn3-hnbgw-test
|
$REPO_USER/ttcn3-hnbgw-test
|
||||||
|
|
||||||
echo Stopping containers
|
echo Stopping containers
|
||||||
docker container kill ${BUILD_TAG}-hnbgw
|
docker_kill_wait ${BUILD_TAG}-hnbgw
|
||||||
docker container kill ${BUILD_TAG}-stp
|
docker_kill_wait ${BUILD_TAG}-stp
|
||||||
}
|
}
|
||||||
|
|
||||||
echo Testing without PFCP
|
echo Testing without PFCP
|
||||||
|
|
|
@ -45,4 +45,4 @@ docker run --rm \
|
||||||
$REPO_USER/ttcn3-hnodeb-test
|
$REPO_USER/ttcn3-hnodeb-test
|
||||||
|
|
||||||
echo Stopping containers
|
echo Stopping containers
|
||||||
docker container kill ${BUILD_TAG}-hnodeb
|
docker_kill_wait ${BUILD_TAG}-hnodeb
|
||||||
|
|
|
@ -80,7 +80,7 @@ write_mp_osmo_repo "$VOL_BASE_DIR/remsim-tester/REMSIM_Tests.cfg"
|
||||||
network_replace_subnet_in_configs
|
network_replace_subnet_in_configs
|
||||||
start_server
|
start_server
|
||||||
start_testsuite
|
start_testsuite
|
||||||
docker container kill ${BUILD_TAG}-server
|
docker_kill_wait ${BUILD_TAG}-server
|
||||||
|
|
||||||
# 2) bankd test suite
|
# 2) bankd test suite
|
||||||
echo "Changing to bankd configuration"
|
echo "Changing to bankd configuration"
|
||||||
|
@ -89,7 +89,7 @@ write_mp_osmo_repo "$VOL_BASE_DIR/remsim-tester/REMSIM_Tests.cfg"
|
||||||
network_replace_subnet_in_configs
|
network_replace_subnet_in_configs
|
||||||
start_bankd
|
start_bankd
|
||||||
start_testsuite
|
start_testsuite
|
||||||
docker container kill ${BUILD_TAG}-bankd
|
docker_kill_wait ${BUILD_TAG}-bankd
|
||||||
|
|
||||||
# 3) client test suite
|
# 3) client test suite
|
||||||
echo "Changing to client configuration"
|
echo "Changing to client configuration"
|
||||||
|
|
Loading…
Reference in New Issue