osmith has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/c/docker-playground/+/14780 )

Change subject: debian-repo-install-test: kill already running
......................................................................

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
---
M debian-repo-install-test/jenkins.sh
1 file changed, 13 insertions(+), 6 deletions(-)

Approvals:
  osmith: Verified
  pespin: Looks good to me, approved



diff --git a/debian-repo-install-test/jenkins.sh 
b/debian-repo-install-test/jenkins.sh
index db71bc6..fbae4b9 100755
--- a/debian-repo-install-test/jenkins.sh
+++ b/debian-repo-install-test/jenkins.sh
@@ -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 @@
 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

--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/14780
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: Ide795092b656c9f0eb92a075d8f662944089019f
Gerrit-Change-Number: 14780
Gerrit-PatchSet: 5
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to