diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-07-19 15:13:09 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 15:13:09 +0000 |
commit | 6d9f34c6301910892f7746dc93b226f7c16f8c2c (patch) | |
tree | 50546c7891ddb04656f96ab42caa1b0c7abb7e8e | |
parent | 21cf30f2f895a3c453760f800077b8f7dbfce23c (diff) | |
parent | 1f0116817da3cbdd8ba75c2ede4c148bca7f296a (diff) | |
download | podman-6d9f34c6301910892f7746dc93b226f7c16f8c2c.tar.gz podman-6d9f34c6301910892f7746dc93b226f7c16f8c2c.tar.bz2 podman-6d9f34c6301910892f7746dc93b226f7c16f8c2c.zip |
Merge pull request #14961 from edsantiago/systemd_test_cleanup
system tests: new system-service bats file
-rw-r--r-- | test/system/250-systemd.bats | 46 | ||||
-rw-r--r-- | test/system/251-system-service.bats | 58 |
2 files changed, 58 insertions, 46 deletions
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 70ae76eb8..9a91501dd 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -296,8 +296,6 @@ LISTEN_FDNAMES=listen_fdnames" | sort) } @test "podman-kube@.service template" { - skip_if_remote "systemd units do not work with remote clients" - # If running from a podman source directory, build and use the source # version of the play-kube-@ unit file unit_name="podman-kube@.service" @@ -375,48 +373,4 @@ EOF rm -f $UNIT_DIR/$unit_name } -@test "podman-system-service containers survive service stop" { - skip_if_remote "N/A under podman-remote" - - SERVICE_NAME=podman-service-$(random_string) - port=$(random_free_port) - URL=tcp://127.0.0.1:$port - - systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 - wait_for_port 127.0.0.1 $port - - # Start a long-running container. - cname=keeps-running - run_podman --url $URL run -d --name $cname $IMAGE top -d 2 - - run_podman container inspect -l --format "{{.State.Running}}" - is "$output" "true" "This should never fail" - - systemctl stop $SERVICE_NAME - - run_podman container inspect $cname --format "{{.State.Running}}" - is "$output" "true" "Container is still running after podman server stops" - - run_podman rm -f -t 0 $cname -} - -@test "podman-system-service containers --host" { - skip_if_remote "N/A under podman-remote" - - SERVICE_NAME=podman-service-$(random_string) - port=$(random_free_port) - URL=tcp://127.0.0.1:$port - - systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 - wait_for_port 127.0.0.1 $port - - run_podman --host $URL run --rm $IMAGE true - run_podman -H $URL run --rm $IMAGE true - - systemctl stop $SERVICE_NAME - - # Make sure the option is actually connecting - run_podman 125 --host $URL run --rm $IMAGE true - assert "$output" =~ "Cannot connect to Podman.*connection refused" -} # vim: filetype=sh diff --git a/test/system/251-system-service.bats b/test/system/251-system-service.bats new file mode 100644 index 000000000..edee4a28c --- /dev/null +++ b/test/system/251-system-service.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats -*- bats -*- +# +# Tests that require 'podman system service' but no other systemd aspects + +load helpers +load helpers.systemd + +SERVICE_NAME="podman-service-$(random_string)" + +function teardown() { + # Ignore exit status: this is just a backup stop in case tests failed + run systemctl stop "$SERVICE_NAME" + + basic_teardown +} + + +@test "podman-system-service containers survive service stop" { + skip_if_remote "podman system service unavailable over remote" + + port=$(random_free_port) + URL=tcp://127.0.0.1:$port + + systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 + wait_for_port 127.0.0.1 $port + + # Start a long-running container. + cname=keeps-running + run_podman --url $URL run -d --name $cname $IMAGE top -d 2 + + run_podman container inspect -l --format "{{.State.Running}}" + is "$output" "true" "This should never fail" + + systemctl stop $SERVICE_NAME + + run_podman container inspect $cname --format "{{.State.Running}}" + is "$output" "true" "Container is still running after podman server stops" + + run_podman rm -f -t 0 $cname +} + +# This doesn't actually test podman system service, but we require it, +# so least-awful choice is to run from this test file. +@test "podman --host / -H options" { + port=$(random_free_port) + URL=tcp://127.0.0.1:$port + + # %%-remote makes this run real podman even when testing podman-remote + systemd-run --unit=$SERVICE_NAME ${PODMAN%%-remote*} system service $URL --time=0 + wait_for_port 127.0.0.1 $port + + for opt in --host -H; do + run_podman $opt $URL info --format '{{.Host.RemoteSocket.Path}}' + is "$output" "$URL" "RemoteSocket.Path using $opt" + done + + systemctl stop $SERVICE_NAME +} |