summaryrefslogtreecommitdiff
path: root/test/system
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-08 23:39:42 +0200
committerGitHub <noreply@github.com>2019-07-08 23:39:42 +0200
commitfce2e6577e8a6be153c45f4d732fb0fcc3c95a4a (patch)
tree62a3d6ec343bba742e159a5514e8a64e6e8baf99 /test/system
parent8d37c2073f774d7f7e708cdb8c24f07c87e83587 (diff)
parent2bfade4391bb6d247ddab2d129d0529471c17063 (diff)
downloadpodman-fce2e6577e8a6be153c45f4d732fb0fcc3c95a4a.tar.gz
podman-fce2e6577e8a6be153c45f4d732fb0fcc3c95a4a.tar.bz2
podman-fce2e6577e8a6be153c45f4d732fb0fcc3c95a4a.zip
Merge pull request #3497 from QazerLab/bugfix/systemd-generate-pidfile
Use conmon pidfile in generated systemd unit as PIDFile.
Diffstat (limited to 'test/system')
-rw-r--r--test/system/250-generate-systemd.bats46
-rw-r--r--test/system/helpers.bash11
2 files changed, 57 insertions, 0 deletions
diff --git a/test/system/250-generate-systemd.bats b/test/system/250-generate-systemd.bats
new file mode 100644
index 000000000..80199af5f
--- /dev/null
+++ b/test/system/250-generate-systemd.bats
@@ -0,0 +1,46 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# Tests generated configurations for systemd.
+#
+
+load helpers
+
+# Be extra paranoid in naming to avoid collisions.
+SERVICE_NAME="podman_test_$(random_string)"
+UNIT_DIR="$HOME/.config/systemd/user"
+UNIT_FILE="$UNIT_DIR/$SERVICE_NAME.service"
+
+function setup() {
+ skip_if_not_systemd
+ skip_if_remote
+
+ basic_setup
+
+ if [ ! -d "$UNIT_DIR" ]; then
+ mkdir -p "$UNIT_DIR"
+ systemctl --user daemon-reload
+ fi
+}
+
+function teardown() {
+ rm -f "$UNIT_FILE"
+ systemctl --user stop "$SERVICE_NAME"
+ basic_teardown
+}
+
+@test "podman generate - systemd - basic" {
+ run_podman create $IMAGE echo "I'm alive!"
+ cid="$output"
+
+ run_podman generate systemd $cid > "$UNIT_FILE"
+
+ run systemctl --user start "$SERVICE_NAME"
+ if [ $status -ne 0 ]; then
+ die "The systemd service $SERVICE_NAME did not start correctly, output: $output"
+ fi
+
+ run_podman logs $cid
+ is "$output" "I'm alive!" "Container output"
+}
+
+# vim: filetype=sh
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 29ef19ecc..1db80f111 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -236,6 +236,17 @@ function skip_if_remote() {
skip "${1:-test does not work with podman-remote}"
}
+#########################
+# skip_if_not_systemd # ...with an optional message
+#########################
+function skip_if_not_systemd() {
+ if systemctl --user >/dev/null 2>&1; then
+ return
+ fi
+
+ skip "${1:-no systemd or daemon does not respond}"
+}
+
#########
# die # Abort with helpful message
#########