Commit Graph

18 Commits

Author SHA1 Message Date
Nalin Dahyabhai c7f0881422 Integration tests: use cached images more
Attempt to make more thorough use of cached copies of images during
integration tests, except in tests which need to pull a new image while
they're running, either because they test pulling directly, or because
they expect to pull a given image for a non-default platform or for
multiple platforms.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-18 11:27:02 -04:00
Ed Santiago a75b263f75 system tests: remove unhelpful assertions
Regular primitive bats uses assertions like '[ $foo = something ]'.
These are worthless for debugging: when they fail, all you know
is that foo is not "something" but you don't know what foo _is_.

Find and replace those assertions with 'assert', which is
more informative. Instances found via:

   $ ack '^ *\[' tests/*.bats

There are many matches for 'test' (instead of '[') but those
mostly look like file-existence ones, which are less evil
than string-check tests. I'm leaving those be for now.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-01-05 08:20:25 -07:00
Ed Santiago 552d09b272 Rename $TESTSDIR (the plural one), step 4 of 3
...rename $TESTDIR (the singular one) to $TEST_SCRATCH_DIR,
which is clearer but unfortunately longer

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-04-26 09:11:22 -06:00
Ed Santiago 267f309911 Rename $TESTSDIR (the plural one), step 1 of 3
...refactor '--signature-policy .../policy.json' to $WITH_POLICY_JSON

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-04-26 09:11:05 -06:00
chenk008 03186a3307 Support overlayfs path contains colon
In linux, directory can contains colon.
Add support to mount path contains colon.

buildah run --volume /root/a\\🅱️/root/test:O

Signed-off-by: chenk008 <kongchen28@gmail.com>
2021-10-20 14:40:38 +08:00
Daniel J Walsh 2e1b71c3ef
Preserve ownership of lower directory when doing an overlay mount
Overlay mounts should work like volume bind mounts and preserve the
underlyng source directories permissions.

Fixes: https://github.com/containers/podman/issues/9947

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-07 07:19:18 -04:00
Nalin Dahyabhai cb20f4169d overlay.bats: fix the "overlay source permissions" test
Fix a mismatch between "$permissions" being set and "$permission" being
read.

Don't expect changes made to an overlay mount in a working container to
persist between subsequent "buildah run" invocations, since they don't.

Use 'stat -c %a' rather than 'ls -l | cut -f1 -d " "' to read the
permissions on a mount upper directory, so that different versions of
"ls" appending "." to "drwxrwx---" (or not) doesn't cause unexpected
mismatches.

Create a file in the lower directory before checking that our attempt to
remove it in the upper layer succeeds.

Expect error code 1 when "buildah run $container ls" can't find a file
which we know whouldn't exist, rather than 125.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-05 15:57:55 -05:00
Nalin Dahyabhai ba11a4ceeb imagebuildah: use overlay for volumes when using overlay
When we're using the overlay driver (which means we know overlay is
available), use it to make volumes appear to be writeable during RUN
instructions instead of saving/restoring their contents.

This avoids having to copy the contents of the volume directory before
each RUN instruction, and having to remove and extract the contents
after each RUN instruction, which should be faster, particularly if the
amount of content in that volume location is large.

For empty directories, it will at least avoid adding an "opaque"
notation for the directory in a layer that might otherwise be empty.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-05 15:57:55 -05:00
Daniel J Walsh b7197a1e10
Set upperdir permissions based on source
We are setting the permissions based on the dest dir rather
then the source dir.  Since we want this to work identical to a bind
mount, we need to have the permissions align.

There is also an issue where overlays on existing mounts is blowing up.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-03 16:20:30 -05:00
Daniel J Walsh 84a261dd10
Upper directory should match mode of destination directory
When we mount over a destination directory inside of the container
we need to preserve the mode of the destination.

Needed to fix: https://github.com/containers/podman/issues/8801

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-06 14:44:38 -05:00
Daniel J Walsh 2f671a26b2
Return exit code from failed containers
Buildah run was exiting with the correct exit code, when a container
failed.  Buildah bud was not, so this should fix this.

Also switched to the proper exit codes when containers fail.  When
Buildah fails to execute it will exit with a 125 exit code like
Podman does.  If a command fails to execute inside of a container
we will exit with a 126. Currently we do not support the 127 for
exiting when the command does not exist.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 11:24:52 -04:00
Chris Evich 8dd593c092
Skip overlay test w/ vfs driver
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-02-06 16:21:43 -05:00
Ed Santiago 229b18f6a8 BATS major cleanup, part 2: use more run_buildah
Replace this pattern:

       cid=$(buildah ...)
with:
       run_buildah ...
       cid=$output

As a special case, if the buildah command is 'from' and the
string 'scratch' does not appear in the arguments, add '--quiet'.
Otherwise we'll get Pulling messages as part of $output. This
is an overkill solution.

For ease of review, this commit was entirely machine-generated via:

   $ perl -pi -e 's{^(\s+)(\S+)=\$\(buildah (.*)\)$}{$indent=$1;$var=$2;$cmd=$3; $cmd =~ s/(\bfrom)\s(?!.*scratch)/$1 --quiet $2/; "${indent}run_buildah $cmd\n$indent$var=\$output"}e' *.bats

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2029
Approved by: rhatdan
2019-12-17 18:16:45 +00:00
Ed Santiago dee4b68ef0 BATS major cleanup, part 1: log-level
PR #1935 removed the default --debug logging; so all run_buildah
calls now use the default (error). It is safe to remove unnecessary
instances of --log-level=error .

For ease of review, this commit was entirely machine-generated via:

    $ perl -pi -e 's/ --log-level=error / /' *.bats

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2029
Approved by: rhatdan
2019-12-17 18:16:45 +00:00
Nalin Dahyabhai c0388272b3 overlay.bats typo: fuse-overlays should be fuse-overlayfs
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1996
Approved by: rhatdan
2019-12-06 12:01:30 +00:00
Sascha Grunert 567141716e Add `--log-level` command line option and deprecate `--debug`
The previous log-level implementation does not seem to work, which is
now fixed and aligns to other projects like podman and CRI-O. Therefore
the `--debug` flag has been deprecated and is now hidden.

Added documentation as well as integration tests.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>

Closes: #1811
Approved by: rhatdan
2019-08-29 12:49:11 +00:00
Giuseppe Scrivano b7a0ed07e9 tests: enable overlay tests for rootless
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1743
Approved by: rhatdan
2019-07-29 23:46:00 +00:00
Daniel J Walsh bcc5e51a94 Add support for Overlay volumes into the container.
Overlay mounts allow buildah bud and buildah from to
specify a directory on the disk that will be mounted
as an overlay into the container, where the overlay can be written to
but when the RUN or buildah run exits, the modified files will dissapear.

The basic idea is to be able to mount cache from the disk for things like yum/dnf/apt
to be able to be used and modified in the contianer on a run command, but to be
kept fresh for each RUN.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1560
Approved by: giuseppe
2019-05-20 12:54:10 +00:00