2017-03-30 03:50:32 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
2018-09-03 19:20:52 +08:00
|
|
|
@test "bud-flags-order-verification" {
|
|
|
|
|
run buildah bud /tmp/tmpdockerfile/ -t blabla
|
|
|
|
|
check_options_flag_err "-t"
|
|
|
|
|
|
|
|
|
|
run buildah bud /tmp/tmpdockerfile/ -q -t blabla
|
|
|
|
|
check_options_flag_err "-q"
|
|
|
|
|
|
|
|
|
|
run buildah bud /tmp/tmpdockerfile/ --force-rm
|
|
|
|
|
check_options_flag_err "--force-rm"
|
|
|
|
|
|
|
|
|
|
run buildah bud /tmp/tmpdockerfile/ --userns=cnt1
|
|
|
|
|
check_options_flag_err "--userns=cnt1"
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 00:55:46 +08:00
|
|
|
@test "bud with --layers and --no-cache flags" {
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 ${TESTSDIR}/bud/use-layers
|
2018-06-14 03:04:31 +08:00
|
|
|
run buildah --debug=false images -a
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 8 ]
|
2018-06-14 03:04:31 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
2018-06-09 00:55:46 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 ${TESTSDIR}/bud/use-layers
|
2018-06-14 03:04:31 +08:00
|
|
|
run buildah --debug=false images -a
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 10 ]
|
2018-06-14 03:04:31 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
2018-06-29 01:59:42 +08:00
|
|
|
run buildah inspect --format "{{.Docker.ContainerConfig.Env}}" test2
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ $output =~ "foo=bar" ]]
|
2018-09-27 02:34:34 +08:00
|
|
|
run buildah inspect --format "{{.Docker.ContainerConfig.ExposedPorts}}" test2
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ $output =~ "8080" ]]
|
2018-06-09 00:55:46 +08:00
|
|
|
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.2 ${TESTSDIR}/bud/use-layers
|
2018-06-14 03:04:31 +08:00
|
|
|
run buildah --debug=false images -a
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 12 ]
|
2018-06-14 03:04:31 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
2018-06-09 00:55:46 +08:00
|
|
|
|
|
|
|
|
mkdir -p ${TESTSDIR}/bud/use-layers/mount/subdir
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test4 -f Dockerfile.3 ${TESTSDIR}/bud/use-layers
|
2018-06-14 03:04:31 +08:00
|
|
|
run buildah --debug=false images -a
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 14 ]
|
2018-06-14 03:04:31 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
2018-06-09 00:55:46 +08:00
|
|
|
touch ${TESTSDIR}/bud/use-layers/mount/subdir/file.txt
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test5 -f Dockerfile.3 ${TESTSDIR}/bud/use-layers
|
2018-06-14 03:04:31 +08:00
|
|
|
run buildah --debug=false images -a
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 16 ]
|
2018-06-14 03:04:31 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
2018-06-09 00:55:46 +08:00
|
|
|
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --no-cache -t test6 -f Dockerfile.2 ${TESTSDIR}/bud/use-layers
|
2018-06-14 03:04:31 +08:00
|
|
|
run buildah --debug=false images -a
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 19 ]
|
2018-06-14 03:04:31 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
2018-06-09 00:55:46 +08:00
|
|
|
|
2018-06-29 01:59:42 +08:00
|
|
|
buildah rmi -a -f
|
2018-06-09 00:55:46 +08:00
|
|
|
rm -rf ${TESTSDIR}/bud/use-layers/mount
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-19 04:10:26 +08:00
|
|
|
@test "bud with --layers, multistage, and COPY with --from" {
|
|
|
|
|
mkdir -p ${TESTSDIR}/bud/use-layers/uuid
|
|
|
|
|
uuidgen > ${TESTSDIR}/bud/use-layers/uuid/data
|
|
|
|
|
mkdir -p ${TESTSDIR}/bud/use-layers/date
|
|
|
|
|
date > ${TESTSDIR}/bud/use-layers/date/data
|
|
|
|
|
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.multistage-copy ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 6 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.multistage-copy ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 7 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
uuidgen > ${TESTSDIR}/bud/use-layers/uuid/data
|
|
|
|
|
date > ${TESTSDIR}/bud/use-layers/date/data
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.multistage-copy ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 11 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
run buildah --debug=false containers
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 1 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
ctr=$(buildah --debug=false from --signature-policy ${TESTSDIR}/policy.json test3)
|
|
|
|
|
mnt=$(buildah --debug=false mount ${ctr})
|
|
|
|
|
run test -e $mnt/uuid
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
run test -e $mnt/date
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t test4 -f Dockerfile.multistage-copy ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 12 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
buildah rmi -a -f
|
|
|
|
|
rm -rf ${TESTSDIR}/bud/use-layers/uuid
|
|
|
|
|
rm -rf ${TESTSDIR}/bud/use-layers/date
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-09 02:17:31 +08:00
|
|
|
@test "bud with --layers and symlink file" {
|
|
|
|
|
echo 'echo "Hello World!"' > ${TESTSDIR}/bud/use-layers/hello.sh
|
|
|
|
|
cd ${TESTSDIR}/bud/use-layers && ln -s hello.sh hello_world.sh
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test -f Dockerfile.4 ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 4 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 -f Dockerfile.4 ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 5 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
echo 'echo "Hello Cache!"' > ${TESTSDIR}/bud/use-layers/hello.sh
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.4 ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 7 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
rm ${TESTSDIR}/bud/use-layers/hello.sh ${TESTSDIR}/bud/use-layers/hello_world.sh
|
|
|
|
|
buildah rmi -a -f
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 02:09:45 +08:00
|
|
|
@test "bud with --rm flag" {
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false containers
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 1 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json --rm=false --layers -t test2 ${TESTSDIR}/bud/use-layers
|
|
|
|
|
run buildah --debug=false containers
|
2018-09-27 02:34:34 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 7 ]
|
2018-06-14 02:09:45 +08:00
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
buildah rm -a
|
2018-06-29 01:59:42 +08:00
|
|
|
buildah rmi -a -f
|
2018-06-14 02:09:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --force-rm flag" {
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json --force-rm --layers -t test1 -f Dockerfile.fail-case ${TESTSDIR}/bud/use-layers
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
run buildah --debug=false containers
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 1 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.fail-case ${TESTSDIR}/bud/use-layers
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
run buildah --debug=false containers
|
|
|
|
|
[ $(wc -l <<< "$output") -eq 2 ]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
buildah rm -a
|
2018-06-29 01:59:42 +08:00
|
|
|
buildah rmi -a -f
|
2018-06-14 02:09:45 +08:00
|
|
|
}
|
|
|
|
|
|
2018-08-22 23:50:29 +08:00
|
|
|
@test "bud --layers with non-existent/down registry" {
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json --force-rm --layers -t test1 -f Dockerfile.non-existent-registry ${TESTSDIR}/bud/use-layers
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -ne 0 ]
|
2018-09-15 00:37:49 +08:00
|
|
|
[[ "$output" =~ "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" {
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t test -f Dockerfile.check-env ${TESTSDIR}/bud/env
|
2018-05-24 23:54:31 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json test)
|
|
|
|
|
buildah config --env random=hello ${cid}
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json ${cid} test1
|
|
|
|
|
buildah --debug inspect test1 | grep foo=bar
|
|
|
|
|
buildah --debug inspect test1 | grep random=hello
|
|
|
|
|
buildah rm ${cid}
|
2018-08-10 15:34:24 +08:00
|
|
|
buildah rmi -a -f
|
2018-05-24 23:54:31 +08:00
|
|
|
}
|
|
|
|
|
|
2017-03-30 03:50:32 +08:00
|
|
|
@test "bud-from-scratch" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2018-04-25 22:00:46 +08:00
|
|
|
|
|
|
|
|
@test "bud-from-scratch-iid" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
buildah bud --iidfile output.iid --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
iid=$(cat output.iid)
|
|
|
|
|
cid=$(buildah from ${iid})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-04-25 22:00:46 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2017-03-30 03:50:32 +08:00
|
|
|
|
2018-05-17 02:13:12 +08:00
|
|
|
@test "bud-from-scratch-label" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
buildah bud --label "test=label" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
run buildah --debug=false inspect --format '{{printf "%q" .Docker.Config.Labels}}' ${target}
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-17 02:13:12 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = 'map["test":"label"]' ]
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 00:05:18 +08:00
|
|
|
@test "bud-from-scratch-annotation" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
buildah bud --annotation "test=annotation" --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
run buildah --debug=false inspect --format '{{printf "%q" .ImageAnnotations}}' ${target}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = 'map["test":"annotation"]' ]
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-30 03:50:32 +08:00
|
|
|
@test "bud-from-multiple-files-one-from" {
|
|
|
|
|
target=scratch-image
|
2018-05-25 17:44:17 +08:00
|
|
|
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
|
2017-03-30 03:50:32 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile1 ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch
|
|
|
|
|
cmp $root/Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.nofrom
|
|
|
|
|
run test -s $root/etc/passwd
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.alpine -f Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files
|
2017-03-30 03:50:32 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile1 ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.alpine
|
|
|
|
|
cmp $root/Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.nofrom
|
|
|
|
|
run test -s $root/etc/passwd
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2017-03-30 03:50:32 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-from-multiple-files-two-froms" {
|
|
|
|
|
target=scratch-image
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.scratch -f Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files
|
2017-03-30 03:50:32 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
2018-02-25 06:40:44 +08:00
|
|
|
run test -s $root/Dockerfile1
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-25 06:40:44 +08:00
|
|
|
[ "$status" -ne 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
cmp $root/Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.withfrom
|
|
|
|
|
run test -s $root/etc/passwd
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-25 06:40:44 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2017-03-30 03:50:32 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.alpine -f Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files
|
2017-03-30 03:50:32 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
2018-02-25 06:40:44 +08:00
|
|
|
run test -s $root/Dockerfile1
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-25 06:40:44 +08:00
|
|
|
[ "$status" -ne 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
cmp $root/Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.withfrom
|
|
|
|
|
run test -s $root/etc/passwd
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2017-03-30 03:50:32 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-25 06:40:44 +08:00
|
|
|
@test "bud-multi-stage-builds" {
|
|
|
|
|
target=multi-stage-index
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds
|
2018-02-25 06:40:44 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.index
|
|
|
|
|
run test -s $root/etc/passwd
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2018-02-25 06:40:44 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
2018-02-25 06:40:44 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
|
|
|
|
|
target=multi-stage-name
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds
|
2018-02-25 06:40:44 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.name
|
|
|
|
|
run test -s $root/etc/passwd
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-25 06:40:44 +08:00
|
|
|
[ "$output" = "" ]
|
2018-05-19 02:16:12 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2018-02-25 06:40:44 +08:00
|
|
|
|
|
|
|
|
target=multi-stage-mixed
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.mixed ${TESTSDIR}/bud/multi-stage-builds
|
2018-02-25 06:40:44 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
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
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-25 06:40:44 +08:00
|
|
|
[ "$output" = "" ]
|
2018-05-19 02:16:12 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2018-02-25 06:40:44 +08:00
|
|
|
}
|
|
|
|
|
|
2018-11-17 06:43:48 +08:00
|
|
|
@test "bud-multi-stage-builds-small-as" {
|
|
|
|
|
target=multi-stage-index
|
|
|
|
|
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
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.index
|
|
|
|
|
run test -s $root/etc/passwd
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi -a
|
|
|
|
|
run buildah --debug=false images -q
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
|
|
|
|
|
target=multi-stage-name
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds-small-as
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile.name ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.name
|
|
|
|
|
run test -s $root/etc/passwd
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
target=multi-stage-mixed
|
|
|
|
|
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
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
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
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
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.
|
|
|
|
|
if ! which runc ; then
|
|
|
|
|
skip
|
|
|
|
|
fi
|
|
|
|
|
target=volume-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/preserve-volumes
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
test -s $root/vol/subvol/subsubvol/subsubvolfile
|
|
|
|
|
run test -s $root/vol/subvol/subvolfile
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
test -s $root/vol/volfile
|
2017-06-21 05:37:50 +08:00
|
|
|
test -s $root/vol/Dockerfile
|
|
|
|
|
test -s $root/vol/Dockerfile2
|
2017-03-30 03:50:32 +08:00
|
|
|
run test -s $root/vol/anothervolfile
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2017-03-30 03:50:32 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-http-Dockerfile" {
|
|
|
|
|
starthttpd ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
target=scratch-image
|
2018-05-25 17:44:17 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} http://0.0.0.0:${HTTP_SERVER_PORT}/Dockerfile
|
2017-03-30 03:50:32 +08:00
|
|
|
stophttpd
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-http-context-with-Dockerfile" {
|
|
|
|
|
starthttpd ${TESTSDIR}/bud/http-context
|
|
|
|
|
target=scratch-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar
|
|
|
|
|
stophttpd
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-http-context-dir-with-Dockerfile-pre" {
|
|
|
|
|
starthttpd ${TESTSDIR}/bud/http-context-subdir
|
|
|
|
|
target=scratch-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f context/Dockerfile http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar
|
|
|
|
|
stophttpd
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-http-context-dir-with-Dockerfile-post" {
|
|
|
|
|
starthttpd ${TESTSDIR}/bud/http-context-subdir
|
|
|
|
|
target=scratch-image
|
2018-02-23 23:54:23 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f context/Dockerfile http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar
|
2017-03-30 03:50:32 +08:00
|
|
|
stophttpd
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud-git-context" {
|
|
|
|
|
# We need git and ssh to be around to handle cloning a repository.
|
|
|
|
|
if ! which git ; then
|
|
|
|
|
skip
|
|
|
|
|
fi
|
|
|
|
|
if ! which ssh ; then
|
|
|
|
|
skip
|
|
|
|
|
fi
|
|
|
|
|
target=giturl-image
|
|
|
|
|
# Any repo should do, but this one is small and is FROM: scratch.
|
|
|
|
|
gitrepo=git://github.com/projectatomic/nulecule-library
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} "${gitrepo}"
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} "${gitrepo}"
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah --debug=false images -q
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-30 03:50:32 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2017-04-11 02:25:07 +08:00
|
|
|
|
|
|
|
|
@test "bud-additional-tags" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
target2=another-scratch-image
|
|
|
|
|
target3=so-many-scratch-images
|
2018-05-02 03:37:13 +08:00
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -t docker.io/${target2} -t ${target3} ${TESTSDIR}/bud/from-scratch
|
2017-04-11 02:25:07 +08:00
|
|
|
run buildah --debug=false images
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-04-11 02:25:07 +08:00
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json library/${target2})
|
2017-04-11 02:25:07 +08:00
|
|
|
buildah rm ${cid}
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target3}:latest)
|
2017-04-11 02:25:07 +08:00
|
|
|
buildah rm ${cid}
|
2017-06-21 22:54:43 +08:00
|
|
|
buildah rmi -f $(buildah --debug=false images -q)
|
2017-04-11 02:25:07 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-04-11 02:25:07 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
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.
|
|
|
|
|
if ! which runc ; then
|
|
|
|
|
skip
|
|
|
|
|
fi
|
|
|
|
|
target=volume-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/volume-perms
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2017-06-21 05:37:50 +08:00
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run test -s $root/vol/subvol/subvolfile
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
run stat -c %f $root/vol/subvol
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-06-21 05:37:50 +08:00
|
|
|
[ "$output" = 41ed ]
|
|
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2017-06-21 05:37:50 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-06-21 05:37:50 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2017-07-17 22:42:58 +08:00
|
|
|
|
|
|
|
|
@test "bud-from-glob" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile2.glob ${TESTSDIR}/bud/from-multiple-files
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2017-07-17 22:42:58 +08:00
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
cmp $root/Dockerfile1.alpine ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.alpine
|
|
|
|
|
cmp $root/Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.withfrom
|
|
|
|
|
buildah rm ${cid}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2017-07-17 22:42:58 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-07-17 22:42:58 +08:00
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2018-02-06 05:26:21 +08:00
|
|
|
|
|
|
|
|
@test "bud-maintainer" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/maintainer
|
|
|
|
|
run buildah --debug=false inspect --type=image --format '{{.Docker.Author}}' ${target}
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-06 05:26:21 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = kilroy ]
|
|
|
|
|
run buildah --debug=false inspect --type=image --format '{{.OCIv1.Author}}' ${target}
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-06 05:26:21 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = kilroy ]
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2018-02-06 05:26:21 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-06 05:26:21 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2018-02-07 01:02:21 +08:00
|
|
|
|
|
|
|
|
@test "bud-unrecognized-instruction" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/unrecognized
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-07 01:02:21 +08:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
[[ "$output" =~ BOGUS ]]
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-02-07 01:02:21 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2018-03-16 19:57:36 +08:00
|
|
|
|
|
|
|
|
@test "bud-shell" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/shell
|
|
|
|
|
run buildah --debug=false inspect --type=image --format '{{printf "%q" .Docker.Config.Shell}}' ${target}
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-16 19:57:36 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = '["/bin/sh" "-c"]' ]
|
2018-07-25 02:08:04 +08:00
|
|
|
ctr=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-03-16 19:57:36 +08:00
|
|
|
run buildah --debug=false config --shell "/bin/bash -c" ${ctr}
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-16 19:57:36 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run buildah --debug=false inspect --type=container --format '{{printf "%q" .Docker.Config.Shell}}' ${ctr}
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-16 19:57:36 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = '["/bin/bash" "-c"]' ]
|
|
|
|
|
buildah rm ${ctr}
|
2018-07-20 02:25:47 +08:00
|
|
|
buildah rmi -a
|
2018-03-16 19:57:36 +08:00
|
|
|
run buildah --debug=false images -q
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-16 19:57:36 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2018-03-28 02:06:00 +08:00
|
|
|
|
|
|
|
|
@test "bud with symlinks" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/symlink
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-03-28 02:06:00 +08:00
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run ls $root/data/log
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ test ]]
|
|
|
|
|
[[ "$output" =~ blah.txt ]]
|
|
|
|
|
run ls -al $root
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ "test-log -> /data/log" ]]
|
|
|
|
|
[[ "$output" =~ "blah -> /test-log" ]]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with symlinks to relative path" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.relative-symlink ${TESTSDIR}/bud/symlink
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-03-28 02:06:00 +08:00
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run ls $root/log
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ test ]]
|
|
|
|
|
run ls -al $root
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ "test-log -> ../log" ]]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with multiple symlinks in a path" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink/Dockerfile.multiple-symlinks ${TESTSDIR}/bud/symlink
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-03-28 02:06:00 +08:00
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run ls $root/data/log
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ bin ]]
|
|
|
|
|
[[ "$output" =~ blah.txt ]]
|
|
|
|
|
run ls -al $root/myuser
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ "log -> /test" ]]
|
|
|
|
|
run ls -al $root/test
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ "bar -> /test-log" ]]
|
|
|
|
|
run ls -al $root/test-log
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ "foo -> /data/log" ]]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with multiple symlink pointing to itself" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink/Dockerfile.symlink-points-to-itself ${TESTSDIR}/bud/symlink
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-03-28 02:06:00 +08:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
}
|
2018-05-05 21:36:22 +08:00
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT and RUN" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.entrypoint-run ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-05 21:36:22 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2018-05-19 02:16:12 +08:00
|
|
|
[[ "$output" =~ "unique.test.string" ]]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-05-05 21:36:22 +08:00
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT and empty RUN" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.entrypoint-empty-run ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-05 21:36:22 +08:00
|
|
|
[[ "$output" =~ "error building at step" ]]
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with CMD and RUN" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/run-scenarios/Dockerfile.cmd-run ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-05 21:36:22 +08:00
|
|
|
[[ "$output" =~ "unique.test.string" ]]
|
|
|
|
|
[ "$status" -eq 0 ]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-05-05 21:36:22 +08:00
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with CMD and empty RUN" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.cmd-empty-run ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-05 21:36:22 +08:00
|
|
|
[[ "$output" =~ "error building at step" ]]
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
2018-05-05 22:37:54 +08:00
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT, CMD and RUN" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +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
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-05 22:37:54 +08:00
|
|
|
[[ "$output" =~ "unique.test.string" ]]
|
|
|
|
|
[ "$status" -eq 0 ]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-05-05 22:37:54 +08:00
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ENTRYPOINT, CMD and empty RUN" {
|
|
|
|
|
target=alpine-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/run-scenarios/Dockerfile.entrypoint-cmd-empty-run ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-05 22:37:54 +08:00
|
|
|
[[ "$output" =~ "error building at step" ]]
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
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" {
|
2018-05-15 20:34:14 +08:00
|
|
|
target=env-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/env/Dockerfile.env-same-file ${TESTSDIR}/bud/env
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-15 20:34:14 +08:00
|
|
|
[[ "$output" =~ ":unique.test.string:" ]]
|
|
|
|
|
[ "$status" -eq 0 ]
|
2018-07-25 02:08:04 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${target})
|
2018-05-15 20:34:14 +08:00
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 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" {
|
2018-05-15 20:34:14 +08:00
|
|
|
from_target=env-from-image
|
|
|
|
|
target=env-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${from_target} -f ${TESTSDIR}/bud/env/Dockerfile.env-same-file ${TESTSDIR}/bud/env
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/env/Dockerfile.env-from-image ${TESTSDIR}/bud/env
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-15 20:34:14 +08:00
|
|
|
[[ "$output" =~ "@unique.test.string@" ]]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
from_cid=$(buildah from ${from_target})
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${from_cid} ${cid}
|
2018-08-10 15:34:24 +08:00
|
|
|
buildah rmi -a -f
|
2018-05-15 20:34:14 +08:00
|
|
|
}
|
|
|
|
|
|
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
|
2018-05-18 21:49:49 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${url}
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
2018-05-18 21:49:49 +08:00
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${url}
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.noop-flags ${TESTSDIR}/bud/run-scenarios
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-08 06:14:44 +08:00
|
|
|
# Following flags are configured to result in noop but should not affect buildiah bud behavior
|
|
|
|
|
@test "bud with --cache-from noop flag" {
|
|
|
|
|
target=noop-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --cache-from=invalidimage --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.noop-flags ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-08 06:14:44 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --compress noop flag" {
|
|
|
|
|
target=noop-image
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --compress --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.noop-flags ${TESTSDIR}/bud/run-scenarios
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-08 06:14:44 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-09 21:51:58 +08:00
|
|
|
@test "bud with --cpu-shares flag, no argument" {
|
|
|
|
|
target=bud-flag
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --cpu-shares --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-09 21:51:58 +08:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares flag, invalid argument" {
|
|
|
|
|
target=bud-flag
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud --cpu-shares bogus --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-09 21:51:58 +08:00
|
|
|
[ "$status" -ne 0 ]
|
2019-01-22 23:35:52 +08:00
|
|
|
[[ "$output" =~ "invalid argument \"bogus\" for " ]]
|
2018-05-09 21:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares flag, valid argument" {
|
|
|
|
|
target=bud-flag
|
2018-05-25 17:44:17 +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
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-09 21:51:58 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares short flag (-c), no argument" {
|
|
|
|
|
target=bud-flag
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud -c --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-09 21:51:58 +08:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with --cpu-shares short flag (-c), invalid argument" {
|
|
|
|
|
target=bud-flag
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud -c bogus --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-scratch/Dockerfile ${TESTSDIR}/bud/from-scratch
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-09 21:51:58 +08:00
|
|
|
[ "$status" -ne 0 ]
|
2019-01-22 23:35:52 +08:00
|
|
|
[[ "$output" =~ "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
|
2018-05-25 17:44:17 +08:00
|
|
|
run buildah bud -c 2 --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
2018-05-19 02:16:12 +08:00
|
|
|
echo "$output"
|
2018-05-09 21:51:58 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi ${target}
|
|
|
|
|
}
|
2018-05-25 15:53:30 +08:00
|
|
|
|
|
|
|
|
@test "bud-onbuild" {
|
|
|
|
|
target=onbuild
|
|
|
|
|
buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/onbuild
|
|
|
|
|
run buildah --debug=false inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = '["RUN touch /onbuild1" "RUN touch /onbuild2"]' ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run ls ${root}/onbuild1 ${root}/onbuild2
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah umount ${cid}
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
|
|
|
|
|
target=onbuild-image2
|
|
|
|
|
buildah bud --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1 ${TESTSDIR}/bud/onbuild
|
|
|
|
|
run buildah --debug=false inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = '["RUN touch /onbuild3"]' ]
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run ls ${root}/onbuild1 ${root}/onbuild2 ${root}/onbuild3
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah umount ${cid}
|
|
|
|
|
|
|
|
|
|
run buildah --debug=false config --onbuild "RUN touch /onbuild4" ${cid}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
target=onbuild-image3
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json --format docker ${cid} ${target}
|
|
|
|
|
run buildah --debug=false inspect --format '{{printf "%q" .Docker.Config.OnBuild}}' ${target}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = '["RUN touch /onbuild4"]' ]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi --all
|
|
|
|
|
}
|
2018-06-06 01:53:39 +08:00
|
|
|
|
|
|
|
|
@test "bud-logfile" {
|
|
|
|
|
rm -f ${TESTDIR}/logfile
|
|
|
|
|
run buildah bud --logfile ${TESTDIR}/logfile --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/preserve-volumes
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
test -s ${TESTDIR}/logfile
|
|
|
|
|
}
|
2018-06-25 20:53:47 +08:00
|
|
|
|
|
|
|
|
@test "bud with ARGS" {
|
|
|
|
|
target=alpine-image
|
2018-08-13 22:18:04 +08:00
|
|
|
run buildah --debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.args ${TESTSDIR}/bud/run-scenarios
|
2018-06-25 20:53:47 +08:00
|
|
|
echo "$output"
|
|
|
|
|
[[ "$output" =~ "arg_value" ]]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
2018-07-27 22:48:16 +08:00
|
|
|
|
|
|
|
|
@test "bud-from-stdin" {
|
|
|
|
|
target=scratch-image
|
|
|
|
|
cat ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch | buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f - ${TESTSDIR}/bud/from-multiple-files
|
|
|
|
|
cid=$(buildah from ${target})
|
|
|
|
|
root=$(buildah mount ${cid})
|
|
|
|
|
run test -s $root/Dockerfile1
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
buildah rm ${cid}
|
|
|
|
|
buildah rmi $(buildah --debug=false images -q)
|
|
|
|
|
run buildah --debug=false images -q
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" = "" ]
|
|
|
|
|
}
|
2018-08-01 18:31:02 +08:00
|
|
|
|
|
|
|
|
@test "bud with preprocessor" {
|
|
|
|
|
target=alpine-image
|
2018-08-13 22:18:04 +08:00
|
|
|
run buildah --debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Decomposed.in ${TESTSDIR}/bud/preprocess
|
2018-08-01 18:31:02 +08:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "$output"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with preprocessor error" {
|
|
|
|
|
target=alpine-image
|
2018-08-13 22:18:04 +08:00
|
|
|
run buildah --debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Error.in ${TESTSDIR}/bud/preprocess
|
2018-08-01 18:31:02 +08:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|
2018-08-22 04:33:36 +08:00
|
|
|
|
|
|
|
|
@test "bud-with-rejected-name" {
|
|
|
|
|
target=ThisNameShouldBeRejected
|
|
|
|
|
run buildah --debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/from-scratch
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
[[ "${output}" =~ "must be lower" ]]
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-30 15:19:46 +08:00
|
|
|
@test "bud with chown copy" {
|
2018-08-13 22:18:04 +08:00
|
|
|
imgName=alpine-image
|
|
|
|
|
ctrName=alpine-chown
|
2018-09-30 15:19:46 +08:00
|
|
|
run buildah --debug=false bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/copy-chown
|
2018-08-13 22:18:04 +08:00
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
2018-09-30 15:19:46 +08:00
|
|
|
[[ "$output" =~ user:2367[[:space:]]group:3267 ]]
|
2018-08-13 22:18:04 +08:00
|
|
|
run buildah --debug=false from --name ${ctrName} ${imgName}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run buildah --debug=false run alpine-chown -- stat -c '%u' /tmp/copychown.txt
|
|
|
|
|
echo "$output"
|
|
|
|
|
# Validate that output starts with "2367"
|
|
|
|
|
[ $(expr "$output" : "2367") -ne 0 ]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah --debug=false run alpine-chown -- stat -c '%g' /tmp/copychown.txt
|
|
|
|
|
echo "$output"
|
|
|
|
|
# Validate that output starts with "3267"
|
|
|
|
|
[ $(expr "$output" : "3267") -ne 0 ]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
2018-09-28 11:53:00 +08:00
|
|
|
|
2019-01-18 06:15:18 +08:00
|
|
|
@test "bud with chown add" {
|
|
|
|
|
imgName=alpine-image
|
|
|
|
|
ctrName=alpine-chown
|
|
|
|
|
run buildah --debug=false bud --signature-policy ${TESTSDIR}/policy.json -t ${imgName} ${TESTSDIR}/bud/add-chown
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ "$output" =~ user:2367[[:space:]]group:3267 ]]
|
|
|
|
|
run buildah --debug=false from --name ${ctrName} ${imgName}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run buildah --debug=false run alpine-chown -- stat -c '%u' /tmp/addchown.txt
|
|
|
|
|
echo "$output"
|
|
|
|
|
# Validate that output starts with "2367"
|
|
|
|
|
[ $(expr "$output" : "2367") -ne 0 ]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah --debug=false run alpine-chown -- stat -c '%g' /tmp/addchown.txt
|
|
|
|
|
echo "$output"
|
|
|
|
|
# Validate that output starts with "3267"
|
|
|
|
|
[ $(expr "$output" : "3267") -ne 0 ]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 11:53:00 +08:00
|
|
|
@test "bud with ADD file construct" {
|
|
|
|
|
buildah --debug=false bud --signature-policy ${TESTSDIR}/policy.json -t test1 ${TESTSDIR}/bud/add-file
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
ctr=$(buildah --debug=false from --signature-policy ${TESTSDIR}/policy.json test1)
|
|
|
|
|
run buildah --debug=false containers -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah --debug=false run $ctr ls /var/file2
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ $output =~ "/var/file2" ]]
|
|
|
|
|
}
|
2018-09-22 07:37:02 +08:00
|
|
|
|
|
|
|
|
@test "bud with FROM AS construct" {
|
|
|
|
|
buildah bud --signature-policy ${TESTSDIR}/policy.json -t test1 ${TESTSDIR}/bud/from-as
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
ctr=$(buildah --debug=false from --signature-policy ${TESTSDIR}/policy.json test1)
|
|
|
|
|
run buildah --debug=false containers -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah inspect --format "{{.Docker.ContainerConfig.Env}}" --type image test1
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ $output =~ "LOCAL=/1" ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with FROM AS construct with layers" {
|
|
|
|
|
buildah bud --layers --signature-policy ${TESTSDIR}/policy.json -t test1 ${TESTSDIR}/bud/from-as
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
ctr=$(buildah --debug=false from --signature-policy ${TESTSDIR}/policy.json test1)
|
|
|
|
|
run buildah --debug=false containers -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah inspect --format "{{.Docker.ContainerConfig.Env}}" --type image test1
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ $output =~ "LOCAL=/1" ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with FROM AS skip FROM construct" {
|
|
|
|
|
run buildah --debug=false bud --signature-policy ${TESTSDIR}/policy.json -t test1 -f ${TESTSDIR}/bud/from-as/Dockerfile.skip ${TESTSDIR}/bud/from-as
|
|
|
|
|
[[ $output =~ "LOCAL=/1" ]]
|
|
|
|
|
[[ $output =~ "LOCAL2=/2" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah --debug=false images -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
ctr=$(buildah --debug=false from --signature-policy ${TESTSDIR}/policy.json test1)
|
|
|
|
|
run buildah --debug=false containers -a
|
|
|
|
|
[[ $output =~ "test1" ]]
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
mnt=$(buildah mount $ctr)
|
|
|
|
|
run test -e $mnt/1
|
|
|
|
|
[ "${status}" -eq 0 ]
|
|
|
|
|
run test -e $mnt/2
|
|
|
|
|
[ "${status}" -ne 0 ]
|
|
|
|
|
|
|
|
|
|
run buildah --debug=false inspect --format "{{.Docker.ContainerConfig.Env}}" --type image test1
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[[ $output =~ "[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LOCAL=/1]" ]]
|
|
|
|
|
}
|
2018-10-28 03:47:03 +08:00
|
|
|
|
|
|
|
|
@test "bud with symlink Dockerfile not specified in file" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink ${TESTSDIR}/bud/symlink
|
|
|
|
|
echo "$output"
|
|
|
|
|
[[ $output =~ "FROM alpine" ]]
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with dir for file but no Dockerfile in dir" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/empty-dir ${TESTSDIR}/bud/empty-dir
|
|
|
|
|
echo "$output"
|
|
|
|
|
[[ $output =~ "no such file or directory" ]]
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with bad dir Dockerfile" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/baddirname ${TESTSDIR}/baddirname
|
|
|
|
|
echo "$output"
|
|
|
|
|
[[ $output =~ "no such file or directory" ]]
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 18:31:14 +08:00
|
|
|
@test "bud with ARG before FROM default value" {
|
|
|
|
|
target=leading-args-default
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/leading-args/Dockerfile ${TESTSDIR}/bud/leading-args
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with ARG before FROM" {
|
|
|
|
|
target=leading-args
|
|
|
|
|
run buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} --build-arg=VERSION=musl -f ${TESTSDIR}/bud/leading-args/Dockerfile ${TESTSDIR}/bud/leading-args
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 04:04:26 +08:00
|
|
|
@test "bud-with-healthcheck" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
buildah --debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} --format docker ${TESTSDIR}/bud/healthcheck
|
|
|
|
|
run buildah --debug=false 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}
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
second=1000000000
|
|
|
|
|
threeseconds=$(( 3 * $second ))
|
|
|
|
|
fiveminutes=$(( 5 * 60 * $second ))
|
|
|
|
|
tenminutes=$(( 10 * 60 * $second ))
|
|
|
|
|
[ "$output" = '["CMD-SHELL" "curl -f http://localhost/ || exit 1"]'" $tenminutes $fiveminutes $threeseconds 4" ]
|
|
|
|
|
}
|
2018-11-29 14:31:20 +08:00
|
|
|
|
|
|
|
|
@test "bud with unused build arg" {
|
|
|
|
|
target=busybox-image
|
|
|
|
|
out=$(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 | grep "Warning" | wc -l)
|
|
|
|
|
[ "$out" -ne 0 ]
|
|
|
|
|
}
|
2018-11-17 06:43:48 +08:00
|
|
|
|
|
|
|
|
@test "bud with copy-from in Dockerfile no prior FROM" {
|
|
|
|
|
target=php-image
|
|
|
|
|
run buildah --debug=false bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy-from ${TESTSDIR}/bud/copy-from
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
|
|
ctr=$(buildah --debug=false from --signature-policy ${TESTSDIR}/policy.json ${target})
|
|
|
|
|
mnt=$(buildah --debug=false mount ${ctr})
|
|
|
|
|
|
|
|
|
|
run test -e $mnt/usr/local/bin/composer
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
}
|