debian-repo-install-test: kill already running

The container grows heavily in size as the test runs, so make sure to
always kill existing ones (from stopped jobs) before starting a new
one. In order to do that, do not use $BUILD_TAG as container name,
which changes with every new jenkins run.

Related: OS#3369
Change-Id: Ide795092b656c9f0eb92a075d8f662944089019f
This commit is contained in:
Oliver Smith 2019-07-12 10:44:11 +02:00
parent 380d49dbd0
commit 29825bbc71
1 changed files with 13 additions and 6 deletions

View File

@ -3,27 +3,34 @@
docker_images_require "debian-repo-install-test"
[ -z "$FEED" ] && FEED="nightly"
CONTAINER="repo-install-test-$FEED"
# Try to run "systemctl status" 10 times, kill the container on failure
check_if_systemd_is_running() {
for i in $(seq 1 10); do
sleep 1
if docker exec "$BUILD_TAG" systemctl status; then
if docker exec "$CONTAINER" systemctl status; then
return
fi
done
echo "ERROR: systemd is not running properly."
docker container kill "$BUILD_TAG"
docker container kill "$CONTAINER"
exit 1
}
# Kill already running container
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER" 2> /dev/null)" = "true" ]; then
docker container kill "$CONTAINER"
sleep 1
fi
# Run the container
# Note that this does not output anything. For debugging, add -it and remove &.
docker run --rm \
-v "$PWD/testdata:/testdata:ro" \
-v "$VOL_BASE_DIR:/data" \
--name "${BUILD_TAG}" \
--name "$CONTAINER" \
-e FEED="$FEED" \
-e container=docker \
--tmpfs /run \
@ -35,14 +42,14 @@ docker run --rm \
check_if_systemd_is_running
# Run the test script
docker exec "$BUILD_TAG" /testdata/repo-install-test.sh
docker exec "$CONTAINER" /testdata/repo-install-test.sh
ret="$?"
# Interactive shell
if [ -n "$INTERACTIVE" ]; then
docker exec -it "$BUILD_TAG" bash
docker exec -it "$CONTAINER" bash
fi
docker container kill "$BUILD_TAG"
docker container kill "$CONTAINER"
exit $ret