mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-19 06:47:51 +00:00
This commit was automatically cherry-picked by buildah-vendor-treadmill v0.3 from the buildah vendor treadmill PR, #13808 Changes since 2022-08-16: - buildah 4139: minor line-number changes to the diff file because helpers.bash got edited - buildah 4190: skip the new test if remote - buildah 4195: add --retry / --retry-delay - changes to deal with vendoring gomega, units - changes to the podman login error message in system test Signed-off-by: Paul Holzinger <pholzing@redhat.com>
130 lines
5.5 KiB
Diff
130 lines
5.5 KiB
Diff
From d22e44c8fb1c87afb90391188733f7ce8fea005d 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 | 70 ++++++++++++++++++++++++++++++++++++++++++++--
|
|
1 file changed, 67 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/tests/helpers.bash b/tests/helpers.bash
|
|
index 8cb93c3a..72c1c797 100644
|
|
--- a/tests/helpers.bash
|
|
+++ b/tests/helpers.bash
|
|
@@ -52,6 +52,23 @@ EOF
|
|
ROOTDIR_OPTS="--root ${TEST_SCRATCH_DIR}/root --runroot ${TEST_SCRATCH_DIR}/runroot --storage-driver ${STORAGE_DRIVER}"
|
|
BUILDAH_REGISTRY_OPTS="--registries-conf ${TEST_SOURCES}/registries.conf --registries-conf-dir ${TEST_SCRATCH_DIR}/registries.d --short-name-alias-conf ${TEST_SCRATCH_DIR}/cache/shortnames.conf"
|
|
PODMAN_REGISTRY_OPTS="--registries-conf ${TEST_SOURCES}/registries.conf"
|
|
+
|
|
+ PODMAN_SERVER_PID=
|
|
+ PODMAN_NATIVE="${PODMAN_BINARY} ${ROOTDIR_OPTS} ${PODMAN_REGISTRY_OPTS}"
|
|
+ if [[ -n "$REMOTE" ]]; then
|
|
+ PODMAN_NATIVE="${PODMAN_BINARY%%-remote} ${ROOTDIR_OPTS} ${PODMAN_REGISTRY_OPTS}"
|
|
+ # static CONTAINERS_CONF needed for capabilities test. As of 2021-07-01
|
|
+ # no tests in bud.bats override this; if at some point any test does
|
|
+ # so, it will probably need to be skip_if_remote()d.
|
|
+ env CONTAINERS_CONF=${CONTAINERS_CONF:-$(dirname ${BASH_SOURCE})/containers.conf} $PODMAN_NATIVE system service --timeout=0 &
|
|
+ PODMAN_SERVER_PID=$!
|
|
+ local timeout=10
|
|
+ while ((timeout > 0)); do
|
|
+ test -S /run/podman/podman.sock && return
|
|
+ sleep 0.2
|
|
+ done
|
|
+ die "podman server never came up"
|
|
+ fi
|
|
}
|
|
|
|
function starthttpd() {
|
|
@@ -95,6 +112,12 @@ function teardown_tests() {
|
|
stop_git_daemon
|
|
stop_registry
|
|
|
|
+ if [[ -n "$PODMAN_SERVER_PID" ]]; then
|
|
+ kill $PODMAN_SERVER_PID
|
|
+ wait $PODMAN_SERVER_PID
|
|
+ rm -f /run/podman/podman.sock
|
|
+ fi
|
|
+
|
|
# Workaround for #1991 - buildah + overlayfs leaks mount points.
|
|
# Many tests leave behind /var/tmp/.../root/overlay and sub-mounts;
|
|
# let's find those and clean them up, otherwise 'rm -rf' fails.
|
|
@@ -187,6 +210,10 @@ function podman() {
|
|
command ${PODMAN_BINARY:-podman} ${PODMAN_REGISTRY_OPTS} ${ROOTDIR_OPTS} "$@"
|
|
}
|
|
|
|
+function podman-remote() {
|
|
+ command ${PODMAN_BINARY:-podman-remote} ${ROOTDIR_OPTS} "$@"
|
|
+}
|
|
+
|
|
# 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`.
|
|
@@ -248,8 +275,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" || $1 == "bud" ]]; then
|
|
+ shift
|
|
+ # podman defaults to --layers=true; buildah to --false.
|
|
+ # If command line includes explicit --layers, leave it untouched,
|
|
+ # but otherwise update command line so podman mimics buildah default.
|
|
+ if [[ "$*" =~ --layers || "$*" =~ --squash ]]; then
|
|
+ set "build" "--force-rm=false" "$@"
|
|
+ else
|
|
+ set "build" "--force-rm=false" "--layers=false" "$@"
|
|
+ fi
|
|
+ podman_or_buildah=${PODMAN_BINARY}
|
|
+ _opts="${ROOTDIR_OPTS} ${PODMAN_REGISTRY_OPTS}"
|
|
+ if [[ -n "$REMOTE" ]]; then
|
|
+ _opts=
|
|
+ fi
|
|
+
|
|
+ # 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
|
|
+ 128) expected_rc=125 ;;
|
|
+ esac
|
|
+ fi
|
|
+ local cmd_basename=$(basename ${podman_or_buildah})
|
|
+
|
|
+
|
|
# Remember command args, for possible use in later diagnostic messages
|
|
- MOST_RECENT_BUILDAH_COMMAND="buildah $*"
|
|
+ MOST_RECENT_BUILDAH_COMMAND="$cmd_basename $*"
|
|
|
|
# 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.
|
|
@@ -263,8 +318,8 @@ function run_buildah() {
|
|
retry=$(( retry - 1 ))
|
|
|
|
# stdout is only emitted upon error; this echo is to help a debugger
|
|
- echo "\$ $BUILDAH_BINARY $*"
|
|
- run env CONTAINERS_CONF=${CONTAINERS_CONF:-$(dirname ${BASH_SOURCE})/containers.conf} timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${BUILDAH_BINARY} ${BUILDAH_REGISTRY_OPTS} ${ROOTDIR_OPTS} "$@"
|
|
+ echo "\$ $cmd_basename $*"
|
|
+ run env CONTAINERS_CONF=${CONTAINERS_CONF:-$(dirname ${BASH_SOURCE})/containers.conf} timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${podman_or_buildah} ${_opts} "$@"
|
|
# without "quotes", multiple lines are glommed together into one
|
|
if [ -n "$output" ]; then
|
|
echo "$output"
|
|
@@ -596,6 +651,15 @@ function skip_if_no_docker() {
|
|
fi
|
|
}
|
|
|
|
+####################
|
|
+# skip_if_remote # (only applicable for podman)
|
|
+####################
|
|
+function skip_if_remote() {
|
|
+ if [[ -n "$REMOTE" ]]; then
|
|
+ skip "${1:-test does not work with podman-remote}"
|
|
+ fi
|
|
+}
|
|
+
|
|
function start_git_daemon() {
|
|
daemondir=${TEST_SCRATCH_DIR}/git-daemon
|
|
mkdir -p ${daemondir}/repo
|
|
--
|
|
2.36.1
|
|
|