diff options
author | Oliver Smith <osmith@sysmocom.de> | 2019-07-12 10:44:11 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2019-07-23 14:10:53 +0200 |
commit | 29825bbc71a363b7de96b4c1de5bd9254ffc6f1d (patch) | |
tree | 269c9cb03b95a06812288abd2555af7e0d15eea8 | |
parent | 380d49dbd0781b814944f4f5525185368dd02c9b (diff) |
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
-rwxr-xr-x | debian-repo-install-test/jenkins.sh | 19 |
1 files changed, 13 insertions, 6 deletions
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 @@ 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 |