diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/login_logout_test.go | 1 | ||||
-rw-r--r-- | test/e2e/runlabel_test.go | 1 | ||||
-rw-r--r-- | test/system/030-run.bats | 16 | ||||
-rw-r--r-- | test/system/250-generate-systemd.bats | 48 | ||||
-rw-r--r-- | test/system/250-systemd.bats | 49 | ||||
-rw-r--r-- | test/system/helpers.bash | 11 |
6 files changed, 65 insertions, 61 deletions
diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index dd35d8489..3f76daa67 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman login and logout", func() { ) BeforeEach(func() { - Skip(v2fail) tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index 83fdcabc9..41d61e9d9 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -31,7 +31,6 @@ var _ = Describe("podman container runlabel", func() { ) BeforeEach(func() { - Skip(v2fail) tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 56e9fed3b..d5d5121f8 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -158,4 +158,20 @@ echo $rand | 0 | $rand run_podman 1 image exists $NONLOCAL_IMAGE } +# 'run --conmon-pidfile --cid-file' makes sure we don't regress on these flags. +# Both are critical for systemd units. +@test "podman run --conmon-pidfile --cidfile" { + pid=$(mktemp) + cid=$(mktemp) + + # CID file exists -> expected to fail. + run_podman 125 run --rm --conmon-pidfile=$pid --cidfile=$cid $IMAGE ls + + rm $pid $cid + run_podman run --name keepme --conmon-pidfile=$pid --cidfile=$cid --detach $IMAGE sleep infinity + stat $pid $cid + run_podman rm -f keepme + rm $pid $cid +} + # vim: filetype=sh diff --git a/test/system/250-generate-systemd.bats b/test/system/250-generate-systemd.bats deleted file mode 100644 index 6155d6ace..000000000 --- a/test/system/250-generate-systemd.bats +++ /dev/null @@ -1,48 +0,0 @@ -#!/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" - -# FIXME: the must run as root (because of CI). It's also broken... - -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/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 diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 51240edc9..7ec2105d1 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -252,17 +252,6 @@ function skip_if_remote() { fi } -######################### -# 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 ######### |