Change in ...docker-playground[master]: debian-repo-install-test: add docker container

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Tue Jul 23 12:09:53 UTC 2019


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

Change subject: debian-repo-install-test: add docker container
......................................................................

debian-repo-install-test: add docker container

Add own container with systemd, so we can (in a follow-up commit) run
the Osmocom systemd services in this test job. Rewrite the
"interactive shell" logic to support the new systemd docker container,
and enable it with an INTERACTIVE environment variable instead of
hardcoding 'interactive="true"' in the script. While at it, move the
Repository.key install to the Dockerfile so it works more like the other
docker containers we have.

Related: OS#3369
Change-Id: I0348f65a2ac184ba6b001e5130dfc8124e657367
---
A debian-repo-install-test/Dockerfile
A debian-repo-install-test/Makefile
R debian-repo-install-test/Release.key
M debian-repo-install-test/jenkins.sh
M debian-repo-install-test/testdata/repo-install-test.sh
5 files changed, 50 insertions(+), 28 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  osmith: Verified



diff --git a/debian-repo-install-test/Dockerfile b/debian-repo-install-test/Dockerfile
new file mode 100644
index 0000000..5448fd6
--- /dev/null
+++ b/debian-repo-install-test/Dockerfile
@@ -0,0 +1,12 @@
+ARG	USER
+FROM	debian:stretch
+
+COPY	Release.key /tmp/Release.key
+
+RUN	apt-get update && \
+	apt-get install -y --no-install-recommends \
+		aptitude \
+		gnupg \
+		systemd && \
+	apt-key add /tmp/Release.key && \
+	rm /tmp/Release.key
diff --git a/debian-repo-install-test/Makefile b/debian-repo-install-test/Makefile
new file mode 100644
index 0000000..8d0e10b
--- /dev/null
+++ b/debian-repo-install-test/Makefile
@@ -0,0 +1 @@
+include ../make/Makefile
diff --git a/debian-repo-install-test/testdata/Release.key b/debian-repo-install-test/Release.key
similarity index 100%
rename from debian-repo-install-test/testdata/Release.key
rename to debian-repo-install-test/Release.key
diff --git a/debian-repo-install-test/jenkins.sh b/debian-repo-install-test/jenkins.sh
index 9dd4565..db71bc6 100755
--- a/debian-repo-install-test/jenkins.sh
+++ b/debian-repo-install-test/jenkins.sh
@@ -1,18 +1,48 @@
 #!/bin/sh
 . ../jenkins-common.sh
+docker_images_require "debian-repo-install-test"
 
-# Configuration
 [ -z "$FEED" ] && FEED="nightly"
-interactive="false"
+
+# 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
+			return
+		fi
+	done
+
+	echo "ERROR: systemd is not running properly."
+	docker container kill "$BUILD_TAG"
+	exit 1
+}
 
 # Run the container
-extra_args=""
-[ "$interactive" = "true" ] && extra_args="-it"
+# 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}" \
 		-e FEED="$FEED" \
-		$extra_args \
-		debian:stretch \
-		"/testdata/repo-install-test.sh"
+		-e container=docker \
+		--tmpfs /run \
+		--tmpfs /tmp \
+		-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
+		--cap-add SYS_ADMIN \
+		"$REPO_USER/debian-repo-install-test" \
+		/lib/systemd/systemd &
+check_if_systemd_is_running
+
+# Run the test script
+docker exec "$BUILD_TAG" /testdata/repo-install-test.sh
+ret="$?"
+
+# Interactive shell
+if [ -n "$INTERACTIVE" ]; then
+	docker exec -it "$BUILD_TAG" bash
+fi
+
+docker container kill "$BUILD_TAG"
+
+exit $ret
diff --git a/debian-repo-install-test/testdata/repo-install-test.sh b/debian-repo-install-test/testdata/repo-install-test.sh
index f45908b..38a982f 100755
--- a/debian-repo-install-test/testdata/repo-install-test.sh
+++ b/debian-repo-install-test/testdata/repo-install-test.sh
@@ -12,15 +12,8 @@
 	fi
 }
 
-install_depends() {
-	echo "Installing dependencies"
-	apt-get update
-	apt-get install -y gnupg aptitude
-}
-
 configure_osmocom_repo() {
 	echo "Configuring Osmocom repository"
-	apt-key add /testdata/Release.key
 	echo "deb $HTTP ./" \
 		> /etc/apt/sources.list.d/osmocom-latest.list
 	apt-get update
@@ -87,21 +80,7 @@
 		osmo-trx-usrp1
 }
 
-finish() {
-	echo "Test finished successfully!"
-
-	# When docker-run is called with "-it", then stdin and a tty are available.
-	# The container will still exit when the entrypoint script (this file) is
-	# through, so in order to be able to type in commands, we execute a bash shell.
-	if [ -t 0 ]; then
-		echo "Dropping to interactive shell"
-		bash
-	fi
-}
-
 check_env
-install_depends
 configure_osmocom_repo
 install_repo_packages
 test_binaries
-finish

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

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I0348f65a2ac184ba6b001e5130dfc8124e657367
Gerrit-Change-Number: 14779
Gerrit-PatchSet: 4
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190723/042237ed/attachment.htm>


More information about the gerrit-log mailing list