summaryrefslogtreecommitdiff
path: root/test/system/250-systemd.bats
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-11 18:19:07 +0200
committerGitHub <noreply@github.com>2020-05-11 18:19:07 +0200
commit7837bf3c071f1259bc08d8f9e52ed2b4edbda428 (patch)
treec499fd2c5913c37dad650e8a82789d2ab653b8f0 /test/system/250-systemd.bats
parentd8c6cc16843efac13b92758b1bf93e9d5897a212 (diff)
parenta82de0e3a039bb23d3a9bdb0a1cb9a56d5cec5df (diff)
downloadpodman-7837bf3c071f1259bc08d8f9e52ed2b4edbda428.tar.gz
podman-7837bf3c071f1259bc08d8f9e52ed2b4edbda428.tar.bz2
podman-7837bf3c071f1259bc08d8f9e52ed2b4edbda428.zip
Merge pull request #6176 from edsantiago/bats_more
Some BATS cleanup: run and systemd tests
Diffstat (limited to 'test/system/250-systemd.bats')
-rw-r--r--test/system/250-systemd.bats39
1 files changed, 30 insertions, 9 deletions
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 902a7cad8..cdac43c1c 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -6,44 +6,65 @@
load helpers
SERVICE_NAME="podman_test_$(random_string)"
+
+SYSTEMCTL="systemctl"
UNIT_DIR="/usr/lib/systemd/system"
+if is_rootless; then
+ UNIT_DIR="$HOME/.config/systemd/user"
+ mkdir -p $UNIT_DIR
+
+ SYSTEMCTL="$SYSTEMCTL --user"
+fi
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() {
+ run '?' $SYSTEMCTL stop "$SERVICE_NAME"
rm -f "$UNIT_FILE"
- systemctl daemon-reload
+ $SYSTEMCTL daemon-reload
basic_teardown
}
+# This test can fail in dev. environment because of SELinux.
+# quick fix: chcon -t container_runtime_exec_t ./bin/podman
@test "podman generate - systemd - basic" {
- run_podman create --name keepme --detach busybox:latest top
+ cname=$(random_string)
+ run_podman create --name $cname --detach $IMAGE top
- run_podman generate systemd --new keepme > "$UNIT_FILE"
- run_podman rm keepme
+ run_podman generate systemd --new $cname
+ echo "$output" > "$UNIT_FILE"
+ run_podman rm $cname
- systemctl daemon-reload
+ $SYSTEMCTL daemon-reload
- run systemctl start "$SERVICE_NAME"
+ 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"
+ 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"
+ # Give container time to start; make sure output looks top-like
+ sleep 2
+ run_podman logs $cname
+ is "$output" ".*Load average:.*" "running container 'top'-like output"
+
+ # All good. Stop service, clean up.
+ run $SYSTEMCTL stop "$SERVICE_NAME"
if [ $status -ne 0 ]; then
die "Error stopping systemd unit $SERVICE_NAME, output: $output"
fi
+
+ rm -f "$UNIT_FILE"
+ $SYSTEMCTL daemon-reload
}
# vim: filetype=sh