summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/apiv2/test-apiv221
-rwxr-xr-xtest/buildah-bud/apply-podman-deltas21
-rw-r--r--test/buildah-bud/buildah-tests.diff25
-rwxr-xr-xtest/buildah-bud/run-buildah-bud-tests6
-rw-r--r--test/e2e/common_test.go2
-rw-r--r--test/e2e/run_volume_test.go14
-rw-r--r--test/e2e/systemd_activate_test.go51
-rw-r--r--test/system/250-systemd.bats25
-rw-r--r--test/system/helpers.systemd.bash4
9 files changed, 139 insertions, 30 deletions
diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2
index 8ecc2aa2d..25f648d93 100755
--- a/test/apiv2/test-apiv2
+++ b/test/apiv2/test-apiv2
@@ -380,6 +380,17 @@ function start_service() {
die "Cannot start service on non-localhost ($HOST)"
fi
+ # FIXME: EXPERIMENTAL: 2022-06-13: podman rootless needs a namespace. If
+ # system-service is the first podman command run (as is the case in CI)
+ # this will happen as a fork-exec, where the parent podman creates the
+ # namespace and the child is the server. Then, when stop_service() kills
+ # the parent, the child (server) happily stays alive and ruins subsequent
+ # tests that try to restart service with different settings.
+ # Workaround: run an unshare to get namespaces initialized.
+ if [[ $(id -u) != 0 ]]; then
+ $PODMAN_BIN unshare true
+ fi
+
$PODMAN_BIN \
--root $WORKDIR/server_root --syslog=true \
system service \
@@ -387,6 +398,7 @@ function start_service() {
tcp:127.0.0.1:$PORT \
&> $WORKDIR/server.log &
service_pid=$!
+ echo "# started service, pid $service_pid"
wait_for_port $HOST $PORT
}
@@ -396,7 +408,14 @@ function stop_service() {
if [[ -n $service_pid ]]; then
kill $service_pid || :
wait $service_pid || :
+ echo "# stopped service, pid $service_pid"
fi
+ service_pid=
+
+ if { exec 3<> /dev/tcp/$HOST/$PORT; } &>/dev/null; then
+ echo "# WARNING: stop_service: Service still running on port $PORT"
+ fi
+
}
####################
@@ -468,6 +487,7 @@ function start_registry() {
${REGISTRY_IMAGE}
wait_for_port localhost $REGISTRY_PORT 10
+ echo "# started registry (auth=$auth) on port $PORT"
}
function stop_registry() {
@@ -482,6 +502,7 @@ function stop_registry() {
if [[ "$1" = "--cleanup" ]]; then
podman $OPTS rmi -f -a
fi
+ echo "# stopped registry on port $PORT"
fi
REGISTRY_PORT=
diff --git a/test/buildah-bud/apply-podman-deltas b/test/buildah-bud/apply-podman-deltas
index 0bde060ed..0b691dd0e 100755
--- a/test/buildah-bud/apply-podman-deltas
+++ b/test/buildah-bud/apply-podman-deltas
@@ -155,13 +155,7 @@ errmsg "checking authfile: stat /tmp/nonexistent: no such file or directory" \
###############################################################################
# BEGIN tests that don't make sense under podman due to fundamental differences
-# TODO
-# Normally, when buildah exits 1 on error, podman exits 125.
-# These tests are the exception. They exit 1 under podman.
-skip "these tests exit 1 under podman, not 125" \
- "bud with --add-host" \
- "bud - invalid runtime flags test"
-
+# Fails with "Error: no context directory and no Containerfile specified"
skip "does not work under podman" \
"bud without any arguments should succeed"
@@ -172,8 +166,9 @@ skip "does not work under podman" \
skip "FIXME FIXME FIXME: argument-order incompatible with podman" \
"bud-squash-hardlinks"
-skip "FIXME FIXME FIXME: this passes on Ed's laptop, fails in CI??" \
- "bud-multi-stage-nocache-nocommit"
+# Fails with "Error: context must be a directory: /path/to/Dockerfile"
+skip "podman-build fails with 'context must be a directory'" \
+ "bud with specified context should succeed if context contains existing Dockerfile"
###############################################################################
# BEGIN tests which are skipped because they make no sense under podman-remote
@@ -240,4 +235,12 @@ skip_if_remote "FIXME FIXME FIXME: find a way to clean up their podman calls" \
"bud with run should not leave mounts behind cleanup test" \
"bud with custom files in /run/ should persist cleanup test"
+# Under podman-remote, the "Ignoring <stdin>:5:2: error: #error" message
+# is never seen. (Not even as stdout/stderr on the server; Ed checked).
+skip_if_remote "FIXME FIXME FIXME: 'Ignoring' warning is never seen" \
+ "bud with preprocessor error"
+
+# END tests which are skipped due to actual podman or podman-remote bugs.
+###############################################################################
+
exit $RC
diff --git a/test/buildah-bud/buildah-tests.diff b/test/buildah-bud/buildah-tests.diff
index 6fa36d904..399042240 100644
--- a/test/buildah-bud/buildah-tests.diff
+++ b/test/buildah-bud/buildah-tests.diff
@@ -1,15 +1,15 @@
-From 8a8fa1a75e0fa3261263afbc8c2504feb430df6a Mon Sep 17 00:00:00 2001
+From 6508e3df2a129554fdf8336d8a6f0cdcc6fd4832 Mon Sep 17 00:00:00 2001
From: Ed Santiago <santiago@redhat.com>
Date: Tue, 9 Feb 2021 17:28:05 -0700
Subject: [PATCH] tweaks for running buildah tests under podman
Signed-off-by: Ed Santiago <santiago@redhat.com>
---
- tests/helpers.bash | 69 ++++++++++++++++++++++++++++++++++++++++++++--
- 1 file changed, 66 insertions(+), 3 deletions(-)
+ tests/helpers.bash | 70 ++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 67 insertions(+), 3 deletions(-)
diff --git a/tests/helpers.bash b/tests/helpers.bash
-index e3087063..b3a8f5ee 100644
+index e3087063..178a486e 100644
--- a/tests/helpers.bash
+++ b/tests/helpers.bash
@@ -51,6 +51,23 @@ EOF
@@ -60,13 +60,13 @@ index e3087063..b3a8f5ee 100644
# There are various scenarios where we would like to execute `tests` as rootless user, however certain commands like `buildah mount`
# do not work in rootless session since a normal user cannot mount a filesystem unless they're in a user namespace along with its
# own mount namespace. In order to run such specific commands from a rootless session we must perform `buildah unshare`.
-@@ -247,8 +274,35 @@ function run_buildah() {
+@@ -247,8 +274,36 @@ function run_buildah() {
--retry) retry=3; shift;; # retry network flakes
esac
+ local podman_or_buildah=${BUILDAH_BINARY}
+ local _opts="${ROOTDIR_OPTS} ${BUILDAH_REGISTRY_OPTS}"
-+ if [[ $1 == "build" || $1 == "build-using-dockerfile" ]]; then
++ if [[ $1 == "build" || $1 == "build-using-dockerfile" || $1 == "bud" ]]; then
+ shift
+ # podman defaults to --layers=true; buildah to --false.
+ # If command line includes explicit --layers, leave it untouched,
@@ -82,10 +82,11 @@ index e3087063..b3a8f5ee 100644
+ _opts=
+ fi
+
-+ # podman always exits 125 where buildah exits 1 or 2 (or, in the
-+ # case of git, 128, which is a bug in git, but I won't harp on that).
++ # Special case: there's one test that invokes git in such
++ # a way that it exits 128 (which IMO is a bug in git).
++ # podman exits 125 in that case.
+ case $expected_rc in
-+ 1|2|128) expected_rc=125 ;;
++ 128) expected_rc=125 ;;
+ esac
+ fi
+ local cmd_basename=$(basename ${podman_or_buildah})
@@ -97,7 +98,7 @@ index e3087063..b3a8f5ee 100644
# If session is rootless and `buildah mount` is invoked, perform unshare,
# since normal user cannot mount a filesystem unless they're in a user namespace along with its own mount namespace.
-@@ -262,8 +316,8 @@ function run_buildah() {
+@@ -262,8 +317,8 @@ function run_buildah() {
retry=$(( retry - 1 ))
# stdout is only emitted upon error; this echo is to help a debugger
@@ -108,7 +109,7 @@ index e3087063..b3a8f5ee 100644
# without "quotes", multiple lines are glommed together into one
if [ -n "$output" ]; then
echo "$output"
-@@ -595,6 +649,15 @@ function skip_if_no_docker() {
+@@ -595,6 +650,15 @@ function skip_if_no_docker() {
fi
}
@@ -125,5 +126,5 @@ index e3087063..b3a8f5ee 100644
daemondir=${TEST_SCRATCH_DIR}/git-daemon
mkdir -p ${daemondir}/repo
--
-2.35.1
+2.35.3
diff --git a/test/buildah-bud/run-buildah-bud-tests b/test/buildah-bud/run-buildah-bud-tests
index eb8de5618..4ff062496 100755
--- a/test/buildah-bud/run-buildah-bud-tests
+++ b/test/buildah-bud/run-buildah-bud-tests
@@ -93,6 +93,12 @@ fi
# From here on out, any error is fatal
set -e
+# Run sudo early, to refresh the credentials cache. This is a NOP under CI,
+# but might be appreciated by developers who run this script, step away
+# during the git-checkout-buildah step, then come back twenty minutes later
+# to an expired sudo prompt and no tests have run.
+sudo --validate
+
# Before pulling buildah (while still cd'ed to podman repo), try to determine
# if this is a PR, and if so if it's a revendoring of buildah. We use this to
# try to offer a helpful hint on failure.
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index db194b777..194d592f4 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -41,7 +41,7 @@ var (
CGROUP_MANAGER = "systemd" //nolint:revive,stylecheck
RESTORE_IMAGES = []string{ALPINE, BB, nginx} //nolint:revive,stylecheck
defaultWaitTimeout = 90
- CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode() //nolint:revive,stylecheck
+ CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode()
)
// PodmanTestIntegration struct for command line options
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 1c0480407..f31e62e42 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -908,6 +908,20 @@ USER testuser`, fedoraMinimal)
Expect(session.OutputToString()).To(Equal(perms))
})
+ It("podman run with -v $SRC:/run does not create /run/.containerenv", func() {
+ mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1")
+ err := os.MkdirAll(mountSrc, 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"run", "-v", mountSrc + ":/run", ALPINE, "true"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // the file should not have been created
+ _, err = os.Stat(filepath.Join(mountSrc, ".containerenv"))
+ Expect(err).To(Not(BeNil()))
+ })
+
It("podman volume with uid and gid works", func() {
volName := "testVol"
volCreate := podmanTest.Podman([]string{"volume", "create", "--opt", "o=uid=1000", volName})
diff --git a/test/e2e/systemd_activate_test.go b/test/e2e/systemd_activate_test.go
index aeea4f932..c50e43b8d 100644
--- a/test/e2e/systemd_activate_test.go
+++ b/test/e2e/systemd_activate_test.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/fs"
+ "net"
"os"
"os/exec"
"path/filepath"
@@ -21,6 +22,7 @@ var _ = Describe("Systemd activate", func() {
var tempDir string
var err error
var podmanTest *PodmanTestIntegration
+ var activate string
BeforeEach(func() {
tempDir, err = testUtils.CreateTempDirInTempDir()
@@ -31,17 +33,10 @@ var _ = Describe("Systemd activate", func() {
podmanTest = PodmanTestCreate(tempDir)
podmanTest.Setup()
- })
- AfterEach(func() {
- podmanTest.Cleanup()
- processTestResult(CurrentGinkgoTestDescription())
- })
-
- It("stop podman.service", func() {
SkipIfRemote("Testing stopped service requires both podman and podman-remote binaries")
- activate, err := exec.LookPath("systemd-socket-activate")
+ activate, err = exec.LookPath("systemd-socket-activate")
if err != nil {
activate = "/usr/bin/systemd-socket-activate"
}
@@ -54,7 +49,14 @@ var _ = Describe("Systemd activate", func() {
case err != nil:
Skip(err.Error())
}
+ })
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ processTestResult(CurrentGinkgoTestDescription())
+ })
+
+ It("stop podman.service", func() {
// systemd-socket-activate does not support DNS lookups
host := "127.0.0.1"
port, err := podmanUtils.GetRandomPort()
@@ -103,4 +105,37 @@ var _ = Describe("Systemd activate", func() {
Expect(abiSession).To(Exit(0))
Expect(abiSession.OutputToString()).To(Equal("true"))
})
+
+ It("invalid systemd file descriptor", func() {
+ host := "127.0.0.1"
+ port, err := podmanUtils.GetRandomPort()
+ Expect(err).ToNot(HaveOccurred())
+
+ addr := fmt.Sprintf("%s:%d", host, port)
+
+ // start systemd activation with datagram socket
+ activateSession := testUtils.StartSystemExec(activate, []string{
+ "--datagram", "--listen", addr,
+ podmanTest.PodmanBinary,
+ "--root=" + filepath.Join(tempDir, "server_root"),
+ "system", "service",
+ "--time=0",
+ })
+ Expect(activateSession.Exited).ShouldNot(Receive(), "Failed to start podman service")
+
+ // we have to wait for systemd-socket-activate to become ready
+ time.Sleep(1 * time.Second)
+
+ // now dial the socket to start podman
+ conn, err := net.Dial("udp", addr)
+ Expect(err).ToNot(HaveOccurred())
+ defer conn.Close()
+ _, err = conn.Write([]byte("test"))
+ Expect(err).ToNot(HaveOccurred())
+
+ // wait for podman to exit
+ activateSession.Wait(10)
+ Expect(activateSession).To(Exit(125))
+ Expect(activateSession.ErrorToString()).To(ContainSubstring("Error: unexpected fd received from systemd: cannot listen on it"))
+ })
})
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 110d425d2..cf57d2589 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -362,4 +362,29 @@ EOF
run_podman 1 pod exists test_pod
}
+@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
+}
+
# vim: filetype=sh
diff --git a/test/system/helpers.systemd.bash b/test/system/helpers.systemd.bash
index 4bde912a4..d9abc087d 100644
--- a/test/system/helpers.systemd.bash
+++ b/test/system/helpers.systemd.bash
@@ -28,3 +28,7 @@ systemctl() {
journalctl() {
command journalctl $_DASHUSER "$@"
}
+
+systemd-run() {
+ command systemd-run $_DASHUSER "$@";
+}