-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallelize buildah bud tests #24656
Open
edsantiago
wants to merge
2
commits into
containers:main
Choose a base branch
from
edsantiago:parallel-bud
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
From d7839d93860915b2a43c486d0fed89fee7313ec0 Mon Sep 17 00:00:00 2001 | ||
From 42a2977ef907112fd48575bcf69aef7847726a9b Mon Sep 17 00:00:00 2001 | ||
From: Ed Santiago <[email protected]> | ||
Date: Thu, 6 Oct 2022 17:32:59 -0600 | ||
Subject: [PATCH] tweaks for running buildah tests under podman | ||
|
||
Signed-off-by: Ed Santiago <[email protected]> | ||
--- | ||
tests/helpers.bash | 119 +++++++++++++++++++++++++++++++++++++++++++-- | ||
1 file changed, 115 insertions(+), 4 deletions(-) | ||
tests/helpers.bash | 126 +++++++++++++++++++++++++++++++++++++++++++-- | ||
1 file changed, 122 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/tests/helpers.bash b/tests/helpers.bash | ||
index f8ab624a8..0d8f5ce69 100644 | ||
index ed5de994e..8f82a9fd4 100644 | ||
--- a/tests/helpers.bash | ||
+++ b/tests/helpers.bash | ||
@@ -80,6 +80,38 @@ EOF | ||
@@ -80,6 +80,42 @@ EOF | ||
BUILDAH_REGISTRY_OPTS="${regconfopt} ${regconfdir} --short-name-alias-conf ${TEST_SCRATCH_DIR}/cache/shortnames.conf" | ||
COPY_REGISTRY_OPTS="${BUILDAH_REGISTRY_OPTS}" | ||
PODMAN_REGISTRY_OPTS="${regconfopt}" | ||
+ PODMAN_REMOTE_OPTS= | ||
+ | ||
+ PODMAN_SERVER_PID= | ||
+ PODMAN_NATIVE="${PODMAN_BINARY} ${ROOTDIR_OPTS} ${PODMAN_REGISTRY_OPTS}" | ||
|
@@ -32,26 +33,29 @@ index f8ab624a8..0d8f5ce69 100644 | |
+ local sockdir=/run | ||
+ if is_rootless; then | ||
+ sockdir=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} | ||
+ mkdir -p ${sockdir}/podman | ||
+ fi | ||
+ PODMAN_SOCK_FILE=$sockdir/podman/podman.sock | ||
+ PODMAN_SOCK_FILE=$sockdir/podman/podman-${BATS_SUITE_TEST_NUMBER}.sock | ||
+ PODMAN_REMOTE_OPTS="--url unix://${PODMAN_SOCK_FILE}" | ||
+ # 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_OVERRIDE=${CONTAINERS_CONF_OVERRIDE:-$(dirname ${BASH_SOURCE})/containers.conf} $PODMAN_NATIVE system service --log-level=info --timeout=0 &>>${PODMAN_SERVER_LOG:-/dev/stderr} & | ||
+ echo "$_LOG_PROMPT $PODMAN_NATIVE system service [...] unix://${PODMAN_SOCK_FILE}" >&2 | ||
+ env CONTAINERS_CONF_OVERRIDE=${CONTAINERS_CONF_OVERRIDE:-$(dirname ${BASH_SOURCE})/containers.conf} $PODMAN_NATIVE system service --log-level=info --timeout=0 unix://${PODMAN_SOCK_FILE} &>>${PODMAN_SERVER_LOG:-/dev/stderr} & | ||
+ PODMAN_SERVER_PID=$! | ||
+ echo ">> pid=$PODMAN_SERVER_PID" >>${PODMAN_SERVER_LOG:-/dev/stderr} | ||
+ local timeout=10 | ||
+ local timeout=30 | ||
+ while ((timeout > 0)); do | ||
+ test -S $PODMAN_SOCK_FILE && return | ||
+ sleep 0.2 | ||
+ timeout=$((timeout - 1)) | ||
+ done | ||
+ die "podman server never came up" | ||
+ die "podman server never came up: $PODMAN_SOCK_FILE" | ||
+ fi | ||
} | ||
|
||
function starthttpd() { # directory [working-directory-or-"" [certfile, keyfile]] | ||
@@ -144,6 +176,32 @@ function teardown_tests() { | ||
@@ -144,6 +180,35 @@ function teardown_tests() { | ||
stop_git_daemon | ||
stop_registry | ||
|
||
|
@@ -71,34 +75,37 @@ index f8ab624a8..0d8f5ce69 100644 | |
+ done | ||
+ fi | ||
+ | ||
+ # FIXME! 2024-11-22: I have no idea if this is still relevant, but it | ||
+ # certainly does not play well with parallel bats tests. Let's see | ||
+ # what happens if we disable it. | ||
+ # FIXME! 2023-04-11: under remote + rootless, on the very first test, | ||
+ # we somehow end up with two podman-system-service jobs. The second one | ||
+ # lingers, and prevents BATS from completing, manifesting as a test hang. | ||
+ if is_rootless; then | ||
+ ps auxww | grep "system service" | grep -v grep | while read user pid rest; do | ||
+ echo "# teardown: killing stray server: $user $pid $rest" >&3 | ||
+ kill $pid | ||
+ done | ||
+ fi | ||
+# if is_rootless; then | ||
+# ps auxww | grep "system service" | grep -v grep | while read user pid rest; do | ||
+# echo "# teardown: killing stray server: $user $pid $rest" >&3 | ||
+# kill $pid | ||
+# done | ||
+# 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. | ||
@@ -252,7 +310,12 @@ function copy() { | ||
@@ -265,7 +330,12 @@ function copy() { | ||
} | ||
|
||
function podman() { | ||
- command ${PODMAN_BINARY:-podman} ${PODMAN_REGISTRY_OPTS} ${ROOTDIR_OPTS} "$@" | ||
+ local cmd=${PODMAN_BINARY:-podman} | ||
+ local opts="${PODMAN_REGISTRY_OPTS} ${ROOTDIR_OPTS}" | ||
+ if [[ $cmd =~ remote ]]; then | ||
+ opts= | ||
+ opts="${PODMAN_REMOTE_OPTS}" | ||
+ fi | ||
+ command $cmd $opts "$@" | ||
} | ||
|
||
# There are various scenarios where we would like to execute `tests` as rootless user, however certain commands like `buildah mount` | ||
@@ -316,8 +379,36 @@ function run_buildah() { | ||
@@ -329,8 +399,36 @@ function run_buildah() { | ||
--retry) retry=3; shift;; # retry network flakes | ||
esac | ||
|
||
|
@@ -117,7 +124,7 @@ index f8ab624a8..0d8f5ce69 100644 | |
+ podman_or_buildah=${PODMAN_BINARY} | ||
+ _opts="${ROOTDIR_OPTS} ${PODMAN_REGISTRY_OPTS}" | ||
+ if [[ -n "$REMOTE" ]]; then | ||
+ _opts= | ||
+ _opts="${PODMAN_REMOTE_OPTS}" | ||
+ fi | ||
+ | ||
+ # Special case: there's one test that invokes git in such | ||
|
@@ -136,7 +143,7 @@ index f8ab624a8..0d8f5ce69 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. | ||
@@ -331,8 +422,8 @@ function run_buildah() { | ||
@@ -344,8 +442,8 @@ function run_buildah() { | ||
retry=$(( retry - 1 )) | ||
|
||
# stdout is only emitted upon error; this echo is to help a debugger | ||
|
@@ -147,7 +154,7 @@ index f8ab624a8..0d8f5ce69 100644 | |
# without "quotes", multiple lines are glommed together into one | ||
if [ -n "$output" ]; then | ||
echo "$output" | ||
@@ -693,6 +784,26 @@ function skip_if_no_unshare() { | ||
@@ -706,6 +804,26 @@ function skip_if_no_unshare() { | ||
fi | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm choosing to leave this in place, instead of deleting it, because I want someone else to practice the bud-tests dance.
You will need to:
test/buildah-bud/run-buildah-tests --no-test
. This will check out the buildah source tree intotest-buildah-*
and apply some patchesgit reset --hard
, to get rid of the applied skips and error message changes, but before you do so, why not rungit diff
just so you can get a feel for what things look like in a bud-under-podman scenario?git reset --hard
tests/helpers.bash
and remove this blockgit commit --amend
. Don't worry, this isn't podman, this is a scratch git repo for buildah. Commit message is irrelevant, don't bother changing it, just commit your new changes./make-new-buildah-diffs
cd ..
, back to your podman source treegit diff
, and this is hard to grok because you're diffing a diff patch, but basically it should look like changes in commit hash, line numbers, and one block removedgit commit
that, and push your PR, and party on