2017-03-30 03:50:32 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
2020-11-11 00:43:41 +08:00
|
|
|
@test "bud with a path to a Dockerfile (-f) containing a non-directory entry" {
|
|
|
|
|
run_buildah 125 bud -f ${TESTSDIR}/bud/non-directory-in-path/non-directory/Dockerfile
|
|
|
|
|
expect_output --substring "non-directory/Dockerfile: not a directory"
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-07 00:03:58 +08:00
|
|
|
@test "bud with --dns* flags" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --dns-search=example.com --dns=223.5.5.5 --dns-option=use-vc --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/dns/Dockerfile ${TESTSDIR}/bud/dns
|
2019-10-19 00:10:48 +08:00
|
|
|
expect_output --substring "search example.com"
|
|
|
|
|
expect_output --substring "nameserver 223.5.5.5"
|
|
|
|
|
expect_output --substring "options use-vc"
|
2019-04-07 00:03:58 +08:00
|
|
|
}
|
|
|
|
|
|
2019-03-20 02:28:54 +08:00
|
|
|
@test "bud with .dockerignore" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine busybox
|
2020-07-16 04:08:05 +08:00
|
|
|
run_buildah 125 bud -t testbud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/dockerignore/Dockerfile ${TESTSDIR}/bud/dockerignore
|
|
|
|
|
expect_output --substring 'error building.*"COPY subdir \./".*no such file or directory'
|
|
|
|
|
|
|
|
|
|
run_buildah bud -t testbud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/dockerignore/Dockerfile.succeed ${TESTSDIR}/bud/dockerignore
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah from --name myctr testbud
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2020-07-16 04:08:05 +08:00
|
|
|
run_buildah 1 run myctr ls -l test1.txt
|
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah run myctr ls -l test2.txt
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2020-07-16 04:08:05 +08:00
|
|
|
run_buildah 1 run myctr ls -l sub1.txt
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-05-30 05:46:33 +08:00
|
|
|
run_buildah 1 run myctr ls -l sub2.txt
|
|
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah run myctr ls -l subdir/sub1.txt
|
2019-04-04 04:32:12 +08:00
|
|
|
|
2019-05-30 05:46:33 +08:00
|
|
|
run_buildah 1 run myctr ls -l subdir/sub2.txt
|
2020-04-02 23:47:41 +08:00
|
|
|
}
|
2019-05-30 05:46:33 +08:00
|
|
|
|
2020-04-02 23:47:41 +08:00
|
|
|
@test "bud with .dockerignore - unmatched" {
|
|
|
|
|
# Here .dockerignore contains 'unmatched', which will not match anything.
|
|
|
|
|
# Therefore everything in the subdirectory should be copied into the image.
|
|
|
|
|
#
|
|
|
|
|
# We need to do this from a tmpdir, not the original or distributed
|
|
|
|
|
# bud subdir, because of rpm: as of 2020-04-01 rpmbuild 4.16 alpha
|
|
|
|
|
# on rawhide no longer packages circular symlinks (rpm issue #1159).
|
|
|
|
|
# We used to include these symlinks in git and the rpm; now we need to
|
|
|
|
|
# set them up manually as part of test setup.
|
|
|
|
|
cp -a ${TESTSDIR}/bud/dockerignore2 ${TESTDIR}/dockerignore2
|
|
|
|
|
|
|
|
|
|
# Create symlinks, including bad ones
|
|
|
|
|
ln -sf subdir ${TESTDIR}/dockerignore2/symlink
|
|
|
|
|
ln -sf circular-link ${TESTDIR}/dockerignore2/subdir/circular-link
|
|
|
|
|
ln -sf no-such-file ${TESTDIR}/dockerignore2/subdir/dangling-link
|
|
|
|
|
|
|
|
|
|
# Build, create a container, mount it, and list all files therein
|
|
|
|
|
run_buildah bud -t testbud2 --signature-policy ${TESTSDIR}/policy.json ${TESTDIR}/dockerignore2
|
|
|
|
|
|
|
|
|
|
run_buildah from testbud2
|
|
|
|
|
cid=$output
|
|
|
|
|
|
|
|
|
|
run_buildah mount $cid
|
|
|
|
|
mnt=$output
|
|
|
|
|
run find $mnt -printf "%P(%l)\n"
|
|
|
|
|
filelist=$(LC_ALL=C sort <<<"$output")
|
|
|
|
|
run_buildah umount $cid
|
|
|
|
|
|
|
|
|
|
# Format is: filename, and, in parentheses, symlink target (usually empty)
|
|
|
|
|
# The list below has been painstakingly crafted; please be careful if
|
|
|
|
|
# you need to touch it (e.g. if you add new files/symlinks)
|
|
|
|
|
expect="()
|
|
|
|
|
.dockerignore()
|
|
|
|
|
Dockerfile()
|
|
|
|
|
subdir()
|
|
|
|
|
subdir/circular-link(circular-link)
|
|
|
|
|
subdir/dangling-link(no-such-file)
|
|
|
|
|
subdir/sub1.txt()
|
|
|
|
|
subdir/subsubdir()
|
|
|
|
|
subdir/subsubdir/subsub1.txt()
|
|
|
|
|
symlink(subdir)"
|
|
|
|
|
|
|
|
|
|
# If this test ever fails, the 'expect' message will be almost impossible
|
|
|
|
|
# for humans to read -- sorry, I never implemented multi-line comparisons.
|
|
|
|
|
# Should this ever happen, uncomment these two lines and run tests in
|
|
|
|
|
# your own vm; then diff the two files.
|
|
|
|
|
#echo "$filelist" >${TMPDIR}/filelist.actual
|
|
|
|
|
#echo "$expect" >${TMPDIR}/filelist.expect
|
|
|
|
|
|
|
|
|
|
expect_output --from="$filelist" "$expect" "container file list"
|
|
|
|
|
}
|
2019-05-09 04:06:04 +08:00
|
|
|
|
2020-04-02 23:47:41 +08:00
|
|
|
@test "bud with .dockerignore - 3" {
|
2020-07-16 04:08:05 +08:00
|
|
|
run_buildah 125 bud -t testbud3 --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/dockerignore3
|
|
|
|
|
expect_output --substring 'error building.*"COPY test1.txt /upload/test1.txt".*no such file or directory'
|
2019-03-20 02:28:54 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-03 19:20:52 +08:00
|
|
|
@test "bud-flags-order-verification" {
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud /tmp/tmpdockerfile/ -t blabla
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "-t"
|
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud /tmp/tmpdockerfile/ -q -t blabla
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "-q"
|
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud /tmp/tmpdockerfile/ --force-rm
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "--force-rm"
|
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud /tmp/tmpdockerfile/ --userns=cnt1
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "--userns=cnt1"
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 00:55:46 +08:00
|
|
|
@test "bud with --layers and --no-cache flags" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-02-20 22:22:28 +08:00
|
|
|
cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers
|
|
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_line_count 8
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
|
|
|
|
expect_line_count 10
|
|
|
|
|
run_buildah inspect --format "{{index .Docker.ContainerConfig.Env 1}}" test1
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_output "foo=bar"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format "{{index .Docker.ContainerConfig.Env 1}}" test2
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "foo=bar"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format "{{.Docker.ContainerConfig.ExposedPorts}}" test1
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_output "map[8080/tcp:{}]"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format "{{.Docker.ContainerConfig.ExposedPorts}}" test2
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "map[8080/tcp:{}]"
|
2018-06-09 00:55:46 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.2 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-12-13 03:08:20 +08:00
|
|
|
expect_line_count 12
|
2018-06-09 00:55:46 +08:00
|
|
|
|
2019-02-20 22:22:28 +08:00
|
|
|
mkdir -p ${TESTDIR}/use-layers/mount/subdir
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test4 -f Dockerfile.3 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-12-13 03:08:20 +08:00
|
|
|
expect_line_count 14
|
2019-03-19 10:54:29 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test5 -f Dockerfile.3 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-12-13 03:08:20 +08:00
|
|
|
expect_line_count 15
|
2018-06-09 00:55:46 +08:00
|
|
|
|
2019-03-19 10:54:29 +08:00
|
|
|
touch ${TESTDIR}/use-layers/mount/subdir/file.txt
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test6 -f Dockerfile.3 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-12-13 03:08:20 +08:00
|
|
|
expect_line_count 17
|
2019-03-19 10:54:29 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --no-cache -t test7 -f Dockerfile.2 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-12-13 03:08:20 +08:00
|
|
|
expect_line_count 18
|
2018-06-09 00:55:46 +08:00
|
|
|
}
|
|
|
|
|
|
2019-02-01 01:19:31 +08:00
|
|
|
@test "bud with --layers and single and two line Dockerfiles" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test -f Dockerfile.5 ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 3
|
2019-02-01 01:19:31 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.6 ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 4
|
2019-02-01 01:19:31 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-19 04:10:26 +08:00
|
|
|
@test "bud with --layers, multistage, and COPY with --from" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-02-20 22:22:28 +08:00
|
|
|
cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers
|
|
|
|
|
|
|
|
|
|
mkdir -p ${TESTDIR}/use-layers/uuid
|
|
|
|
|
uuidgen > ${TESTDIR}/use-layers/uuid/data
|
|
|
|
|
mkdir -p ${TESTDIR}/use-layers/date
|
|
|
|
|
date > ${TESTDIR}/use-layers/date/data
|
2018-11-19 04:10:26 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.multistage-copy ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 6
|
2019-03-19 10:54:29 +08:00
|
|
|
# The second time through, the layers should all get reused.
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.multistage-copy ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 6
|
2019-03-19 10:54:29 +08:00
|
|
|
# The third time through, the layers should all get reused, but we'll have a new line of output for the new name.
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.multistage-copy ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 7
|
2018-11-19 04:10:26 +08:00
|
|
|
|
2019-03-19 10:54:29 +08:00
|
|
|
# Both interim images will be different, and all of the layers in the final image will be different.
|
2019-02-20 22:22:28 +08:00
|
|
|
uuidgen > ${TESTDIR}/use-layers/uuid/data
|
|
|
|
|
date > ${TESTDIR}/use-layers/date/data
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.multistage-copy ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 11
|
2019-03-19 10:54:29 +08:00
|
|
|
# No leftover containers, just the header line.
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 1
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test3
|
|
|
|
|
ctr=$output
|
|
|
|
|
run_buildah mount ${ctr}
|
|
|
|
|
mnt=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
test -e $mnt/uuid
|
|
|
|
|
test -e $mnt/date
|
2018-11-19 04:10:26 +08:00
|
|
|
|
2019-03-19 10:54:29 +08:00
|
|
|
# Layers won't get reused because this build won't use caching.
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t test4 -f Dockerfile.multistage-copy ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 12
|
2018-11-19 04:10:26 +08:00
|
|
|
}
|
2019-05-29 07:07:03 +08:00
|
|
|
|
2019-08-10 06:37:32 +08:00
|
|
|
@test "bud-multistage-partial-cache" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-08-10 06:37:32 +08:00
|
|
|
target=foo
|
|
|
|
|
# build the first stage
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -f ${TESTSDIR}/bud/cache-stages/Dockerfile.1 ${TESTSDIR}/bud/cache-stages
|
|
|
|
|
# expect alpine + 1 image record for the first stage
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-08-10 06:37:32 +08:00
|
|
|
expect_line_count 3
|
|
|
|
|
# build the second stage, itself not cached, when the first stage is found in the cache
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -f ${TESTSDIR}/bud/cache-stages/Dockerfile.2 -t ${target} ${TESTSDIR}/bud/cache-stages
|
|
|
|
|
# expect alpine + 1 image record for the first stage, then two more image records for the second stage
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-08-10 06:37:32 +08:00
|
|
|
expect_line_count 5
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 07:07:03 +08:00
|
|
|
@test "bud-multistage-copy-final-slash" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-05-29 07:07:03 +08:00
|
|
|
target=foo
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/dest-final-slash
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json ${target}
|
2019-05-29 07:07:03 +08:00
|
|
|
cid="$output"
|
|
|
|
|
run_buildah run ${cid} /test/ls -lR /test/ls
|
|
|
|
|
}
|
2018-11-19 04:10:26 +08:00
|
|
|
|
2019-05-01 02:40:54 +08:00
|
|
|
@test "bud-multistage-reused" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine busybox
|
2019-05-01 02:40:54 +08:00
|
|
|
target=foo
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.reused ${TESTSDIR}/bud/multi-stage-builds
|
|
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
run_buildah rmi -f ${target}
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --layers -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.reused ${TESTSDIR}/bud/multi-stage-builds
|
|
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-16 02:51:19 +08:00
|
|
|
@test "bud-multistage-cache" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine busybox
|
2019-05-16 02:51:19 +08:00
|
|
|
target=foo
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.extended ${TESTSDIR}/bud/multi-stage-builds
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json ${target}
|
2019-05-16 02:51:19 +08:00
|
|
|
cid="$output"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah mount "$cid"
|
2019-05-16 02:51:19 +08:00
|
|
|
root="$output"
|
|
|
|
|
# cache should have used this one
|
|
|
|
|
test -r "$root"/tmp/preCommit
|
|
|
|
|
# cache should not have used this one
|
|
|
|
|
! test -r "$root"/tmp/postCommit
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-09 02:17:31 +08:00
|
|
|
@test "bud with --layers and symlink file" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-02-20 22:22:28 +08:00
|
|
|
cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers
|
|
|
|
|
echo 'echo "Hello World!"' > ${TESTDIR}/use-layers/hello.sh
|
|
|
|
|
ln -s hello.sh ${TESTDIR}/use-layers/hello_world.sh
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test -f Dockerfile.4 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 4
|
2019-04-02 05:56:29 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.4 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 5
|
2018-10-09 02:17:31 +08:00
|
|
|
|
2019-02-20 22:22:28 +08:00
|
|
|
echo 'echo "Hello Cache!"' > ${TESTDIR}/use-layers/hello.sh
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.4 ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 7
|
2018-10-09 02:17:31 +08:00
|
|
|
}
|
|
|
|
|
|
2019-04-16 04:32:43 +08:00
|
|
|
@test "bud with --layers and dangling symlink" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-16 04:32:43 +08:00
|
|
|
cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers
|
|
|
|
|
mkdir ${TESTDIR}/use-layers/blah
|
|
|
|
|
ln -s ${TESTSDIR}/policy.json ${TESTDIR}/use-layers/blah/policy.json
|
|
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test -f Dockerfile.dangling-symlink ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-16 04:32:43 +08:00
|
|
|
expect_line_count 3
|
|
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.dangling-symlink ${TESTDIR}/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-16 04:32:43 +08:00
|
|
|
expect_line_count 4
|
|
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test
|
|
|
|
|
cid=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $cid ls /tmp
|
2019-04-16 04:32:43 +08:00
|
|
|
expect_output "policy.json"
|
|
|
|
|
}
|
2019-04-16 10:20:24 +08:00
|
|
|
|
|
|
|
|
@test "bud with --layers and --build-args" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-09 10:59:52 +08:00
|
|
|
# base plus 3, plus the header line
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --build-arg=user=0 --layers -t test -f Dockerfile.build-args ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_line_count 5
|
2019-04-16 10:20:24 +08:00
|
|
|
|
2019-04-09 10:59:52 +08:00
|
|
|
# two more, starting at the "echo $user" instruction
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --build-arg=user=1 --layers -t test1 -f Dockerfile.build-args ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_line_count 7
|
2019-04-16 10:20:24 +08:00
|
|
|
|
2019-04-09 10:59:52 +08:00
|
|
|
# one more, because we added a new name to the same image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --build-arg=user=1 --layers -t test2 -f Dockerfile.build-args ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_line_count 8
|
2019-04-16 10:20:24 +08:00
|
|
|
|
2019-04-09 10:59:52 +08:00
|
|
|
# two more, starting at the "echo $user" instruction
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.build-args ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_line_count 10
|
2019-04-16 10:20:24 +08:00
|
|
|
}
|
2019-04-16 04:32:43 +08:00
|
|
|
|
2018-06-14 02:09:45 +08:00
|
|
|
@test "bud with --rm flag" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 1
|
2018-06-14 02:09:45 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --rm=false --layers -t test2 ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers
|
2019-04-09 10:59:52 +08:00
|
|
|
expect_line_count 7
|
2018-06-14 02:09:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --force-rm flag" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --force-rm --layers -t test1 -f Dockerfile.fail-case ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 1
|
2018-06-14 02:09:45 +08:00
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.fail-case ${TESTSDIR}/bud/use-layers
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers
|
2019-04-05 21:56:11 +08:00
|
|
|
expect_line_count 2
|
2018-06-14 02:09:45 +08:00
|
|
|
}
|
|
|
|
|
|
2018-08-22 23:50:29 +08:00
|
|
|
@test "bud --layers with non-existent/down registry" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --force-rm --layers -t test1 -f Dockerfile.non-existent-registry ${TESTSDIR}/bud/use-layers
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "no such host"
|
2018-08-22 23:50:29 +08:00
|
|
|
}
|
|
|
|
|
|
2018-05-24 23:54:31 +08:00
|
|
|
@test "bud from base image should have base image ENV also" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t test -f Dockerfile.check-env ${TESTSDIR}/bud/env
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test
|
|
|
|
|
cid=$output
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah config --env random=hello,goodbye ${cid}
|
|
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json ${cid} test1
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{index .Docker.ContainerConfig.Env 1}}' test1
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "foo=bar"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{index .Docker.ContainerConfig.Env 2}}' test1
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "random=hello,goodbye"
|
2018-05-24 23:54:31 +08:00
|
|
|
}
|
|
|
|
|
|
2017-03-30 03:50:32 +08:00
|
|
|
@test "bud-from-scratch" {
|
|
|
|
|
target=scratch-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
|
|
|
|
expect_output "${target}-working-container"
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
2018-04-25 22:00:46 +08:00
|
|
|
|
|
|
|
|
@test "bud-from-scratch-iid" {
|
|
|
|
|
target=scratch-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --iidfile ${TESTDIR}/output.iid --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-04-29 02:57:50 +08:00
|
|
|
iid=$(cat ${TESTDIR}/output.iid)
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${iid}
|
|
|
|
|
expect_output "${target}-working-container"
|
2018-04-25 22:00:46 +08:00
|
|
|
}
|
2017-03-30 03:50:32 +08:00
|
|
|
|
2018-05-17 02:13:12 +08:00
|
|
|
@test "bud-from-scratch-label" {
|
2020-08-05 05:00:47 +08:00
|
|
|
run_buildah --version
|
|
|
|
|
local -a output_fields=($output)
|
|
|
|
|
buildah_version=${output_fields[2]}
|
|
|
|
|
want_output='map["io.buildah.version":"'$buildah_version'" "test":"label"]'
|
|
|
|
|
|
2018-05-17 02:13:12 +08:00
|
|
|
target=scratch-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --label "test=label" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .Docker.Config.Labels}}' ${target}
|
2020-08-05 05:00:47 +08:00
|
|
|
expect_output "$want_output"
|
2018-05-17 02:13:12 +08:00
|
|
|
}
|
|
|
|
|
|
2018-05-23 00:05:18 +08:00
|
|
|
@test "bud-from-scratch-annotation" {
|
|
|
|
|
target=scratch-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --annotation "test=annotation1,annotation2=z" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .ImageAnnotations}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output 'map["test":"annotation1,annotation2=z"]'
|
2018-05-23 00:05:18 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-07 04:39:48 +08:00
|
|
|
@test "bud-from-scratch-layers" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/from-scratch/Dockerfile2 -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/from-scratch/Dockerfile2 -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images
|
2019-10-29 06:03:31 +08:00
|
|
|
expect_line_count 3
|
2019-05-07 04:39:48 +08:00
|
|
|
run_buildah rm ${cid}
|
2019-10-29 06:03:31 +08:00
|
|
|
expect_line_count 1
|
2019-05-07 04:39:48 +08:00
|
|
|
}
|
|
|
|
|
|
2017-03-30 03:50:32 +08:00
|
|
|
@test "bud-from-multiple-files-one-from" {
|
|
|
|
|
target=scratch-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch -f ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2017-03-30 03:50:32 +08:00
|
|
|
cmp $root/Dockerfile1 ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch
|
|
|
|
|
cmp $root/Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.nofrom
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/etc/passwd
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah rmi -a
|
2017-03-30 03:50:32 +08:00
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2017-03-30 03:50:32 +08:00
|
|
|
target=alpine-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.alpine -f Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2017-03-30 03:50:32 +08:00
|
|
|
cmp $root/Dockerfile1 ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.alpine
|
|
|
|
|
cmp $root/Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.nofrom
|
2019-10-19 00:10:48 +08:00
|
|
|
test -s $root/etc/passwd
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-from-multiple-files-two-froms" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2017-03-30 03:50:32 +08:00
|
|
|
target=scratch-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.scratch -f Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/Dockerfile1
|
2017-03-30 03:50:32 +08:00
|
|
|
cmp $root/Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.withfrom
|
2019-10-19 00:10:48 +08:00
|
|
|
test -s $root/etc/passwd
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
|
|
|
|
run_buildah rmi -a
|
2017-03-30 03:50:32 +08:00
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2017-03-30 03:50:32 +08:00
|
|
|
target=alpine-image
|
2019-10-19 00:10:48 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.alpine -f Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/Dockerfile1
|
2017-03-30 03:50:32 +08:00
|
|
|
cmp $root/Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.withfrom
|
2019-10-19 00:10:48 +08:00
|
|
|
test -s $root/etc/passwd
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
2018-02-25 06:40:44 +08:00
|
|
|
@test "bud-multi-stage-builds" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-02-25 06:40:44 +08:00
|
|
|
target=multi-stage-index
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-02-25 06:40:44 +08:00
|
|
|
cmp $root/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.index
|
2019-10-19 00:10:48 +08:00
|
|
|
test -s $root/etc/passwd
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
|
|
|
|
run_buildah rmi -a
|
2018-02-25 06:40:44 +08:00
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-02-25 06:40:44 +08:00
|
|
|
target=multi-stage-name
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-02-25 06:40:44 +08:00
|
|
|
cmp $root/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.name
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/etc/passwd
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah rmi -a
|
2018-02-25 06:40:44 +08:00
|
|
|
|
|
|
|
|
target=multi-stage-mixed
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.mixed ${TESTSDIR}/bud/multi-stage-builds
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-02-25 06:40:44 +08:00
|
|
|
cmp $root/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.name
|
|
|
|
|
cmp $root/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.index
|
2018-04-11 01:35:03 +08:00
|
|
|
cmp $root/Dockerfile.mixed ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.mixed
|
2018-02-25 06:40:44 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-17 06:43:48 +08:00
|
|
|
@test "bud-multi-stage-builds-small-as" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-11-17 06:43:48 +08:00
|
|
|
target=multi-stage-index
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds-small-as
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-11-17 06:43:48 +08:00
|
|
|
cmp $root/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.index
|
2019-10-19 00:10:48 +08:00
|
|
|
test -s $root/etc/passwd
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
|
|
|
|
run_buildah rmi -a
|
2018-11-17 06:43:48 +08:00
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-11-17 06:43:48 +08:00
|
|
|
target=multi-stage-name
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds-small-as
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-11-17 06:43:48 +08:00
|
|
|
cmp $root/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.name
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/etc/passwd
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah rmi -a
|
2018-11-17 06:43:48 +08:00
|
|
|
|
|
|
|
|
target=multi-stage-mixed
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.mixed ${TESTSDIR}/bud/multi-stage-builds-small-as
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-11-17 06:43:48 +08:00
|
|
|
cmp $root/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.name
|
|
|
|
|
cmp $root/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.index
|
|
|
|
|
cmp $root/Dockerfile.mixed ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.mixed
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-30 03:50:32 +08:00
|
|
|
@test "bud-preserve-subvolumes" {
|
|
|
|
|
# This Dockerfile needs us to be able to handle a working RUN instruction.
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2017-03-30 03:50:32 +08:00
|
|
|
target=volume-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/preserve-volumes
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2017-03-30 03:50:32 +08:00
|
|
|
test -s $root/vol/subvol/subsubvol/subsubvolfile
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/vol/subvol/subvolfile
|
2017-03-30 03:50:32 +08:00
|
|
|
test -s $root/vol/volfile
|
2017-06-21 05:37:50 +08:00
|
|
|
test -s $root/vol/Dockerfile
|
|
|
|
|
test -s $root/vol/Dockerfile2
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/vol/anothervolfile
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
# Helper function for several of the tests which pull from http.
|
|
|
|
|
#
|
|
|
|
|
# Usage: _test_http SUBDIRECTORY URL_PATH [EXTRA ARGS]
|
|
|
|
|
#
|
|
|
|
|
# SUBDIRECTORY is a subdirectory path under the 'buds' subdirectory.
|
|
|
|
|
# This will be the argument to starthttpd(), i.e. where
|
|
|
|
|
# the httpd will serve files.
|
|
|
|
|
#
|
|
|
|
|
# URL_PATH is the path requested by buildah from the http server,
|
|
|
|
|
# probably 'Dockerfile' or 'context.tar'
|
|
|
|
|
#
|
|
|
|
|
# [EXTRA ARGS] if present, will be passed to buildah on the 'bud'
|
|
|
|
|
# command line; it is intended for '-f subdir/Dockerfile'.
|
|
|
|
|
#
|
|
|
|
|
function _test_http() {
|
|
|
|
|
local testdir=$1; shift; # in: subdirectory under bud/
|
|
|
|
|
local urlpath=$1; shift; # in: path to request from localhost
|
|
|
|
|
|
|
|
|
|
starthttpd "${TESTSDIR}/bud/$testdir"
|
2017-03-30 03:50:32 +08:00
|
|
|
target=scratch-image
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json \
|
|
|
|
|
-t ${target} \
|
|
|
|
|
"$@" \
|
|
|
|
|
http://0.0.0.0:${HTTP_SERVER_PORT}/$urlpath
|
2017-03-30 03:50:32 +08:00
|
|
|
stophttpd
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
@test "bud-http-Dockerfile" {
|
|
|
|
|
_test_http from-scratch Dockerfile
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
@test "bud-http-context-with-Dockerfile" {
|
|
|
|
|
_test_http http-context context.tar
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
@test "bud-http-context-dir-with-Dockerfile" {
|
|
|
|
|
_test_http http-context-subdir context.tar -f context/Dockerfile
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-git-context" {
|
|
|
|
|
# We need git and ssh to be around to handle cloning a repository.
|
|
|
|
|
if ! which git ; then
|
2019-04-02 05:56:29 +08:00
|
|
|
skip "no git in PATH"
|
2017-03-30 03:50:32 +08:00
|
|
|
fi
|
|
|
|
|
if ! which ssh ; then
|
2019-04-02 05:56:29 +08:00
|
|
|
skip "no ssh in PATH"
|
2017-03-30 03:50:32 +08:00
|
|
|
fi
|
|
|
|
|
target=giturl-image
|
|
|
|
|
# Any repo should do, but this one is small and is FROM: scratch.
|
|
|
|
|
gitrepo=git://github.com/projectatomic/nulecule-library
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} "${gitrepo}"
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-github-context" {
|
|
|
|
|
target=github-image
|
|
|
|
|
# Any repo should do, but this one is small and is FROM: scratch.
|
|
|
|
|
gitrepo=github.com/projectatomic/nulecule-library
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} "${gitrepo}"
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2017-03-30 03:50:32 +08:00
|
|
|
}
|
2017-04-11 02:25:07 +08:00
|
|
|
|
|
|
|
|
@test "bud-additional-tags" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
target2=another-scratch-image
|
|
|
|
|
target3=so-many-scratch-images
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -t docker.io/${target2} -t ${target3} ${TESTSDIR}/bud/from-scratch
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json library/${target2}
|
|
|
|
|
cid=$output
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah rm ${cid}
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target3}:latest
|
2019-12-09 21:45:52 +08:00
|
|
|
run_buildah rm $output
|
|
|
|
|
|
|
|
|
|
run_buildah rmi $target3 $target2 $target
|
|
|
|
|
expect_line_count 4
|
|
|
|
|
for i in 0 1 2;do
|
|
|
|
|
expect_output --substring --from="${lines[$i]}" "untagged: "
|
|
|
|
|
done
|
|
|
|
|
expect_output --substring --from="${lines[3]}" '^[0-9a-f]{64}$'
|
2017-04-11 02:25:07 +08:00
|
|
|
}
|
2017-06-21 05:37:50 +08:00
|
|
|
|
2019-06-04 05:00:42 +08:00
|
|
|
@test "bud-additional-tags-cached" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-06-04 05:00:42 +08:00
|
|
|
target=tagged-image
|
|
|
|
|
target2=another-tagged-image
|
|
|
|
|
target3=yet-another-tagged-image
|
|
|
|
|
target4=still-another-tagged-image
|
|
|
|
|
run_buildah bud --layers --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/addtl-tags
|
|
|
|
|
run_buildah bud --layers --signature-policy ${TESTSDIR}/policy.json -t ${target2} -t ${target3} -t ${target4} ${TESTSDIR}/bud/addtl-tags
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' busybox
|
2019-06-04 05:00:42 +08:00
|
|
|
busyboxid="$output"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-06-04 05:00:42 +08:00
|
|
|
targetid="$output"
|
|
|
|
|
[ "$targetid" != "$busyboxid" ]
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target2}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$targetid" "target2 -> .FromImageID"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target3}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$targetid" "target3 -> .FromImageID"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target4}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$targetid" "target4 -> .FromImageID"
|
2019-06-04 05:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 05:37:50 +08:00
|
|
|
@test "bud-volume-perms" {
|
|
|
|
|
# This Dockerfile needs us to be able to handle a working RUN instruction.
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_no_runtime
|
|
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2017-06-21 05:37:50 +08:00
|
|
|
target=volume-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/volume-perms
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-10-19 00:10:48 +08:00
|
|
|
test ! -s $root/vol/subvol/subvolfile
|
2017-06-21 05:37:50 +08:00
|
|
|
run stat -c %f $root/vol/subvol
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "41ed" "stat($root/vol/subvol) [0x41ed = 040755]"
|
2017-06-21 05:37:50 +08:00
|
|
|
}
|
2017-07-17 22:42:58 +08:00
|
|
|
|
2020-03-11 21:22:06 +08:00
|
|
|
@test "bud-volume-ownership" {
|
|
|
|
|
# This Dockerfile needs us to be able to handle a working RUN instruction.
|
|
|
|
|
skip_if_no_runtime
|
|
|
|
|
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
target=volume-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/volume-ownership
|
|
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
2020-03-19 21:27:52 +08:00
|
|
|
run_buildah run $cid stat -c "%U %G" /vol/subvol
|
|
|
|
|
expect_output "testuser testgroup"
|
2020-03-11 21:22:06 +08:00
|
|
|
}
|
|
|
|
|
|
2017-07-17 22:42:58 +08:00
|
|
|
@test "bud-from-glob" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2017-07-17 22:42:58 +08:00
|
|
|
target=alpine-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile2.glob ${TESTSDIR}/bud/from-multiple-files
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2017-07-17 22:42:58 +08:00
|
|
|
cmp $root/Dockerfile1.alpine ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.alpine
|
|
|
|
|
cmp $root/Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.withfrom
|
|
|
|
|
}
|
2018-02-06 05:26:21 +08:00
|
|
|
|
|
|
|
|
@test "bud-maintainer" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-02-06 05:26:21 +08:00
|
|
|
target=alpine-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/maintainer
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --type=image --format '{{.Docker.Author}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "kilroy"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --type=image --format '{{.OCIv1.Author}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "kilroy"
|
2018-02-06 05:26:21 +08:00
|
|
|
}
|
2018-02-07 01:02:21 +08:00
|
|
|
|
|
|
|
|
@test "bud-unrecognized-instruction" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-02-07 01:02:21 +08:00
|
|
|
target=alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/unrecognized
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "BOGUS"
|
2018-02-07 01:02:21 +08:00
|
|
|
}
|
2018-03-16 19:57:36 +08:00
|
|
|
|
|
|
|
|
@test "bud-shell" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-03-16 19:57:36 +08:00
|
|
|
target=alpine-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/shell
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --type=image --format '{{printf "%q" .Docker.Config.Shell}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["/bin/sh" "-c"]' ".Docker.Config.Shell (original)"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
ctr=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah config --shell "/bin/bash -c" ${ctr}
|
|
|
|
|
run_buildah inspect --type=container --format '{{printf "%q" .Docker.Config.Shell}}' ${ctr}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["/bin/bash" "-c"]' ".Docker.Config.Shell (changed)"
|
2018-03-16 19:57:36 +08:00
|
|
|
}
|
2018-03-28 02:06:00 +08:00
|
|
|
|
2019-05-11 05:53:24 +08:00
|
|
|
@test "bud-shell during build in Docker format" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-05-11 05:53:24 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
run_buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/shell/Dockerfile.build-shell-default ${TESTSDIR}/bud/shell
|
|
|
|
|
expect_output --substring "SHELL=/bin/sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-shell during build in OCI format" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-05-11 05:53:24 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/shell/Dockerfile.build-shell-default ${TESTSDIR}/bud/shell
|
|
|
|
|
expect_output --substring "SHELL=/bin/sh"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-shell changed during build in Docker format" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-11 05:53:24 +08:00
|
|
|
target=ubuntu-image
|
|
|
|
|
run_buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/shell/Dockerfile.build-shell-custom ${TESTSDIR}/bud/shell
|
|
|
|
|
expect_output --substring "SHELL=/bin/bash"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-shell changed during build in OCI format" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-11 05:53:24 +08:00
|
|
|
target=ubuntu-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/shell/Dockerfile.build-shell-custom ${TESTSDIR}/bud/shell
|
|
|
|
|
expect_output --substring "SHELL=/bin/sh"
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-28 02:06:00 +08:00
|
|
|
@test "bud with symlinks" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-03-28 02:06:00 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/symlink
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls $root/data/log
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "test" "ls \$root/data/log"
|
|
|
|
|
expect_output --substring "blah.txt" "ls \$root/data/log"
|
|
|
|
|
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls -al $root
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "test-log -> /data/log" "ls -l \$root/data/log"
|
|
|
|
|
expect_output --substring "blah -> /test-log" "ls -l \$root/data/log"
|
2018-03-28 02:06:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with symlinks to relative path" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-03-28 02:06:00 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.relative-symlink ${TESTSDIR}/bud/symlink
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls $root/log
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "test" "ls \$root/log"
|
|
|
|
|
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls -al $root
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "test-log -> ../log" "ls -l \$root/log"
|
2019-03-08 07:13:12 +08:00
|
|
|
test -r $root/var/data/empty
|
2018-03-28 02:06:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with multiple symlinks in a path" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-03-28 02:06:00 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink/Dockerfile.multiple-symlinks ${TESTSDIR}/bud/symlink
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls $root/data/log
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "bin" "ls \$root/data/log"
|
|
|
|
|
expect_output --substring "blah.txt" "ls \$root/data/log"
|
|
|
|
|
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls -al $root/myuser
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "log -> /test" "ls -al \$root/myuser"
|
|
|
|
|
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls -al $root/test
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "bar -> /test-log" "ls -al \$root/test"
|
|
|
|
|
|
2018-03-28 02:06:00 +08:00
|
|
|
run ls -al $root/test-log
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "foo -> /data/log" "ls -al \$root/test-log"
|
2018-03-28 02:06:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with multiple symlink pointing to itself" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-03-28 02:06:00 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah 1 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink/Dockerfile.symlink-points-to-itself ${TESTSDIR}/bud/symlink
|
2018-03-28 02:06:00 +08:00
|
|
|
}
|
2018-05-05 21:36:22 +08:00
|
|
|
|
2019-06-04 05:44:35 +08:00
|
|
|
@test "bud multi-stage with symlink to absolute path" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-06-04 05:44:35 +08:00
|
|
|
target=ubuntu-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.absolute-symlink ${TESTSDIR}/bud/symlink
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-06-04 05:44:35 +08:00
|
|
|
run ls $root/bin
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "myexe" "ls \$root/bin"
|
|
|
|
|
|
2019-06-04 05:44:35 +08:00
|
|
|
run cat $root/bin/myexe
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "symlink-test" "cat \$root/bin/myexe"
|
2019-06-04 05:44:35 +08:00
|
|
|
}
|
|
|
|
|
|
2019-06-09 00:56:41 +08:00
|
|
|
@test "bud multi-stage with dir symlink to absolute path" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-06-09 00:56:41 +08:00
|
|
|
target=ubuntu-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.absolute-dir-symlink ${TESTSDIR}/bud/symlink
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-06-09 00:56:41 +08:00
|
|
|
run ls $root/data
|
|
|
|
|
[ "$status" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "myexe" "ls \$root/data"
|
2019-06-09 00:56:41 +08:00
|
|
|
}
|
|
|
|
|
|
2018-05-05 21:36:22 +08:00
|
|
|
@test "bud with ENTRYPOINT and RUN" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-05 21:36:22 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.entrypoint-run ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "unique.test.string"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
2018-05-05 21:36:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT and empty RUN" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-05 21:36:22 +08:00
|
|
|
target=alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 2 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.entrypoint-empty-run ${TESTSDIR}/bud/run-scenarios
|
2019-10-19 00:10:48 +08:00
|
|
|
expect_output --substring "error building at STEP"
|
2018-05-05 21:36:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with CMD and RUN" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-05 21:36:22 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/run-scenarios/Dockerfile.cmd-run ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "unique.test.string"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
2018-05-05 21:36:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with CMD and empty RUN" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-05 21:36:22 +08:00
|
|
|
target=alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 2 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.cmd-empty-run ${TESTSDIR}/bud/run-scenarios
|
2019-10-19 00:10:48 +08:00
|
|
|
expect_output --substring "error building at STEP"
|
2018-05-05 21:36:22 +08:00
|
|
|
}
|
2018-05-05 22:37:54 +08:00
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT, CMD and RUN" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-05 22:37:54 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/run-scenarios/Dockerfile.entrypoint-cmd-run ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "unique.test.string"
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json ${target}
|
2018-05-05 22:37:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT, CMD and empty RUN" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-05 22:37:54 +08:00
|
|
|
target=alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 2 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/run-scenarios/Dockerfile.entrypoint-cmd-empty-run ${TESTSDIR}/bud/run-scenarios
|
2019-10-29 06:03:31 +08:00
|
|
|
expect_output --substring "error building at STEP"
|
2018-05-05 22:37:54 +08:00
|
|
|
}
|
2018-05-08 06:14:44 +08:00
|
|
|
|
2018-05-15 20:34:14 +08:00
|
|
|
# Determines if a variable set with ENV is available to following commands in the Dockerfile
|
2018-05-18 21:49:49 +08:00
|
|
|
@test "bud access ENV variable defined in same source file" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-15 20:34:14 +08:00
|
|
|
target=env-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/env/Dockerfile.env-same-file ${TESTSDIR}/bud/env
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring ":unique.test.string:"
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json ${target}
|
2018-05-15 20:34:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Determines if a variable set with ENV in an image is available to commands in downstream Dockerfile
|
2018-05-18 21:49:49 +08:00
|
|
|
@test "bud access ENV variable defined in FROM image" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-15 20:34:14 +08:00
|
|
|
from_target=env-from-image
|
|
|
|
|
target=env-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${from_target} -f ${TESTSDIR}/bud/env/Dockerfile.env-same-file ${TESTSDIR}/bud/env
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/env/Dockerfile.env-from-image ${TESTSDIR}/bud/env
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "@unique.test.string@"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${from_target}
|
|
|
|
|
from_cid=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-15 20:34:14 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-23 05:40:27 +08:00
|
|
|
@test "bud ENV preserves special characters after commit" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-23 05:40:27 +08:00
|
|
|
from_target=special-chars
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${from_target} -f ${TESTSDIR}/bud/env/Dockerfile.special-chars ${TESTSDIR}/bud/env
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${from_target}
|
|
|
|
|
cid=$output
|
2019-05-23 05:40:27 +08:00
|
|
|
run_buildah run ${cid} env
|
|
|
|
|
expect_output --substring "LIB=\\$\(PREFIX\)/lib"
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 21:49:49 +08:00
|
|
|
@test "bud with Dockerfile from valid URL" {
|
|
|
|
|
target=url-image
|
2018-09-18 03:20:16 +08:00
|
|
|
url=https://raw.githubusercontent.com/containers/buildah/master/tests/bud/from-scratch/Dockerfile
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${url}
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-18 21:49:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with Dockerfile from invalid URL" {
|
|
|
|
|
target=url-image
|
2018-09-18 03:20:16 +08:00
|
|
|
url=https://raw.githubusercontent.com/containers/buildah/master/tests/bud/from-scratch/Dockerfile.bogus
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${url}
|
2018-05-18 21:49:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# When provided with a -f flag and directory, buildah will look for the alternate Dockerfile name in the supplied directory
|
|
|
|
|
@test "bud with -f flag, alternate Dockerfile name" {
|
|
|
|
|
target=fileflag-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.noop-flags ${TESTSDIR}/bud/run-scenarios
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-18 21:49:49 +08:00
|
|
|
}
|
|
|
|
|
|
2020-12-22 00:19:56 +08:00
|
|
|
# Following flags are configured to result in noop but should not affect buildah bud behavior
|
2018-05-08 06:14:44 +08:00
|
|
|
@test "bud with --cache-from noop flag" {
|
|
|
|
|
target=noop-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --cache-from=invalidimage --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.noop-flags ${TESTSDIR}/bud/run-scenarios
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-08 06:14:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --compress noop flag" {
|
|
|
|
|
target=noop-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --compress --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.noop-flags ${TESTSDIR}/bud/run-scenarios
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-08 06:14:44 +08:00
|
|
|
}
|
|
|
|
|
|
2018-05-09 21:51:58 +08:00
|
|
|
@test "bud with --cpu-shares flag, no argument" {
|
|
|
|
|
target=bud-flag
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --cpu-shares --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares flag, invalid argument" {
|
|
|
|
|
target=bud-flag
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --cpu-shares bogus --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "invalid argument \"bogus\" for "
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares flag, valid argument" {
|
|
|
|
|
target=bud-flag
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --cpu-shares 2 --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares short flag (-c), no argument" {
|
|
|
|
|
target=bud-flag
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud -c --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares short flag (-c), invalid argument" {
|
|
|
|
|
target=bud-flag
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud -c bogus --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "invalid argument \"bogus\" for "
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares short flag (-c), valid argument" {
|
|
|
|
|
target=bud-flag
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud -c 2 --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah from ${target}
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
2018-05-25 15:53:30 +08:00
|
|
|
|
|
|
|
|
@test "bud-onbuild" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-05-25 15:53:30 +08:00
|
|
|
target=onbuild
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/onbuild
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["RUN touch /onbuild1" "RUN touch /onbuild2"]'
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
2019-12-29 04:46:05 +08:00
|
|
|
cid=${lines[0]}
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
|
|
|
|
|
test -e ${root}/onbuild1
|
|
|
|
|
test -e ${root}/onbuild2
|
|
|
|
|
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah umount ${cid}
|
|
|
|
|
run_buildah rm ${cid}
|
2018-05-25 15:53:30 +08:00
|
|
|
|
|
|
|
|
target=onbuild-image2
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1 ${TESTSDIR}/bud/onbuild
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["RUN touch /onbuild3"]'
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
2019-12-29 04:46:05 +08:00
|
|
|
cid=${lines[0]}
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
|
|
|
|
|
test -e ${root}/onbuild1
|
|
|
|
|
test -e ${root}/onbuild2
|
|
|
|
|
test -e ${root}/onbuild3
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah umount ${cid}
|
2018-05-25 15:53:30 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah config --onbuild "RUN touch /onbuild4" ${cid}
|
2018-05-25 15:53:30 +08:00
|
|
|
|
|
|
|
|
target=onbuild-image3
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json --format docker ${cid} ${target}
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["RUN touch /onbuild4"]'
|
2018-05-25 15:53:30 +08:00
|
|
|
}
|
2018-06-06 01:53:39 +08:00
|
|
|
|
2019-03-21 02:26:37 +08:00
|
|
|
@test "bud-onbuild-layers" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-03-21 02:26:37 +08:00
|
|
|
target=onbuild
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile2 ${TESTSDIR}/bud/onbuild
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["RUN touch /onbuild1" "RUN touch /onbuild2"]'
|
2019-03-21 02:26:37 +08:00
|
|
|
}
|
|
|
|
|
|
2018-06-06 01:53:39 +08:00
|
|
|
@test "bud-logfile" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-06-06 01:53:39 +08:00
|
|
|
rm -f ${TESTDIR}/logfile
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --logfile ${TESTDIR}/logfile --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/preserve-volumes
|
2018-06-06 01:53:39 +08:00
|
|
|
test -s ${TESTDIR}/logfile
|
|
|
|
|
}
|
2018-06-25 20:53:47 +08:00
|
|
|
|
|
|
|
|
@test "bud with ARGS" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-06-25 20:53:47 +08:00
|
|
|
target=alpine-image
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.args ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "arg_value"
|
2018-06-25 20:53:47 +08:00
|
|
|
}
|
2018-07-27 22:48:16 +08:00
|
|
|
|
2019-02-20 06:14:10 +08:00
|
|
|
@test "bud with unused ARGS" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-02-20 06:14:10 +08:00
|
|
|
target=alpine-image
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.multi-args --build-arg USED_ARG=USED_VALUE ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "USED_VALUE"
|
2019-02-20 06:14:10 +08:00
|
|
|
[[ ! "$output" =~ "one or more build args were not consumed: [UNUSED_ARG]" ]]
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.multi-args --build-arg USED_ARG=USED_VALUE --build-arg UNUSED_ARG=whaaaat ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "USED_VALUE"
|
|
|
|
|
expect_output --substring "one or more build args were not consumed: \[UNUSED_ARG\]"
|
2019-02-20 06:14:10 +08:00
|
|
|
}
|
|
|
|
|
|
2019-04-07 23:59:09 +08:00
|
|
|
@test "bud with multi-value ARGS" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-07 23:59:09 +08:00
|
|
|
target=alpine-image
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.multi-args --build-arg USED_ARG=plugin1,plugin2,plugin3 ${TESTSDIR}/bud/run-scenarios
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "plugin1,plugin2,plugin3"
|
2019-12-12 07:21:51 +08:00
|
|
|
if [[ "$output" =~ "one or more build args were not consumed" ]]; then
|
|
|
|
|
expect_output "[not expecting to see 'one or more build args were not consumed']"
|
|
|
|
|
fi
|
2019-04-07 23:59:09 +08:00
|
|
|
}
|
|
|
|
|
|
2018-07-27 22:48:16 +08:00
|
|
|
@test "bud-from-stdin" {
|
|
|
|
|
target=scratch-image
|
2019-12-12 07:21:51 +08:00
|
|
|
cat ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch | run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f - ${TESTSDIR}/bud/from-multiple-files
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
test -s $root/Dockerfile1
|
2018-07-27 22:48:16 +08:00
|
|
|
}
|
2018-08-01 18:31:02 +08:00
|
|
|
|
|
|
|
|
@test "bud with preprocessor" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-08-01 18:31:02 +08:00
|
|
|
target=alpine-image
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Decomposed.in ${TESTSDIR}/bud/preprocess
|
2018-08-01 18:31:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with preprocessor error" {
|
|
|
|
|
target=alpine-image
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah 1 bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Error.in ${TESTSDIR}/bud/preprocess
|
2018-08-01 18:31:02 +08:00
|
|
|
}
|
2018-08-22 04:33:36 +08:00
|
|
|
|
|
|
|
|
@test "bud-with-rejected-name" {
|
|
|
|
|
target=ThisNameShouldBeRejected
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "must be lower"
|
2018-08-22 04:33:36 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-30 15:19:46 +08:00
|
|
|
@test "bud with chown copy" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-08-13 22:18:04 +08:00
|
|
|
imgName=alpine-image
|
|
|
|
|
ctrName=alpine-chown
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/copy-chown
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "user:2367 group:3267"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run alpine-chown -- stat -c '%u' /tmp/copychown.txt
|
2018-08-13 22:18:04 +08:00
|
|
|
# Validate that output starts with "2367"
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "2367"
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run alpine-chown -- stat -c '%g' /tmp/copychown.txt
|
2018-08-13 22:18:04 +08:00
|
|
|
# Validate that output starts with "3267"
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "3267"
|
2018-08-13 22:18:04 +08:00
|
|
|
}
|
2018-09-28 11:53:00 +08:00
|
|
|
|
2019-11-26 08:52:52 +08:00
|
|
|
@test "bud with chown copy with bad chown flag in Dockerfile with --layers" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-11-26 08:52:52 +08:00
|
|
|
imgName=alpine-image
|
|
|
|
|
ctrName=alpine-chown
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${imgName} -f ${TESTSDIR}/bud/copy-chown/Dockerfile.bad ${TESTSDIR}/bud/copy-chown
|
2019-11-26 08:52:52 +08:00
|
|
|
expect_output --substring "COPY only supports the --chown=<uid:gid> and the --from=<image|stage> flags"
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 06:15:18 +08:00
|
|
|
@test "bud with chown add" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-01-18 06:15:18 +08:00
|
|
|
imgName=alpine-image
|
|
|
|
|
ctrName=alpine-chown
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/add-chown
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "user:2367 group:3267"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run alpine-chown -- stat -c '%u' /tmp/addchown.txt
|
2019-01-18 06:15:18 +08:00
|
|
|
# Validate that output starts with "2367"
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "2367"
|
2019-01-18 06:15:18 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run alpine-chown -- stat -c '%g' /tmp/addchown.txt
|
2019-01-18 06:15:18 +08:00
|
|
|
# Validate that output starts with "3267"
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "3267"
|
2019-01-18 06:15:18 +08:00
|
|
|
}
|
|
|
|
|
|
2019-11-26 08:52:52 +08:00
|
|
|
@test "bud with chown add with bad chown flag in Dockerfile with --layers" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-11-26 08:52:52 +08:00
|
|
|
imgName=alpine-image
|
|
|
|
|
ctrName=alpine-chown
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${imgName} -f ${TESTSDIR}/bud/add-chown/Dockerfile.bad ${TESTSDIR}/bud/add-chown
|
2019-11-26 08:52:52 +08:00
|
|
|
expect_output --substring "ADD only supports the --chown=<uid:gid> flag"
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 11:53:00 +08:00
|
|
|
@test "bud with ADD file construct" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t test1 ${TESTSDIR}/bud/add-file
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2018-09-28 11:53:00 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test1
|
|
|
|
|
ctr=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2018-09-28 11:53:00 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run $ctr ls /var/file2
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "/var/file2"
|
2018-09-28 11:53:00 +08:00
|
|
|
}
|
2018-09-22 07:37:02 +08:00
|
|
|
|
2019-05-26 20:56:13 +08:00
|
|
|
@test "bud with COPY of single file creates absolute path with correct permissions" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/copy-create-absolute-path
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "permissions=755"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run ${ctrName} -- stat -c "%a" /usr/lib/python3.7/distutils
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "755"
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with COPY of single file creates relative path with correct permissions" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/copy-create-relative-path
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "permissions=755"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run ${ctrName} -- stat -c "%a" lib/custom
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "755"
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ADD of single file creates absolute path with correct permissions" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/add-create-absolute-path
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "permissions=755"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run ${ctrName} -- stat -c "%a" /usr/lib/python3.7/distutils
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "755"
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ADD of single file creates relative path with correct permissions" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/add-create-relative-path
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "permissions=755"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run ${ctrName} -- stat -c "%a" lib/custom
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "755"
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud multi-stage COPY creates absolute path with correct permissions" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/copy-multistage-paths/Dockerfile.absolute -t ${imgName} ${TESTSDIR}/bud/copy-multistage-paths
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "permissions=755"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run ${ctrName} -- stat -c "%a" /my/bin
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "755"
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud multi-stage COPY creates relative path with correct permissions" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/copy-multistage-paths/Dockerfile.relative -t ${imgName} ${TESTSDIR}/bud/copy-multistage-paths
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "permissions=755"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --name ${ctrName} ${imgName}
|
|
|
|
|
run_buildah run ${ctrName} -- stat -c "%a" my/bin
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "755"
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
2019-10-06 06:15:02 +08:00
|
|
|
@test "bud multi-stage COPY with invalid from statement" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-10-06 06:15:02 +08:00
|
|
|
imgName=ubuntu-image
|
|
|
|
|
ctrName=ubuntu-copy
|
2020-08-12 04:46:36 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/copy-multistage-paths/Dockerfile.invalid_from -t ${imgName} ${TESTSDIR}/bud/copy-multistage-paths
|
2019-11-26 08:52:52 +08:00
|
|
|
expect_output --substring "COPY only supports the --chown=<uid:gid> and the --from=<image|stage> flags"
|
2019-10-06 06:15:02 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-26 20:56:13 +08:00
|
|
|
@test "bud COPY to root succeeds" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/copy-root
|
2019-05-26 20:56:13 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-22 07:37:02 +08:00
|
|
|
@test "bud with FROM AS construct" {
|
2020-02-07 01:04:17 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t test1 ${TESTSDIR}/bud/from-as
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2018-09-22 07:37:02 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test1
|
|
|
|
|
ctr=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah inspect --format "{{.Docker.ContainerConfig.Env}}" --type image test1
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "LOCAL=/1"
|
2018-09-22 07:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with FROM AS construct with layers" {
|
2020-02-07 01:04:17 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --layers --signature-policy ${TESTSDIR}/policy.json -t test1 ${TESTSDIR}/bud/from-as
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2018-09-22 07:37:02 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test1
|
|
|
|
|
ctr=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah inspect --format "{{.Docker.ContainerConfig.Env}}" --type image test1
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "LOCAL=/1"
|
2018-09-22 07:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with FROM AS skip FROM construct" {
|
2020-02-07 01:04:17 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t test1 -f ${TESTSDIR}/bud/from-as/Dockerfile.skip ${TESTSDIR}/bud/from-as
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "LOCAL=/1"
|
|
|
|
|
expect_output --substring "LOCAL2=/2"
|
2018-09-22 07:37:02 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2018-09-22 07:37:02 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json test1
|
|
|
|
|
ctr=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah containers -a
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "test1"
|
2018-09-22 07:37:02 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah mount $ctr
|
|
|
|
|
mnt=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
test -e $mnt/1
|
|
|
|
|
test ! -e $mnt/2
|
2019-03-20 02:28:54 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format "{{.Docker.ContainerConfig.Env}}" --type image test1
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output "[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LOCAL=/1]"
|
2018-09-22 07:37:02 +08:00
|
|
|
}
|
2018-10-28 03:47:03 +08:00
|
|
|
|
|
|
|
|
@test "bud with symlink Dockerfile not specified in file" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-10-28 03:47:03 +08:00
|
|
|
target=alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink ${TESTSDIR}/bud/symlink
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "FROM alpine"
|
2018-10-28 03:47:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with dir for file but no Dockerfile in dir" {
|
|
|
|
|
target=alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/empty-dir ${TESTSDIR}/bud/empty-dir
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "no such file or directory"
|
2018-10-28 03:47:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with bad dir Dockerfile" {
|
|
|
|
|
target=alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/baddirname ${TESTSDIR}/baddirname
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "no such file or directory"
|
2018-10-28 03:47:03 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-08 18:31:14 +08:00
|
|
|
@test "bud with ARG before FROM default value" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2018-11-08 18:31:14 +08:00
|
|
|
target=leading-args-default
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/leading-args/Dockerfile ${TESTSDIR}/bud/leading-args
|
2018-11-08 18:31:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ARG before FROM" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox:musl
|
2018-11-08 18:31:14 +08:00
|
|
|
target=leading-args
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --build-arg=VERSION=musl -f ${TESTSDIR}/bud/leading-args/Dockerfile ${TESTSDIR}/bud/leading-args
|
2018-11-08 18:31:14 +08:00
|
|
|
}
|
|
|
|
|
|
2018-08-21 04:04:26 +08:00
|
|
|
@test "bud-with-healthcheck" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2018-08-21 04:04:26 +08:00
|
|
|
target=alpine-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --format docker ${TESTSDIR}/bud/healthcheck
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{printf "%q" .Docker.Config.Healthcheck.Test}} {{printf "%d" .Docker.Config.Healthcheck.StartPeriod}} {{printf "%d" .Docker.Config.Healthcheck.Interval}} {{printf "%d" .Docker.Config.Healthcheck.Timeout}} {{printf "%d" .Docker.Config.Healthcheck.Retries}}' ${target}
|
2018-08-21 04:04:26 +08:00
|
|
|
second=1000000000
|
|
|
|
|
threeseconds=$(( 3 * $second ))
|
|
|
|
|
fiveminutes=$(( 5 * 60 * $second ))
|
|
|
|
|
tenminutes=$(( 10 * 60 * $second ))
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output '["CMD-SHELL" "curl -f http://localhost/ || exit 1"]'" $tenminutes $fiveminutes $threeseconds 4" "Healthcheck config"
|
2018-08-21 04:04:26 +08:00
|
|
|
}
|
2018-11-29 14:31:20 +08:00
|
|
|
|
|
|
|
|
@test "bud with unused build arg" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine busybox
|
2018-11-29 14:31:20 +08:00
|
|
|
target=busybox-image
|
2019-04-16 23:13:31 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --build-arg foo=bar --build-arg foo2=bar2 -f ${TESTSDIR}/bud/build-arg ${TESTSDIR}/bud/build-arg
|
|
|
|
|
expect_output --substring "one or more build args were not consumed: \[foo2\]"
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --build-arg IMAGE=alpine -f ${TESTSDIR}/bud/build-arg/Dockerfile2 ${TESTSDIR}/bud/build-arg
|
|
|
|
|
! expect_output --substring "one or more build args were not consumed: \[IMAGE\]"
|
|
|
|
|
expect_output --substring "FROM alpine"
|
2018-11-29 14:31:20 +08:00
|
|
|
}
|
2018-11-17 06:43:48 +08:00
|
|
|
|
2019-04-03 01:26:48 +08:00
|
|
|
@test "bud with copy-from and cache" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-04-03 01:26:48 +08:00
|
|
|
target=busybox-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers --iidfile ${TESTDIR}/iid1 -f ${TESTSDIR}/bud/copy-from/Dockerfile2 ${TESTSDIR}/bud/copy-from
|
|
|
|
|
cat ${TESTDIR}/iid1
|
|
|
|
|
test -s ${TESTDIR}/iid1
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers --iidfile ${TESTDIR}/iid2 -f ${TESTSDIR}/bud/copy-from/Dockerfile2 ${TESTSDIR}/bud/copy-from
|
|
|
|
|
cat ${TESTDIR}/iid2
|
|
|
|
|
test -s ${TESTDIR}/iid2
|
|
|
|
|
cmp ${TESTDIR}/iid1 ${TESTDIR}/iid2
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-17 06:43:48 +08:00
|
|
|
@test "bud with copy-from in Dockerfile no prior FROM" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch php:7.2
|
2018-11-17 06:43:48 +08:00
|
|
|
target=php-image
|
2019-04-09 10:59:52 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy-from ${TESTSDIR}/bud/copy-from
|
2018-11-17 06:43:48 +08:00
|
|
|
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json ${target}
|
|
|
|
|
ctr=$output
|
|
|
|
|
run_buildah mount ${ctr}
|
|
|
|
|
mnt=$output
|
2018-11-17 06:43:48 +08:00
|
|
|
|
2019-10-19 00:10:48 +08:00
|
|
|
test -e $mnt/usr/local/bin/composer
|
2018-11-17 06:43:48 +08:00
|
|
|
}
|
2019-02-03 07:31:44 +08:00
|
|
|
|
2019-11-26 08:52:52 +08:00
|
|
|
@test "bud with copy-from with bad from flag in Dockerfile with --layers" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch php:7.2
|
2019-11-26 08:52:52 +08:00
|
|
|
target=php-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f ${TESTSDIR}/bud/copy-from/Dockerfile.bad ${TESTSDIR}/bud/copy-from
|
2019-11-26 08:52:52 +08:00
|
|
|
expect_output --substring "COPY only supports the --chown=<uid:gid> and the --from=<image|stage> flags"
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-24 02:15:17 +08:00
|
|
|
@test "bud with copy-from referencing the base image" {
|
|
|
|
|
_prefetch busybox
|
|
|
|
|
target=busybox-derived
|
2020-06-22 16:53:02 +08:00
|
|
|
target_mt=busybox-mt-derived
|
2020-04-24 02:15:17 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy-from/Dockerfile3 ${TESTSDIR}/bud/copy-from
|
2020-06-22 16:53:02 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --jobs 4 -t ${target} -f ${TESTSDIR}/bud/copy-from/Dockerfile3 ${TESTSDIR}/bud/copy-from
|
|
|
|
|
|
2020-04-24 02:15:17 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy-from/Dockerfile4 ${TESTSDIR}/bud/copy-from
|
2020-06-22 16:53:02 +08:00
|
|
|
run_buildah bud --no-cache --signature-policy ${TESTSDIR}/policy.json --jobs 4 -t ${target_mt} -f ${TESTSDIR}/bud/copy-from/Dockerfile4 ${TESTSDIR}/bud/copy-from
|
|
|
|
|
|
|
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root_single_job=$output
|
|
|
|
|
|
|
|
|
|
run_buildah from --quiet ${target_mt}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root_multi_job=$output
|
|
|
|
|
|
|
|
|
|
# Check that both the version with --jobs 1 and --jobs=N have the same number of files
|
|
|
|
|
test $(find $root_single_job -type f | wc -l) = $(find $root_multi_job -type f | wc -l)
|
2020-04-24 02:15:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with copy-from referencing the current stage" {
|
|
|
|
|
_prefetch busybox
|
|
|
|
|
target=busybox-derived
|
|
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy-from/Dockerfile2.bad ${TESTSDIR}/bud/copy-from
|
|
|
|
|
expect_output --substring "COPY --from=build: no stage or image found with that name"
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 07:31:44 +08:00
|
|
|
@test "bud-target" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine ubuntu
|
2019-02-03 07:31:44 +08:00
|
|
|
target=target
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --target mytarget ${TESTSDIR}/bud/target
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "STEP 1: FROM ubuntu:latest"
|
|
|
|
|
expect_output --substring "STEP 3: FROM alpine:latest AS mytarget"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
test -e ${root}/2
|
|
|
|
|
test ! -e ${root}/3
|
2019-02-03 07:31:44 +08:00
|
|
|
}
|
2019-03-21 01:06:29 +08:00
|
|
|
|
|
|
|
|
@test "bud-no-target-name" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-03-21 01:06:29 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/maintainer
|
|
|
|
|
}
|
2019-04-16 00:57:39 +08:00
|
|
|
|
|
|
|
|
@test "bud-multi-stage-nocache-nocommit" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-16 00:57:39 +08:00
|
|
|
# pull the base image directly, so that we don't record it being written to local storage in the next step
|
|
|
|
|
run_buildah pull --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
|
# okay, build an image with two stages
|
2019-10-29 06:03:31 +08:00
|
|
|
run_buildah --log-level=debug bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds
|
2019-04-16 00:57:39 +08:00
|
|
|
# debug messages should only record us creating one new image: the one for the second stage, since we don't base anything on the first
|
|
|
|
|
run grep "created new image ID" <<< "$output"
|
2019-10-29 06:03:31 +08:00
|
|
|
expect_line_count 1
|
2019-04-16 00:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-multi-stage-cache-nocontainer" {
|
2020-07-06 17:58:10 +08:00
|
|
|
skip "FIXME: Broken in CI right now"
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-16 00:57:39 +08:00
|
|
|
# first time through, quite normal
|
|
|
|
|
run_buildah bud --layers -t base --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.rebase ${TESTSDIR}/bud/multi-stage-builds
|
|
|
|
|
# second time through, everything should be cached, and we shouldn't create a container based on the final image
|
2019-10-29 06:03:31 +08:00
|
|
|
run_buildah --log-level=debug bud --layers -t base --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.rebase ${TESTSDIR}/bud/multi-stage-builds
|
2019-04-16 00:57:39 +08:00
|
|
|
# skip everything up through the final COMMIT step, and make sure we didn't log a "Container ID:" after it
|
|
|
|
|
run sed '0,/COMMIT base/ d' <<< "$output"
|
2019-12-12 07:21:51 +08:00
|
|
|
echo "$output" >&2
|
2019-04-16 00:57:39 +08:00
|
|
|
test "${#lines[@]}" -gt 1
|
|
|
|
|
run grep "Container ID:" <<< "$output"
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output ""
|
2019-04-16 00:57:39 +08:00
|
|
|
}
|
2019-03-26 02:29:39 +08:00
|
|
|
|
|
|
|
|
@test "bud copy to symlink" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-03-26 02:29:39 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
ctr=alpine-ctr
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/dest-symlink
|
2019-03-26 02:29:39 +08:00
|
|
|
expect_output --substring "STEP 5: RUN ln -s "
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name=${ctr} ${target}
|
2019-03-26 02:29:39 +08:00
|
|
|
expect_output --substring ${ctr}
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /etc/hbase
|
2019-03-26 02:29:39 +08:00
|
|
|
expect_output --substring "/etc/hbase -> /usr/local/hbase/"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /usr/local/hbase
|
2019-03-26 02:29:39 +08:00
|
|
|
expect_output --substring "Dockerfile"
|
|
|
|
|
}
|
2019-04-27 07:39:16 +08:00
|
|
|
|
2019-05-26 20:56:13 +08:00
|
|
|
@test "bud copy to dangling symlink" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch ubuntu
|
2019-05-26 20:56:13 +08:00
|
|
|
target=ubuntu-image
|
|
|
|
|
ctr=ubuntu-ctr
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/dest-symlink-dangling
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "STEP 3: RUN ln -s "
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name=${ctr} ${target}
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring ${ctr}
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /src
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "/src -> /symlink"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /symlink
|
2019-05-26 20:56:13 +08:00
|
|
|
expect_output --substring "Dockerfile"
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-27 07:39:16 +08:00
|
|
|
@test "bud WORKDIR isa symlink" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-27 07:39:16 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
ctr=alpine-ctr
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/workdir-symlink
|
2019-04-27 07:39:16 +08:00
|
|
|
expect_output --substring "STEP 3: RUN ln -sf "
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name=${ctr} ${target}
|
2019-04-27 07:39:16 +08:00
|
|
|
expect_output --substring ${ctr}
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /tempest
|
2019-04-27 07:39:16 +08:00
|
|
|
expect_output --substring "/tempest -> /var/lib/tempest/"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /etc/notareal.conf
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "\-rw\-rw\-r\-\-"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud WORKDIR isa symlink no target dir" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-05-04 06:06:21 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
ctr=alpine-ctr
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile-2 ${TESTSDIR}/bud/workdir-symlink
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "STEP 2: RUN ln -sf "
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name=${ctr} ${target}
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring ${ctr}
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /tempest
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "/tempest -> /var/lib/tempest/"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls /tempest
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "Dockerfile-2"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /etc/notareal.conf
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "\-rw\-rw\-r\-\-"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud WORKDIR isa symlink no target dir and follow on dir" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-05-04 06:06:21 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
ctr=alpine-ctr
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile-3 ${TESTSDIR}/bud/workdir-symlink
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "STEP 2: RUN ln -sf "
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name=${ctr} ${target}
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring ${ctr}
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /tempest
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "/tempest -> /var/lib/tempest/"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls /tempest
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "Dockerfile-3"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls /tempest/lowerdir
|
2019-05-04 06:06:21 +08:00
|
|
|
expect_output --substring "Dockerfile-3"
|
|
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah run ${ctr} ls -alF /etc/notareal.conf
|
2019-04-27 07:39:16 +08:00
|
|
|
expect_output --substring "\-rw\-rw\-r\-\-"
|
|
|
|
|
}
|
2019-04-28 18:33:09 +08:00
|
|
|
|
2020-12-22 00:19:56 +08:00
|
|
|
@test "buildah bud --volume" {
|
2020-01-06 23:43:20 +08:00
|
|
|
voldir=${TESTDIR}/bud-volume
|
|
|
|
|
mkdir -p ${voldir}
|
|
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2020-01-06 23:43:20 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -v ${voldir}:/testdir ${TESTSDIR}/bud/mount
|
2019-04-28 18:33:09 +08:00
|
|
|
expect_output --substring "/testdir"
|
2020-01-06 23:43:20 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -v ${voldir}:/testdir:rw ${TESTSDIR}/bud/mount
|
2019-12-22 05:43:59 +08:00
|
|
|
expect_output --substring "/testdir"
|
2020-01-06 23:43:20 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -v ${voldir}:/testdir:rw,z ${TESTSDIR}/bud/mount
|
2019-12-22 05:43:59 +08:00
|
|
|
expect_output --substring "/testdir"
|
2019-04-28 18:33:09 +08:00
|
|
|
}
|
2019-05-09 03:53:05 +08:00
|
|
|
|
2019-04-19 14:27:38 +08:00
|
|
|
@test "bud-copy-dot with --layers picks up changed file" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-04-19 14:27:38 +08:00
|
|
|
cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers
|
|
|
|
|
|
|
|
|
|
mkdir -p ${TESTDIR}/use-layers/subdir
|
|
|
|
|
touch ${TESTDIR}/use-layers/subdir/file.txt
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers --iidfile ${TESTDIR}/iid1 -f Dockerfile.7 ${TESTDIR}/use-layers
|
|
|
|
|
|
|
|
|
|
touch ${TESTDIR}/use-layers/subdir/file.txt
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers --iidfile ${TESTDIR}/iid2 -f Dockerfile.7 ${TESTDIR}/use-layers
|
|
|
|
|
|
2020-07-15 04:31:00 +08:00
|
|
|
if [[ $(cat ${TESTDIR}/iid1) != $(cat ${TESTDIR}/iid2) ]]; then
|
|
|
|
|
echo "Expected image id to not change after touching a file copied into the image" >&2
|
2019-04-19 14:27:38 +08:00
|
|
|
false
|
|
|
|
|
fi
|
|
|
|
|
}
|
2019-05-09 03:53:05 +08:00
|
|
|
|
|
|
|
|
@test "buildah-bud-policy" {
|
|
|
|
|
target=foo
|
|
|
|
|
|
|
|
|
|
# A deny-all policy should prevent us from pulling the base image.
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/deny.json -t ${target} -v ${TESTSDIR}:/testdir ${TESTSDIR}/bud/mount
|
2019-05-09 03:53:05 +08:00
|
|
|
expect_output --substring 'Source image rejected: Running image .* rejected by policy.'
|
|
|
|
|
|
|
|
|
|
# A docker-only policy should allow us to pull the base image and commit.
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/docker.json -t ${target} -v ${TESTSDIR}:/testdir ${TESTSDIR}/bud/mount
|
2019-08-13 12:23:28 +08:00
|
|
|
# A deny-all policy shouldn't break pushing, since policy is only evaluated
|
|
|
|
|
# on the source image, and we force it to allow local storage.
|
2019-05-09 03:53:05 +08:00
|
|
|
run_buildah push --signature-policy ${TESTSDIR}/deny.json ${target} dir:${TESTDIR}/mount
|
2019-12-09 21:45:52 +08:00
|
|
|
run_buildah rmi ${target}
|
2019-05-09 03:53:05 +08:00
|
|
|
|
|
|
|
|
# A docker-only policy should allow us to pull the base image first...
|
|
|
|
|
run_buildah pull --signature-policy ${TESTSDIR}/docker.json alpine
|
|
|
|
|
# ... and since we don't need to pull the base image, a deny-all policy shouldn't break a build.
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/deny.json -t ${target} -v ${TESTSDIR}:/testdir ${TESTSDIR}/bud/mount
|
2019-08-13 12:23:28 +08:00
|
|
|
# A deny-all policy shouldn't break pushing, since policy is only evaluated
|
|
|
|
|
# on the source image, and we force it to allow local storage.
|
2019-05-09 03:53:05 +08:00
|
|
|
run_buildah push --signature-policy ${TESTSDIR}/deny.json ${target} dir:${TESTDIR}/mount
|
2019-08-13 12:23:28 +08:00
|
|
|
# Similarly, a deny-all policy shouldn't break committing directly to other locations.
|
2019-05-09 03:53:05 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/deny.json -t dir:${TESTDIR}/mount -v ${TESTSDIR}:/testdir ${TESTSDIR}/bud/mount
|
|
|
|
|
}
|
2019-05-29 22:00:38 +08:00
|
|
|
|
|
|
|
|
@test "bud-copy-replace-symlink" {
|
|
|
|
|
mkdir -p ${TESTDIR}/top
|
|
|
|
|
cp ${TESTSDIR}/bud/symlink/Dockerfile.replace-symlink ${TESTDIR}/top/
|
|
|
|
|
ln -s Dockerfile.replace-symlink ${TESTDIR}/top/symlink
|
|
|
|
|
echo foo > ${TESTDIR}/top/.dockerignore
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTDIR}/top/Dockerfile.replace-symlink ${TESTDIR}/top
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-copy-recurse" {
|
|
|
|
|
mkdir -p ${TESTDIR}/recurse
|
|
|
|
|
cp ${TESTSDIR}/bud/recurse/Dockerfile ${TESTDIR}/recurse
|
|
|
|
|
echo foo > ${TESTDIR}/recurse/.dockerignore
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json ${TESTDIR}/recurse
|
|
|
|
|
}
|
2019-06-04 03:55:30 +08:00
|
|
|
|
2020-03-21 19:20:11 +08:00
|
|
|
@test "bud copy with .dockerignore #1" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
mytmpdir=${TESTDIR}/my-dir
|
|
|
|
|
mkdir -p $mytmpdir/stuff/huge/usr/bin/
|
|
|
|
|
(cd $mytmpdir/stuff/huge/usr/bin/; touch file1 file2)
|
|
|
|
|
(cd $mytmpdir/stuff/huge/usr/; touch file3)
|
|
|
|
|
|
|
|
|
|
cat > $mytmpdir/.dockerignore << _EOF
|
|
|
|
|
stuff/huge/*
|
|
|
|
|
!stuff/huge/usr/bin/*
|
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
|
|
cat > $mytmpdir/Containerfile << _EOF
|
|
|
|
|
FROM alpine
|
|
|
|
|
COPY stuff /tmp/stuff
|
|
|
|
|
RUN find /tmp/stuff -type f
|
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
|
|
run_buildah bud -t testbud --signature-policy ${TESTSDIR}/policy.json ${mytmpdir}
|
|
|
|
|
expect_output --substring "file1"
|
|
|
|
|
expect_output --substring "file2"
|
|
|
|
|
! expect_output --substring "file3"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud copy with .dockerignore #2" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
mytmpdir=${TESTDIR}/my-dir1
|
|
|
|
|
mkdir -p $mytmpdir/stuff/huge/usr/bin/
|
|
|
|
|
(cd $mytmpdir/stuff/huge/usr/bin/; touch file1 file2)
|
|
|
|
|
|
|
|
|
|
cat > $mytmpdir/.dockerignore << _EOF
|
|
|
|
|
stuff/huge/*
|
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
|
|
cat > $mytmpdir/Containerfile << _EOF
|
|
|
|
|
FROM alpine
|
|
|
|
|
COPY stuff /tmp/stuff
|
|
|
|
|
RUN find /tmp/stuff -type f
|
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
|
|
run_buildah bud -t testbud --signature-policy ${TESTSDIR}/policy.json ${mytmpdir}
|
|
|
|
|
! expect_output --substring "file1"
|
|
|
|
|
! expect_output --substring "file2"
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 03:55:30 +08:00
|
|
|
@test "bud-copy-workdir" {
|
|
|
|
|
target=testimage
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/copy-workdir
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from ${target}
|
2019-06-04 03:55:30 +08:00
|
|
|
cid="$output"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah mount "${cid}"
|
2019-06-04 03:55:30 +08:00
|
|
|
root="$output"
|
|
|
|
|
test -s "${root}"/file1.txt
|
|
|
|
|
test -d "${root}"/subdir
|
|
|
|
|
test -s "${root}"/subdir/file2.txt
|
|
|
|
|
}
|
2019-06-07 04:22:47 +08:00
|
|
|
|
|
|
|
|
@test "bud-build-arg-cache" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-06-07 04:22:47 +08:00
|
|
|
target=derived-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile3 ${TESTSDIR}/bud/build-arg
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-06-07 04:22:47 +08:00
|
|
|
targetid="$output"
|
|
|
|
|
|
|
|
|
|
# With build args, we should not find the previous build as a cached result.
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile3 --build-arg=UID=17122 --build-arg=CODE=/copr/coprs_frontend --build-arg=USERNAME=praiskup --build-arg=PGDATA=/pgdata ${TESTSDIR}/bud/build-arg
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-06-07 04:22:47 +08:00
|
|
|
argsid="$output"
|
|
|
|
|
[[ "$argsid" != "$targetid" ]]
|
|
|
|
|
|
|
|
|
|
# With build args, even in a different order, we should end up using the previous build as a cached result.
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile3 --build-arg=UID=17122 --build-arg=CODE=/copr/coprs_frontend --build-arg=USERNAME=praiskup --build-arg=PGDATA=/pgdata ${TESTSDIR}/bud/build-arg
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$argsid"
|
2019-06-07 04:22:47 +08:00
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile3 --build-arg=CODE=/copr/coprs_frontend --build-arg=USERNAME=praiskup --build-arg=PGDATA=/pgdata --build-arg=UID=17122 ${TESTSDIR}/bud/build-arg
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$argsid"
|
2019-06-07 04:22:47 +08:00
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile3 --build-arg=USERNAME=praiskup --build-arg=PGDATA=/pgdata --build-arg=UID=17122 --build-arg=CODE=/copr/coprs_frontend ${TESTSDIR}/bud/build-arg
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$argsid"
|
2019-06-07 04:22:47 +08:00
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} -f Dockerfile3 --build-arg=PGDATA=/pgdata --build-arg=UID=17122 --build-arg=CODE=/copr/coprs_frontend --build-arg=USERNAME=praiskup ${TESTSDIR}/bud/build-arg
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect -f '{{.FromImageID}}' ${target}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$argsid"
|
2019-06-07 04:22:47 +08:00
|
|
|
}
|
2019-06-19 06:05:10 +08:00
|
|
|
|
|
|
|
|
@test "bud test RUN with a priv'd command" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-06-19 06:05:10 +08:00
|
|
|
target=alpinepriv
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/run-privd/Dockerfile ${TESTSDIR}/bud/run-privd
|
|
|
|
|
expect_output --substring "STEP 3: COMMIT"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah images -q
|
2019-08-13 15:26:44 +08:00
|
|
|
expect_line_count 2
|
2019-06-19 06:05:10 +08:00
|
|
|
}
|
2019-06-08 05:58:04 +08:00
|
|
|
|
|
|
|
|
@test "bud-copy-dockerignore-hardlinks" {
|
|
|
|
|
target=image
|
|
|
|
|
mkdir -p ${TESTDIR}/hardlinks/subdir
|
|
|
|
|
cp ${TESTSDIR}/bud/recurse/Dockerfile ${TESTDIR}/hardlinks
|
|
|
|
|
echo foo > ${TESTDIR}/hardlinks/.dockerignore
|
|
|
|
|
echo test1 > ${TESTDIR}/hardlinks/subdir/test1.txt
|
|
|
|
|
ln ${TESTDIR}/hardlinks/subdir/test1.txt ${TESTDIR}/hardlinks/subdir/test2.txt
|
|
|
|
|
ln ${TESTDIR}/hardlinks/subdir/test2.txt ${TESTDIR}/hardlinks/test3.txt
|
|
|
|
|
ln ${TESTDIR}/hardlinks/test3.txt ${TESTDIR}/hardlinks/test4.txt
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTDIR}/hardlinks
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah from ${target}
|
2019-06-08 05:58:04 +08:00
|
|
|
ctrid="$output"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah mount "$ctrid"
|
2019-06-08 05:58:04 +08:00
|
|
|
root="$output"
|
2019-12-12 07:21:51 +08:00
|
|
|
|
|
|
|
|
run stat -c "%d:%i" ${root}/subdir/test1.txt
|
|
|
|
|
id1=$output
|
2019-07-25 22:10:03 +08:00
|
|
|
run stat -c "%h" ${root}/subdir/test1.txt
|
|
|
|
|
expect_output 4
|
2019-12-12 07:21:51 +08:00
|
|
|
run stat -c "%d:%i" ${root}/subdir/test2.txt
|
|
|
|
|
expect_output $id1 "stat(test2) == stat(test1)"
|
2019-07-25 22:10:03 +08:00
|
|
|
run stat -c "%h" ${root}/subdir/test2.txt
|
|
|
|
|
expect_output 4
|
2019-12-12 07:21:51 +08:00
|
|
|
run stat -c "%d:%i" ${root}/test3.txt
|
|
|
|
|
expect_output $id1 "stat(test3) == stat(test1)"
|
2019-07-25 22:10:03 +08:00
|
|
|
run stat -c "%h" ${root}/test3.txt
|
|
|
|
|
expect_output 4
|
2019-12-12 07:21:51 +08:00
|
|
|
run stat -c "%d:%i" ${root}/test4.txt
|
|
|
|
|
expect_output $id1 "stat(test4) == stat(test1)"
|
2019-07-25 22:10:03 +08:00
|
|
|
run stat -c "%h" ${root}/test4.txt
|
|
|
|
|
expect_output 4
|
2019-06-08 05:58:04 +08:00
|
|
|
}
|
2019-08-13 15:26:44 +08:00
|
|
|
|
|
|
|
|
@test "bud without any arguments should succeed" {
|
|
|
|
|
cd ${TESTSDIR}/bud/from-scratch
|
2019-08-20 02:15:03 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json
|
2019-08-13 15:26:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud without any arguments should fail when no Dockerfile exist" {
|
|
|
|
|
cd $(mktemp -d)
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "no such file or directory"
|
2019-08-13 15:26:44 +08:00
|
|
|
}
|
Fix possible runtime panic on bud
The current code triggers a runtime panic in `imagebuildah/build.go:201`
if buildah is specifying a file as build context, which will be
interpreted wrongly as `Dockerfile`.
Reproduce with:
```
> buildah bud <any exinsting file>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x561c1706f0a5]
goroutine 1 [running]:
github.com/containers/buildah/imagebuildah.BuildDockerfiles(0x561c17513b00, 0xc0000ba038, 0x561c1751bd60, 0xc00075a360, 0x7ffebb358667, 0x18, 0x0, 0x0, 0x0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/imagebuildah/build.go:201 +0xd85
main.budCmd(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0xc0006e3da8, 0xc000098f00, 0xc0003b8b40, 0xc000099080, 0xc0003b8ba0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:292 +0x12e6
main.init.1.func1(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0x0, 0x0)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:50 +0xd8
github.com/spf13/cobra.(*Command).execute(0xc000173400, 0xc0000afca0, 0x1, 0x1, 0xc000173400, 0xc0000afca0)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:762 +0x475
github.com/spf13/cobra.(*Command).ExecuteC(0x561c17a8f700, 0xc000721f18, 0x561c17039a74, 0xc000721f00)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:852 +0x2ff
github.com/spf13/cobra.(*Command).Execute(0x561c17a8f700, 0x1, 0xc000721f88)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:800 +0x2d
main.main()
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/main.go:125 +0x42
```
We now check if the file exists before passing the Dockerfile around.
For this we introduce a new function `discoverDockerfile`, which tries
to find a corresponding Dockerfile for a given directory.
All possible integration test scenarios have been added as well.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1795
Approved by: TomSweeneyRedHat
2019-08-15 22:29:14 +08:00
|
|
|
|
|
|
|
|
@test "bud with specified context should fail if directory contains no Dockerfile" {
|
|
|
|
|
DIR=$(mktemp -d)
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "no such file or directory"
|
Fix possible runtime panic on bud
The current code triggers a runtime panic in `imagebuildah/build.go:201`
if buildah is specifying a file as build context, which will be
interpreted wrongly as `Dockerfile`.
Reproduce with:
```
> buildah bud <any exinsting file>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x561c1706f0a5]
goroutine 1 [running]:
github.com/containers/buildah/imagebuildah.BuildDockerfiles(0x561c17513b00, 0xc0000ba038, 0x561c1751bd60, 0xc00075a360, 0x7ffebb358667, 0x18, 0x0, 0x0, 0x0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/imagebuildah/build.go:201 +0xd85
main.budCmd(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0xc0006e3da8, 0xc000098f00, 0xc0003b8b40, 0xc000099080, 0xc0003b8ba0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:292 +0x12e6
main.init.1.func1(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0x0, 0x0)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:50 +0xd8
github.com/spf13/cobra.(*Command).execute(0xc000173400, 0xc0000afca0, 0x1, 0x1, 0xc000173400, 0xc0000afca0)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:762 +0x475
github.com/spf13/cobra.(*Command).ExecuteC(0x561c17a8f700, 0xc000721f18, 0x561c17039a74, 0xc000721f00)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:852 +0x2ff
github.com/spf13/cobra.(*Command).Execute(0x561c17a8f700, 0x1, 0xc000721f88)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:800 +0x2d
main.main()
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/main.go:125 +0x42
```
We now check if the file exists before passing the Dockerfile around.
For this we introduce a new function `discoverDockerfile`, which tries
to find a corresponding Dockerfile for a given directory.
All possible integration test scenarios have been added as well.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1795
Approved by: TomSweeneyRedHat
2019-08-15 22:29:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with specified context should fail if assumed Dockerfile is a directory" {
|
|
|
|
|
DIR=$(mktemp -d)
|
|
|
|
|
mkdir -p "$DIR"/Dockerfile
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "is not a file"
|
Fix possible runtime panic on bud
The current code triggers a runtime panic in `imagebuildah/build.go:201`
if buildah is specifying a file as build context, which will be
interpreted wrongly as `Dockerfile`.
Reproduce with:
```
> buildah bud <any exinsting file>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x561c1706f0a5]
goroutine 1 [running]:
github.com/containers/buildah/imagebuildah.BuildDockerfiles(0x561c17513b00, 0xc0000ba038, 0x561c1751bd60, 0xc00075a360, 0x7ffebb358667, 0x18, 0x0, 0x0, 0x0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/imagebuildah/build.go:201 +0xd85
main.budCmd(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0xc0006e3da8, 0xc000098f00, 0xc0003b8b40, 0xc000099080, 0xc0003b8ba0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:292 +0x12e6
main.init.1.func1(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0x0, 0x0)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:50 +0xd8
github.com/spf13/cobra.(*Command).execute(0xc000173400, 0xc0000afca0, 0x1, 0x1, 0xc000173400, 0xc0000afca0)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:762 +0x475
github.com/spf13/cobra.(*Command).ExecuteC(0x561c17a8f700, 0xc000721f18, 0x561c17039a74, 0xc000721f00)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:852 +0x2ff
github.com/spf13/cobra.(*Command).Execute(0x561c17a8f700, 0x1, 0xc000721f88)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:800 +0x2d
main.main()
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/main.go:125 +0x42
```
We now check if the file exists before passing the Dockerfile around.
For this we introduce a new function `discoverDockerfile`, which tries
to find a corresponding Dockerfile for a given directory.
All possible integration test scenarios have been added as well.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1795
Approved by: TomSweeneyRedHat
2019-08-15 22:29:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with specified context should fail if context contains not-existing Dockerfile" {
|
|
|
|
|
DIR=$(mktemp -d)
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"/Dockerfile
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output --substring "no such file or directory"
|
Fix possible runtime panic on bud
The current code triggers a runtime panic in `imagebuildah/build.go:201`
if buildah is specifying a file as build context, which will be
interpreted wrongly as `Dockerfile`.
Reproduce with:
```
> buildah bud <any exinsting file>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x561c1706f0a5]
goroutine 1 [running]:
github.com/containers/buildah/imagebuildah.BuildDockerfiles(0x561c17513b00, 0xc0000ba038, 0x561c1751bd60, 0xc00075a360, 0x7ffebb358667, 0x18, 0x0, 0x0, 0x0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/imagebuildah/build.go:201 +0xd85
main.budCmd(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0xc0006e3da8, 0xc000098f00, 0xc0003b8b40, 0xc000099080, 0xc0003b8ba0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:292 +0x12e6
main.init.1.func1(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0x0, 0x0)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:50 +0xd8
github.com/spf13/cobra.(*Command).execute(0xc000173400, 0xc0000afca0, 0x1, 0x1, 0xc000173400, 0xc0000afca0)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:762 +0x475
github.com/spf13/cobra.(*Command).ExecuteC(0x561c17a8f700, 0xc000721f18, 0x561c17039a74, 0xc000721f00)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:852 +0x2ff
github.com/spf13/cobra.(*Command).Execute(0x561c17a8f700, 0x1, 0xc000721f88)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:800 +0x2d
main.main()
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/main.go:125 +0x42
```
We now check if the file exists before passing the Dockerfile around.
For this we introduce a new function `discoverDockerfile`, which tries
to find a corresponding Dockerfile for a given directory.
All possible integration test scenarios have been added as well.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1795
Approved by: TomSweeneyRedHat
2019-08-15 22:29:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with specified context should succeed if context contains existing Dockerfile" {
|
|
|
|
|
DIR=$(mktemp -d)
|
2020-10-15 17:16:50 +08:00
|
|
|
echo "FROM alpine" > "$DIR"/Dockerfile
|
2019-08-20 02:15:03 +08:00
|
|
|
run_buildah 0 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"/Dockerfile
|
Fix possible runtime panic on bud
The current code triggers a runtime panic in `imagebuildah/build.go:201`
if buildah is specifying a file as build context, which will be
interpreted wrongly as `Dockerfile`.
Reproduce with:
```
> buildah bud <any exinsting file>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x561c1706f0a5]
goroutine 1 [running]:
github.com/containers/buildah/imagebuildah.BuildDockerfiles(0x561c17513b00, 0xc0000ba038, 0x561c1751bd60, 0xc00075a360, 0x7ffebb358667, 0x18, 0x0, 0x0, 0x0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/imagebuildah/build.go:201 +0xd85
main.budCmd(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0xc0006e3da8, 0xc000098f00, 0xc0003b8b40, 0xc000099080, 0xc0003b8ba0, 0x0, ...)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:292 +0x12e6
main.init.1.func1(0xc000173400, 0xc0000afce0, 0x1, 0x1, 0x0, 0x0)
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/bud.go:50 +0xd8
github.com/spf13/cobra.(*Command).execute(0xc000173400, 0xc0000afca0, 0x1, 0x1, 0xc000173400, 0xc0000afca0)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:762 +0x475
github.com/spf13/cobra.(*Command).ExecuteC(0x561c17a8f700, 0xc000721f18, 0x561c17039a74, 0xc000721f00)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:852 +0x2ff
github.com/spf13/cobra.(*Command).Execute(0x561c17a8f700, 0x1, 0xc000721f88)
/home/abuild/go/src/github.com/containers/buildah/vendor/github.com/spf13/cobra/command.go:800 +0x2d
main.main()
/home/abuild/go/src/github.com/containers/buildah/cmd/buildah/main.go:125 +0x42
```
We now check if the file exists before passing the Dockerfile around.
For this we introduce a new function `discoverDockerfile`, which tries
to find a corresponding Dockerfile for a given directory.
All possible integration test scenarios have been added as well.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Closes: #1795
Approved by: TomSweeneyRedHat
2019-08-15 22:29:14 +08:00
|
|
|
}
|
2019-09-04 05:06:48 +08:00
|
|
|
|
2020-10-15 17:16:50 +08:00
|
|
|
@test "bud with specified context should fail if context contains empty Dockerfile" {
|
|
|
|
|
DIR=$(mktemp -d)
|
|
|
|
|
touch "$DIR"/Dockerfile
|
|
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"/Dockerfile
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 05:06:48 +08:00
|
|
|
@test "bud-no-change" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-04 05:06:48 +08:00
|
|
|
parent=alpine
|
|
|
|
|
target=no-change-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/no-change
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .FromImageDigest}}' ${parent}
|
2019-09-04 05:06:48 +08:00
|
|
|
parentid="$output"
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .FromImageDigest}}' ${target}
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$parentid"
|
2019-09-04 05:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-no-change-label" {
|
2020-08-05 05:00:47 +08:00
|
|
|
run_buildah --version
|
|
|
|
|
local -a output_fields=($output)
|
|
|
|
|
buildah_version=${output_fields[2]}
|
|
|
|
|
want_output='map["io.buildah.version":"'$buildah_version'" "test":"label"]'
|
|
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-04 05:06:48 +08:00
|
|
|
parent=alpine
|
|
|
|
|
target=no-change-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --label "test=label" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/no-change
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .Docker.Config.Labels}}' ${target}
|
2020-08-05 05:00:47 +08:00
|
|
|
expect_output "$want_output"
|
2019-09-04 05:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-no-change-annotation" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-04 05:06:48 +08:00
|
|
|
target=no-change-image
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah bud --annotation "test=annotation" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/no-change
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah inspect --format '{{printf "%q" .ImageAnnotations}}' ${target}
|
2019-09-04 05:06:48 +08:00
|
|
|
expect_output 'map["test":"annotation"]'
|
|
|
|
|
}
|
2019-09-05 02:57:10 +08:00
|
|
|
|
|
|
|
|
@test "bud-squash-layers" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-05 02:57:10 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --squash ${TESTSDIR}/bud/layers-squash
|
|
|
|
|
}
|
2019-09-07 03:07:18 +08:00
|
|
|
|
2020-09-09 05:55:07 +08:00
|
|
|
@test "bud-squash-hardlinks" {
|
|
|
|
|
_prefetch busybox
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --squash ${TESTSDIR}/bud/layers-squash/Dockerfile.hardlinks
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-22 09:59:15 +08:00
|
|
|
@test "bud with additional directory of devices" {
|
2019-11-06 02:22:07 +08:00
|
|
|
skip_if_chroot
|
|
|
|
|
skip_if_rootless
|
|
|
|
|
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-10-22 09:59:15 +08:00
|
|
|
target=alpine-image
|
2019-10-29 06:03:31 +08:00
|
|
|
rm -rf ${TESTSDIR}/foo
|
|
|
|
|
mkdir -p ${TESTSDIR}/foo
|
2019-10-22 09:59:15 +08:00
|
|
|
mknod ${TESTSDIR}/foo/null c 1 3
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --device ${TESTSDIR}/foo:/dev/fuse -t ${target} -f ${TESTSDIR}/bud/device/Dockerfile ${TESTSDIR}/bud/device
|
|
|
|
|
expect_output --substring "null"
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-07 03:07:18 +08:00
|
|
|
@test "bud with additional device" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-07 03:07:18 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --device /dev/fuse -t ${target} -f ${TESTSDIR}/bud/device/Dockerfile ${TESTSDIR}/bud/device
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "/dev/fuse"
|
|
|
|
|
}
|
2019-09-16 01:29:56 +08:00
|
|
|
|
|
|
|
|
@test "bud with Containerfile" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-16 01:29:56 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with Dockerfile" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-16 01:29:56 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/dockerfile
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with Containerfile and Dockerfile" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-16 01:29:56 +08:00
|
|
|
target=alpine-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containeranddockerfile
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-http-context-with-Containerfile" {
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
_test_http http-context-containerfile context.tar
|
2019-09-16 01:29:56 +08:00
|
|
|
}
|
2019-09-18 17:25:50 +08:00
|
|
|
|
|
|
|
|
@test "bud with Dockerfile from stdin" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-18 17:25:50 +08:00
|
|
|
target=df-stdin
|
|
|
|
|
cat ${TESTSDIR}/bud/context-from-stdin/Dockerfile | buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -
|
|
|
|
|
[ "$?" -eq 0 ]
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
|
|
|
|
|
test -s $root/scratchfile
|
|
|
|
|
run cat $root/scratchfile
|
|
|
|
|
expect_output "stdin-context" "contents of \$root/scratchfile"
|
|
|
|
|
|
|
|
|
|
# FROM scratch overrides FROM alpine
|
|
|
|
|
test ! -s $root/etc/alpine-release
|
2019-09-18 17:25:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with Dockerfile from stdin tar" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-09-18 17:25:50 +08:00
|
|
|
target=df-stdin
|
|
|
|
|
tar -c -C ${TESTSDIR}/bud/context-from-stdin . | buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -
|
|
|
|
|
[ "$?" -eq 0 ]
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
cid=$output
|
|
|
|
|
run_buildah mount ${cid}
|
|
|
|
|
root=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
|
|
|
|
|
test -s $root/scratchfile
|
|
|
|
|
run cat $root/scratchfile
|
|
|
|
|
expect_output "stdin-context" "contents of \$root/scratchfile"
|
|
|
|
|
|
|
|
|
|
# FROM scratch overrides FROM alpine
|
|
|
|
|
test ! -s $root/etc/alpine-release
|
2019-09-18 17:25:50 +08:00
|
|
|
}
|
2019-09-28 07:56:14 +08:00
|
|
|
|
|
|
|
|
@test "bud containerfile with args" {
|
2020-02-07 01:04:17 +08:00
|
|
|
_prefetch alpine
|
2019-09-28 07:56:14 +08:00
|
|
|
target=use-args
|
|
|
|
|
touch ${TESTSDIR}/bud/use-args/abc.txt
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --build-arg=abc.txt ${TESTSDIR}/bud/use-args
|
|
|
|
|
expect_output --substring "COMMIT use-args"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
ctrID=$output
|
2019-09-28 07:56:14 +08:00
|
|
|
run_buildah run $ctrID ls abc.txt
|
|
|
|
|
expect_output --substring "abc.txt"
|
|
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Containerfile.destination --build-arg=testArg=abc.txt --build-arg=destination=/tmp ${TESTSDIR}/bud/use-args
|
|
|
|
|
expect_output --substring "COMMIT use-args"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
ctrID=$output
|
2019-09-28 07:56:14 +08:00
|
|
|
run_buildah run $ctrID ls /tmp/abc.txt
|
|
|
|
|
expect_output --substring "abc.txt"
|
|
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Containerfile.dest_nobrace --build-arg=testArg=abc.txt --build-arg=destination=/tmp ${TESTSDIR}/bud/use-args
|
|
|
|
|
expect_output --substring "COMMIT use-args"
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet ${target}
|
|
|
|
|
ctrID=$output
|
2019-09-28 07:56:14 +08:00
|
|
|
run_buildah run $ctrID ls /tmp/abc.txt
|
|
|
|
|
expect_output --substring "abc.txt"
|
|
|
|
|
|
2019-10-22 09:59:15 +08:00
|
|
|
rm ${TESTSDIR}/bud/use-args/abc.txt
|
2019-09-28 07:56:14 +08:00
|
|
|
}
|
2019-10-23 01:14:13 +08:00
|
|
|
|
|
|
|
|
@test "bud using gitrepo and branch" {
|
bud.bats - cleanup, refactoring
Fix three issues identified in #2036:
- the 'gitrepo and branch' test was pulling from a place
that took four minutes; change it to our own repo,
suggested by Dan, which takes just a few seconds.
-- also, remove what I think is an unnecessary dup.
If buildah can pull from a branch, it can pull
from master.
- the httpd tests were really confusing, with lots of
copy/pasted code differing in only small ways. Refactor
to make the purpose of each test more apparent, and
to make it easier to add new ones as needed.
- combine bud-http-context-dir-with-Dockerfile -pre and -post,
since they were identical. (Context: they started off being
different tests, with command-line options in different
order, but as of #493 the -post form of options no longer
works so the -post test is no longer relevant)
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 07:29:19 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t gittarget -f tests/bud/shell/Dockerfile git://github.com/containers/buildah#release-1.11-rhel
|
2019-10-23 01:14:13 +08:00
|
|
|
}
|
2019-10-17 07:54:05 +08:00
|
|
|
|
2019-10-31 20:20:26 +08:00
|
|
|
# Fixes #1906: buildah was not detecting changed tarfile
|
2019-10-17 07:54:05 +08:00
|
|
|
@test "bud containerfile with tar archive in copy" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-10-31 20:20:26 +08:00
|
|
|
# First check to verify cache is used if the tar file does not change
|
2019-10-17 07:54:05 +08:00
|
|
|
target=copy-archive
|
2019-10-31 20:20:26 +08:00
|
|
|
date > ${TESTSDIR}/bud/${target}/test
|
|
|
|
|
tar -C $TESTSDIR -cJf ${TESTSDIR}/bud/${target}/test.tar.xz bud/${target}/test
|
2019-10-17 07:54:05 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target}
|
|
|
|
|
expect_output --substring "COMMIT copy-archive"
|
|
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target}
|
|
|
|
|
expect_output --substring " Using cache"
|
|
|
|
|
expect_output --substring "COMMIT copy-archive"
|
|
|
|
|
|
|
|
|
|
# Now test that we do NOT use cache if the tar file changes
|
2019-10-31 20:20:26 +08:00
|
|
|
echo This is a change >> ${TESTSDIR}/bud/${target}/test
|
|
|
|
|
tar -C $TESTSDIR -cJf ${TESTSDIR}/bud/${target}/test.tar.xz bud/${target}/test
|
2019-10-17 07:54:05 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t ${target} ${TESTSDIR}/bud/${target}
|
|
|
|
|
if [[ "$output" =~ " Using cache" ]]; then
|
2019-10-31 20:20:26 +08:00
|
|
|
expect_output "[no instance of 'Using cache']" "no cache used"
|
2019-10-17 07:54:05 +08:00
|
|
|
fi
|
|
|
|
|
expect_output --substring "COMMIT copy-archive"
|
|
|
|
|
|
2019-10-31 20:20:26 +08:00
|
|
|
rm -f ${TESTSDIR}/bud/${target}/test*
|
2019-10-17 07:54:05 +08:00
|
|
|
}
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
|
|
|
|
|
@test "bud pull never" {
|
|
|
|
|
target=pull
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --pull-never ${TESTSDIR}/bud/pull
|
2020-10-19 16:44:22 +08:00
|
|
|
expect_output --substring "pull policy is \"never\" but \""
|
|
|
|
|
expect_output --substring "\" could not be found locally"
|
Fix --pull=true||false and add --pull-never to bud and from (retry)
(Replaces #1873 as it had lint issues that were timing out tests that I couldn't
track down easily)
Prior to this fix, if someone did `buildah bud --pull=false .` and the image in
the Containerfile's FROM statement was not local, the build would fail. The same
build on Docker will succeed. In Docker, when `--pull` is set to false, it only
pulls the image from the registry if there was not one locally. Buildah would never
pull the image and if the image was not locally available, it would throw an error.
In certain Kubernetes environments, this was especially troublesome.
To retain the old `--pull=false` functionality, I've created a new `--pull-never`
option that fails if an image is not locally available just like the old
`--pull=false` option used to do.
In addition, if there was a newer version of the image on the repository than
the one locally, the `--pull=true` option would not pull the image as it should
have, this corrects that.
Changes both the from and bud commands.
Addresses: #1675
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #1959
Approved by: rhatdan
2019-10-31 22:15:56 +08:00
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --pull ${TESTSDIR}/bud/pull
|
|
|
|
|
expect_output --substring "COMMIT pull"
|
|
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --pull-never ${TESTSDIR}/bud/pull
|
|
|
|
|
expect_output --substring "COMMIT pull"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud pull false no local image" {
|
|
|
|
|
target=pull
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --pull=false ${TESTSDIR}/bud/pull
|
|
|
|
|
expect_output --substring "COMMIT pull"
|
|
|
|
|
}
|
2019-11-06 11:57:38 +08:00
|
|
|
|
2020-12-22 00:19:56 +08:00
|
|
|
@test "bud with Containerfile should fail with nonexistent authfile" {
|
2019-11-06 11:57:38 +08:00
|
|
|
target=alpine-image
|
2020-12-22 00:19:56 +08:00
|
|
|
run_buildah 125 bud --authfile /tmp/nonexistent --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
|
2019-11-06 11:57:38 +08:00
|
|
|
}
|
2019-11-11 23:23:36 +08:00
|
|
|
|
|
|
|
|
@test "bud COPY with URL should fail" {
|
|
|
|
|
mkdir ${TESTSDIR}/bud/copy
|
|
|
|
|
FILE=${TESTSDIR}/bud/copy/Dockerfile.url
|
|
|
|
|
/bin/cat <<EOM >$FILE
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
COPY https://getfedora.org/index.html .
|
|
|
|
|
EOM
|
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy/Dockerfile.url ${TESTSDIR}/bud/copy
|
2019-11-11 23:23:36 +08:00
|
|
|
rm -r ${TESTSDIR}/bud/copy
|
|
|
|
|
}
|
2019-10-22 21:04:36 +08:00
|
|
|
|
|
|
|
|
@test "bud quiet" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-10-22 21:04:36 +08:00
|
|
|
run_buildah bud --format docker -t quiet-test --signature-policy ${TESTSDIR}/policy.json -q ${TESTSDIR}/bud/shell
|
|
|
|
|
expect_line_count 1
|
2019-12-04 02:18:24 +08:00
|
|
|
expect_output --substring '^[0-9a-f]{64}$'
|
2019-10-22 21:04:36 +08:00
|
|
|
}
|
2020-01-19 04:43:05 +08:00
|
|
|
|
|
|
|
|
@test "bud COPY with Env Var in Containerfile" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2020-01-19 04:43:05 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t testctr ${TESTSDIR}/bud/copy-envvar
|
|
|
|
|
run_buildah from testctr
|
|
|
|
|
run_buildah run testctr-working-container ls /file-0.0.1.txt
|
|
|
|
|
run_buildah rm -a
|
|
|
|
|
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t testctr ${TESTSDIR}/bud/copy-envvar
|
|
|
|
|
run_buildah from testctr
|
|
|
|
|
run_buildah run testctr-working-container ls /file-0.0.1.txt
|
|
|
|
|
run_buildah rm -a
|
|
|
|
|
}
|
2020-01-20 19:31:09 +08:00
|
|
|
|
|
|
|
|
@test "bud with custom arch" {
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json \
|
|
|
|
|
-f ${TESTSDIR}/bud/from-scratch/Dockerfile \
|
|
|
|
|
-t arch-test \
|
|
|
|
|
--arch=arm
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .Docker.Architecture }}" arch-test
|
|
|
|
|
expect_output arm
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .OCIv1.Architecture }}" arch-test
|
|
|
|
|
expect_output arm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with custom os" {
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json \
|
|
|
|
|
-f ${TESTSDIR}/bud/from-scratch/Dockerfile \
|
|
|
|
|
-t os-test \
|
|
|
|
|
--os=windows
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .Docker.OS }}" os-test
|
|
|
|
|
expect_output windows
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .OCIv1.OS }}" os-test
|
|
|
|
|
expect_output windows
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with custom platform" {
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json \
|
|
|
|
|
-f ${TESTSDIR}/bud/from-scratch/Dockerfile \
|
|
|
|
|
-t platform-test \
|
|
|
|
|
--platform=windows/arm
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .Docker.OS }}" platform-test
|
|
|
|
|
expect_output windows
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .OCIv1.OS }}" platform-test
|
|
|
|
|
expect_output windows
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .Docker.Architecture }}" platform-test
|
|
|
|
|
expect_output arm
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format "{{ .OCIv1.Architecture }}" platform-test
|
|
|
|
|
expect_output arm
|
|
|
|
|
}
|
2020-01-26 08:42:54 +08:00
|
|
|
|
|
|
|
|
@test "bud Add with linked tarball" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2020-01-26 08:42:54 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/symlink/Containerfile.add-tar-with-link -t testctr ${TESTSDIR}/bud/symlink
|
|
|
|
|
run_buildah from testctr
|
|
|
|
|
run_buildah run testctr-working-container ls /tmp/testdir/testfile.txt
|
|
|
|
|
run_buildah rm -a
|
|
|
|
|
run_buildah rmi -a -f
|
|
|
|
|
|
2020-02-07 01:04:17 +08:00
|
|
|
_prefetch alpine
|
2020-01-26 08:42:54 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/symlink/Containerfile.add-tar-gz-with-link -t testctr ${TESTSDIR}/bud/symlink
|
|
|
|
|
run_buildah from testctr
|
|
|
|
|
run_buildah run testctr-working-container ls /tmp/testdir/testfile.txt
|
|
|
|
|
run_buildah rm -a
|
|
|
|
|
run_buildah rmi -a -f
|
|
|
|
|
}
|
2020-02-08 04:08:47 +08:00
|
|
|
|
2020-03-06 02:46:38 +08:00
|
|
|
@test "bud file above context directory" {
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t testctr ${TESTSDIR}/bud/context-escape-dir/testdir
|
2020-02-08 04:08:47 +08:00
|
|
|
expect_output --substring "escaping context directory error"
|
|
|
|
|
}
|
2020-03-24 09:08:23 +08:00
|
|
|
|
2020-03-24 09:55:36 +08:00
|
|
|
@test "bud-multi-stage-args-scope" {
|
2020-03-24 09:08:23 +08:00
|
|
|
_prefetch alpine
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t multi-stage-args --build-arg SECRET=secretthings -f Dockerfile.arg ${TESTSDIR}/bud/multi-stage-builds
|
|
|
|
|
run_buildah from --name test-container multi-stage-args
|
|
|
|
|
run_buildah run test-container -- cat test_file
|
|
|
|
|
expect_output ""
|
|
|
|
|
}
|
2020-03-24 09:55:36 +08:00
|
|
|
|
|
|
|
|
@test "bud-multi-stage-args-history" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t multi-stage-args --build-arg SECRET=secretthings -f Dockerfile.arg ${TESTSDIR}/bud/multi-stage-builds
|
|
|
|
|
run_buildah inspect --format '{{range .History}}{{println .CreatedBy}}{{end}}' multi-stage-args
|
|
|
|
|
run grep "secretthings" <<< "$output"
|
|
|
|
|
expect_output ""
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format '{{range .OCIv1.History}}{{println .CreatedBy}}{{end}}' multi-stage-args
|
|
|
|
|
run grep "secretthings" <<< "$output"
|
|
|
|
|
expect_output ""
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format '{{range .Docker.History}}{{println .CreatedBy}}{{end}}' multi-stage-args
|
|
|
|
|
run grep "secretthings" <<< "$output"
|
|
|
|
|
expect_output ""
|
|
|
|
|
}
|
2020-04-02 02:15:56 +08:00
|
|
|
|
|
|
|
|
@test "bud with encrypted FROM image" {
|
|
|
|
|
_prefetch busybox
|
|
|
|
|
mkdir ${TESTDIR}/tmp
|
|
|
|
|
openssl genrsa -out ${TESTDIR}/tmp/mykey.pem 1024
|
|
|
|
|
openssl genrsa -out ${TESTDIR}/tmp/mykey2.pem 1024
|
|
|
|
|
openssl rsa -in ${TESTDIR}/tmp/mykey.pem -pubout > ${TESTDIR}/tmp/mykey.pub
|
|
|
|
|
run_buildah push --signature-policy ${TESTSDIR}/policy.json --tls-verify=false --creds testuser:testpassword --encryption-key jwe:${TESTDIR}/tmp/mykey.pub busybox docker://localhost:5000/buildah/busybox_encrypted:latest
|
|
|
|
|
|
|
|
|
|
target=busybox-image
|
|
|
|
|
# Try to build from encrypted image without key
|
2020-04-29 02:07:41 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --tls-verify=false --creds testuser:testpassword -t ${target} -f ${TESTSDIR}/bud/from-encrypted-image/Dockerfile
|
2020-04-02 02:15:56 +08:00
|
|
|
# Try to build from encrypted image with wrong key
|
2020-04-29 02:07:41 +08:00
|
|
|
run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json --tls-verify=false --creds testuser:testpassword --decryption-key ${TESTDIR}/tmp/mykey2.pem -t ${target} -f ${TESTSDIR}/bud/from-encrypted-image/Dockerfile
|
2020-04-02 02:15:56 +08:00
|
|
|
# Try to build with the correct key
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --tls-verify=false --creds testuser:testpassword --decryption-key ${TESTDIR}/tmp/mykey.pem -t ${target} -f ${TESTSDIR}/bud/from-encrypted-image/Dockerfile
|
|
|
|
|
|
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
|
}
|
2020-05-19 20:20:14 +08:00
|
|
|
|
|
|
|
|
@test "bud with --build-arg" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
run_buildah --log-level "warn" bud --signature-policy ${TESTSDIR}/policy.json -t test ${TESTSDIR}/bud/build-arg
|
|
|
|
|
expect_output --substring 'missing .+ build argument'
|
|
|
|
|
}
|
2020-06-24 03:40:17 +08:00
|
|
|
|
|
|
|
|
@test "bud arg and env var with same name" {
|
2020-09-11 22:06:31 +08:00
|
|
|
# Regression test for https://github.com/containers/buildah/issues/2345
|
2020-06-24 03:40:17 +08:00
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t testctr ${TESTSDIR}/bud/dupe-arg-env-name
|
|
|
|
|
expect_output --substring "https://example.org/bar"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud copy chown with newuser" {
|
|
|
|
|
# Regression test for https://github.com/containers/buildah/issues/2192
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t testctr -f ${TESTSDIR}/bud/copy-chown/Containerfile.chown_user ${TESTSDIR}/bud/copy-chown
|
|
|
|
|
expect_output --substring "myuser myuser"
|
|
|
|
|
}
|
2020-08-05 05:00:47 +08:00
|
|
|
|
|
|
|
|
@test "bud-builder-identity" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
parent=alpine
|
|
|
|
|
target=no-change-image
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
run_buildah --version
|
|
|
|
|
local -a output_fields=($output)
|
|
|
|
|
buildah_version=${output_fields[2]}
|
|
|
|
|
|
|
|
|
|
run_buildah inspect --format '{{ index .Docker.Config.Labels "io.buildah.version"}}' $target
|
|
|
|
|
expect_output "$buildah_version"
|
|
|
|
|
}
|
2020-08-08 07:08:40 +08:00
|
|
|
|
|
|
|
|
@test "run check --from with arg" {
|
|
|
|
|
skip_if_no_runtime
|
|
|
|
|
|
|
|
|
|
${OCI} --version
|
2020-08-12 04:46:36 +08:00
|
|
|
_prefetch alpine
|
2020-08-08 07:08:40 +08:00
|
|
|
_prefetch debian
|
|
|
|
|
|
|
|
|
|
run_buildah bud --build-arg base=alpine --build-arg toolchainname=busybox --build-arg destinationpath=/tmp --pull=false --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/from-with-arg/Containerfile .
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
expect_output --substring 'STEP 4: COPY --from=\$\{toolchainname\} \/ \$\{destinationpath\}'
|
|
|
|
|
run_buildah rm -a
|
|
|
|
|
}
|
2020-08-11 17:28:41 +08:00
|
|
|
|
2020-08-27 04:56:57 +08:00
|
|
|
@test "bud timestamp" {
|
2020-08-11 17:28:41 +08:00
|
|
|
_prefetch alpine
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --timestamp=0 --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json -t timestamp -f Dockerfile.1 ${TESTSDIR}/bud/cache-stages
|
2020-08-11 17:28:41 +08:00
|
|
|
cid=$output
|
2020-08-27 04:56:57 +08:00
|
|
|
run_buildah inspect --format '{{ .Docker.Created }}' timestamp
|
2020-08-11 17:28:41 +08:00
|
|
|
expect_output --substring "1970-01-01"
|
2020-08-27 04:56:57 +08:00
|
|
|
run_buildah inspect --format '{{ .OCIv1.Created }}' timestamp
|
2020-08-11 17:28:41 +08:00
|
|
|
expect_output --substring "1970-01-01"
|
2020-09-09 03:15:16 +08:00
|
|
|
run_buildah inspect --format '{{ .History }}' timestamp
|
|
|
|
|
expect_output --substring '1970-01-01 00:00:00'
|
2020-08-11 17:28:41 +08:00
|
|
|
|
2020-08-27 04:56:57 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json timestamp
|
2020-08-11 17:28:41 +08:00
|
|
|
cid=$output
|
|
|
|
|
run_buildah run $cid ls -l /tmpfile
|
|
|
|
|
expect_output --substring "1970"
|
|
|
|
|
|
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
|
}
|
2020-08-25 21:53:59 +08:00
|
|
|
|
2020-08-27 04:56:57 +08:00
|
|
|
@test "bud timestamp compare" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
TIMESTAMP=$(date '+%s')
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --timestamp=${TIMESTAMP} --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json -t timestamp -f Dockerfile.1 ${TESTSDIR}/bud/cache-stages
|
2020-08-27 04:56:57 +08:00
|
|
|
cid=$output
|
|
|
|
|
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --timestamp=${TIMESTAMP} --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json -t timestamp -f Dockerfile.1 ${TESTSDIR}/bud/cache-stages
|
2020-08-27 04:56:57 +08:00
|
|
|
expect_output "$cid"
|
|
|
|
|
|
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-25 21:53:59 +08:00
|
|
|
@test "bud with-rusage" {
|
|
|
|
|
_prefetch alpine
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --log-rusage --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/shell
|
2020-08-25 21:53:59 +08:00
|
|
|
cid=$output
|
|
|
|
|
# expect something that looks like it was formatted using pkg/rusage.FormatDiff()
|
|
|
|
|
expect_output --substring ".*\(system\).*\(user\).*\(elapsed\).*input.*output"
|
|
|
|
|
}
|
2020-09-02 02:41:22 +08:00
|
|
|
|
|
|
|
|
@test "bud-caching-from-scratch" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
# run the build once
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
iid="$output"
|
|
|
|
|
# now run it again - the cache should give us the same final image ID
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
iid2="$output"
|
|
|
|
|
expect_output --substring "$iid"
|
|
|
|
|
# now run it *again*, except with more content added at an intermediate step, which should invalidate the cache
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.different1 ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
test "$output" != "$iid"
|
|
|
|
|
# now run it *again* again, except with more content added at an intermediate step, which should invalidate the cache
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.different2 ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
test "$output" != "$iid"
|
|
|
|
|
test "$output" != "$iid2"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-caching-from-scratch-config" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
# run the build once
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.config ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
iid="$output"
|
|
|
|
|
# now run it again - the cache should give us the same final image ID
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.config ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
iid2="$output"
|
|
|
|
|
expect_output --substring "$iid"
|
|
|
|
|
# now run it *again*, except with more content added at an intermediate step, which should invalidate the cache
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.different1 ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
test "$output" != "$iid"
|
|
|
|
|
# now run it *again* again, except with more content added at an intermediate step, which should invalidate the cache
|
2020-09-09 00:53:47 +08:00
|
|
|
run_buildah bud --quiet --layers --pull=false --format docker --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.different2 ${TESTSDIR}/bud/cache-scratch
|
2020-09-02 02:41:22 +08:00
|
|
|
test "$output" != "$iid"
|
|
|
|
|
test "$output" != "$iid2"
|
|
|
|
|
}
|
2020-08-24 16:48:58 +08:00
|
|
|
|
|
|
|
|
@test "bud capabilities test" {
|
|
|
|
|
_prefetch busybox
|
|
|
|
|
run_buildah bud -t testcap --signature-policy ${TESTSDIR}/policy.json -f ${TESTSDIR}/bud/capabilities/Dockerfile
|
|
|
|
|
expect_output --substring "uid=3267"
|
|
|
|
|
expect_output --substring "CapBnd: 00000000a80425fb"
|
|
|
|
|
expect_output --substring "CapEff: 0000000000000000"
|
|
|
|
|
}
|
2020-10-21 02:22:19 +08:00
|
|
|
|
|
|
|
|
@test "bud does not gobble stdin" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
|
|
|
|
|
ctxdir=${TESTDIR}/bud
|
|
|
|
|
mkdir -p $ctxdir
|
|
|
|
|
cat >$ctxdir/Dockerfile <<EOF
|
|
|
|
|
FROM alpine
|
|
|
|
|
RUN true
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
random_msg=$(head -10 /dev/urandom | tr -dc a-zA-Z0-9 | head -c12)
|
|
|
|
|
|
|
|
|
|
# Prior to #2708, buildah bud would gobble up its stdin even if it
|
|
|
|
|
# didn't actually use it. This prevented the use of 'cmdlist | bash';
|
|
|
|
|
# if 'buildah bud' was in cmdlist, everything past it would be lost.
|
|
|
|
|
#
|
|
|
|
|
# This is ugly but effective: it checks that buildah passes stdin untouched.
|
|
|
|
|
passthru=$(echo "$random_msg" | (run_buildah bud --quiet --signature-policy ${TESTSDIR}/policy.json -t stdin-test ${ctxdir} >/dev/null; cat))
|
|
|
|
|
|
|
|
|
|
expect_output --from="$passthru" "$random_msg" "stdin was passed through"
|
|
|
|
|
}
|
2020-10-31 01:47:23 +08:00
|
|
|
|
|
|
|
|
@test "bud cache by format" {
|
|
|
|
|
# Build first in Docker format. Whether we do OCI or Docker first shouldn't matter, so we picked one.
|
|
|
|
|
run_buildah bud --iidfile first-docker --format docker --layers --quiet --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/cache-format
|
|
|
|
|
# Build in OCI format. Cache should not re-use the same images, so we should get a different image ID.
|
|
|
|
|
run_buildah bud --iidfile first-oci --format oci --layers --quiet --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/cache-format
|
|
|
|
|
# Build in Docker format again. Cache traversal should 100% hit the Docker image, so we should get its image ID.
|
|
|
|
|
run_buildah bud --iidfile second-docker --format docker --layers --quiet --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/cache-format
|
|
|
|
|
# Build in OCI format again. Cache traversal should 100% hit the OCI image, so we should get its image ID.
|
|
|
|
|
run_buildah bud --iidfile second-oci --format oci --layers --quiet --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/cache-format
|
|
|
|
|
# Compare them. The two images we built in Docker format should be the same, the two we built in OCI format
|
|
|
|
|
# should be the same, but the OCI and Docker format images should be different.
|
|
|
|
|
cmp first-docker second-docker
|
|
|
|
|
cmp first-oci second-oci
|
|
|
|
|
run cmp first-docker first-oci
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
}
|
2020-11-05 06:23:25 +08:00
|
|
|
|
|
|
|
|
@test "bud cache add-copy-chown" {
|
|
|
|
|
# Build each variation of COPY (from context, from previous stage) and ADD (from context, not overriding an archive, URL) twice.
|
|
|
|
|
# Each second build should produce an image with the same ID as the first build, because the cache matches, but they should
|
|
|
|
|
# otherwise all be different.
|
|
|
|
|
run_buildah bud --iidfile copy1 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.copy1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile prev1 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.prev1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile add1 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.add1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile tar1 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.tar1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile url1 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.url1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile copy2 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.copy2 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile prev2 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.prev2 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile add2 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.add2 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile tar2 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.tar2 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile url2 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.url2 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile copy3 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.copy1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile prev3 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.prev1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile add3 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.add1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile tar3 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.tar1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
run_buildah bud --iidfile url3 --layers --quiet --signature-policy ${TESTSDIR}/policy.json -f Dockerfile.url1 ${TESTSDIR}/bud/cache-chown
|
|
|
|
|
|
|
|
|
|
# The third round of builds should match all of the first rounds by way of caching.
|
|
|
|
|
cmp copy1 copy3
|
|
|
|
|
cmp prev1 prev3
|
|
|
|
|
cmp add1 add3
|
|
|
|
|
cmp tar1 tar3
|
|
|
|
|
cmp url1 url3
|
|
|
|
|
|
|
|
|
|
# The second round of builds should not match the first rounds, since the different ownership
|
|
|
|
|
# makes the changes look different to the cache, except for cases where we extract an archive,
|
|
|
|
|
# where --chown is ignored.
|
|
|
|
|
run cmp copy1 copy2
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp prev1 prev2
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp add1 add2
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
cmp tar1 tar2
|
|
|
|
|
run cmp url1 url2
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
|
|
|
|
|
# The first rounds of builds should all be different from each other, as a sanith thing.
|
|
|
|
|
run cmp copy1 prev1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp copy1 add1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp copy1 tar1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp copy1 url1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
|
|
|
|
|
run cmp prev1 add1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp prev1 tar1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp prev1 url1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
|
|
|
|
|
run cmp add1 tar1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
run cmp add1 url1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
|
|
|
|
|
run cmp tar1 url1
|
|
|
|
|
[[ "$status" -ne 0 ]]
|
|
|
|
|
}
|
2020-11-18 00:16:48 +08:00
|
|
|
|
|
|
|
|
@test "bud-terminal" {
|
|
|
|
|
run_buildah bud ${TESTSDIR}/bud/terminal
|
|
|
|
|
}
|
2020-11-19 21:14:58 +08:00
|
|
|
|
|
|
|
|
@test "bud --ignore containerignore" {
|
|
|
|
|
_prefetch alpine busybox
|
|
|
|
|
|
|
|
|
|
CONTEXTDIR=${TESTDIR}/dockerignore
|
|
|
|
|
cp -r ${TESTSDIR}/bud/dockerignore ${CONTEXTDIR}
|
|
|
|
|
mv ${CONTEXTDIR}/.dockerignore ${TESTDIR}/containerignore
|
|
|
|
|
|
|
|
|
|
run_buildah bud -t testbud --signature-policy ${TESTSDIR}/policy.json -f ${CONTEXTDIR}/Dockerfile.succeed --ignorefile ${TESTDIR}/containerignore ${CONTEXTDIR}
|
|
|
|
|
|
|
|
|
|
run_buildah from --name myctr testbud
|
|
|
|
|
|
|
|
|
|
run_buildah 1 run myctr ls -l test1.txt
|
|
|
|
|
|
|
|
|
|
run_buildah run myctr ls -l test2.txt
|
|
|
|
|
|
|
|
|
|
run_buildah 1 run myctr ls -l sub1.txt
|
|
|
|
|
|
|
|
|
|
run_buildah 1 run myctr ls -l sub2.txt
|
|
|
|
|
|
|
|
|
|
run_buildah run myctr ls -l subdir/sub1.txt
|
|
|
|
|
|
|
|
|
|
run_buildah 1 run myctr ls -l subdir/sub2.txt
|
|
|
|
|
}
|
2020-12-02 23:03:07 +08:00
|
|
|
|
|
|
|
|
@test "bud with network options" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
target=alpine-image
|
|
|
|
|
|
|
|
|
|
run_buildah bud --network=none --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
|
|
|
|
|
run_buildah bud --network=private --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
|
|
|
|
|
run_buildah bud --network=container --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
expect_output --substring "FROM alpine"
|
|
|
|
|
|
|
|
|
|
run_buildah 125 bud --network=bogus --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
|
2020-11-25 09:04:52 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-replace-from-in-containerfile" {
|
|
|
|
|
_prefetch alpine
|
|
|
|
|
# override the first FROM (fedora) image in the Containerfile
|
|
|
|
|
# with alpine, leave the second (busybox) alone.
|
|
|
|
|
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --from=alpine ${TESTSDIR}/bud/build-with-from
|
|
|
|
|
expect_output --substring "STEP 1: FROM alpine AS builder"
|
|
|
|
|
expect_output --substring "STEP 2: FROM busybox"
|
2020-12-02 23:03:07 +08:00
|
|
|
}
|