summaryrefslogtreecommitdiff
path: root/test/system/250-systemd.bats
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-05-08 11:50:07 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-05-08 13:05:25 +0200
commit42c6aa1a4281d0ac1fc70fc95cca97506b25477e (patch)
tree44f002eacaddf7bc11cd4823ecfe7011ec79b6a9 /test/system/250-systemd.bats
parentff1c59065e9d2ef0c03ce8de444b489630d00b3c (diff)
downloadpodman-42c6aa1a4281d0ac1fc70fc95cca97506b25477e.tar.gz
podman-42c6aa1a4281d0ac1fc70fc95cca97506b25477e.tar.bz2
podman-42c6aa1a4281d0ac1fc70fc95cca97506b25477e.zip
fix and enable systemd system tests
The systemd unit test never ran in CI and was broken for various reasons. Fix the test to execute Podman in systemd units and to also run generated units files. Note: more tests will be added in the future. The simple check for now will prevent regressions. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test/system/250-systemd.bats')
-rw-r--r--test/system/250-systemd.bats49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
new file mode 100644
index 000000000..902a7cad8
--- /dev/null
+++ b/test/system/250-systemd.bats
@@ -0,0 +1,49 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# Tests generated configurations for systemd.
+#
+
+load helpers
+
+SERVICE_NAME="podman_test_$(random_string)"
+UNIT_DIR="/usr/lib/systemd/system"
+UNIT_FILE="$UNIT_DIR/$SERVICE_NAME.service"
+
+function setup() {
+ skip_if_remote
+ skip_if_rootless "systemd tests are root-only for now"
+
+ basic_setup
+}
+
+function teardown() {
+ rm -f "$UNIT_FILE"
+ systemctl daemon-reload
+ basic_teardown
+}
+
+@test "podman generate - systemd - basic" {
+ run_podman create --name keepme --detach busybox:latest top
+
+ run_podman generate systemd --new keepme > "$UNIT_FILE"
+ run_podman rm keepme
+
+ systemctl daemon-reload
+
+ run systemctl start "$SERVICE_NAME"
+ if [ $status -ne 0 ]; then
+ die "Error starting systemd unit $SERVICE_NAME, output: $output"
+ fi
+
+ run systemctl status "$SERVICE_NAME"
+ if [ $status -ne 0 ]; then
+ die "Non-zero status of systemd unit $SERVICE_NAME, output: $output"
+ fi
+
+ run systemctl stop "$SERVICE_NAME"
+ if [ $status -ne 0 ]; then
+ die "Error stopping systemd unit $SERVICE_NAME, output: $output"
+ fi
+}
+
+# vim: filetype=sh