summaryrefslogtreecommitdiff
path: root/test/system/270-socket-activation.bats
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2021-07-20 08:24:37 -0600
committerEd Santiago <santiago@redhat.com>2021-07-20 08:57:26 -0600
commit313c7118eadca28ff6f0121f43f56687b36d3849 (patch)
tree71de7e9499b5ec32f7a911450c1c293804c7e723 /test/system/270-socket-activation.bats
parent4fb4614cf14a362c047b17612488fbdc0dc8e253 (diff)
downloadpodman-313c7118eadca28ff6f0121f43f56687b36d3849.tar.gz
podman-313c7118eadca28ff6f0121f43f56687b36d3849.tar.bz2
podman-313c7118eadca28ff6f0121f43f56687b36d3849.zip
system tests: cleaner, safer use of systemd
First and foremost: use ephemeral (/run, $XDG) directories for systemd unit files, so as not to vandalize a working system. Second, refactor common systemd-related functionality into a new helper file, loaded by the systemd-related tests. Shared functionality includes: * setting $XDG_RUNTIME_DIR if unset and rootless * setting $UNIT_DIR for use by tests * new systemctl() and journalctl() functions, which include "--user" when rootless (why can't systemd figure this out on its own?) Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/system/270-socket-activation.bats')
-rw-r--r--test/system/270-socket-activation.bats17
1 files changed, 4 insertions, 13 deletions
diff --git a/test/system/270-socket-activation.bats b/test/system/270-socket-activation.bats
index 25206c6a7..031ba161b 100644
--- a/test/system/270-socket-activation.bats
+++ b/test/system/270-socket-activation.bats
@@ -4,21 +4,12 @@
#
load helpers
+load helpers.systemd
SERVICE_NAME="podman_test_$(random_string)"
-SYSTEMCTL="systemctl"
-UNIT_DIR="/usr/lib/systemd/system"
SERVICE_SOCK_ADDR="/run/podman/podman.sock"
-
if is_rootless; then
- UNIT_DIR="$HOME/.config/systemd/user"
- mkdir -p $UNIT_DIR
-
- SYSTEMCTL="$SYSTEMCTL --user"
- if [ -z "$XDG_RUNTIME_DIR" ]; then
- export XDG_RUNTIME_DIR=/run/user/$(id -u)
- fi
SERVICE_SOCK_ADDR="$XDG_RUNTIME_DIR/podman/podman.sock"
fi
@@ -66,13 +57,13 @@ EOF
rm -f $pause_pid
fi
fi
- $SYSTEMCTL start "$SERVICE_NAME.socket"
+ systemctl start "$SERVICE_NAME.socket"
}
function teardown() {
- $SYSTEMCTL stop "$SERVICE_NAME.socket"
+ systemctl stop "$SERVICE_NAME.socket"
rm -f "$SERVICE_FILE" "$SOCKET_FILE"
- $SYSTEMCTL daemon-reload
+ systemctl daemon-reload
basic_teardown
}