2017-03-30 03:50:32 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
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-08-01 00:02:06 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 6 ]
|
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-08-01 00:02:06 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 7 ]
|
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-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-08-01 00:02:06 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 9 ]
|
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-08-01 00:02:06 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 11 ]
|
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-08-01 00:02:06 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 13 ]
|
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-08-01 00:02:06 +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
|
|
|
|
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-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-08-01 00:02:06 +08:00
|
|
|
[ $(wc -l <<< "$output") -eq 5 ]
|
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-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}
|
|
|
|
|
buildah rmi test
|
|
|
|
|
buildah rmi test1
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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}
|
|
|
|
|
buildah rmi ${from_target} ${target}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 21:49:49 +08:00
|
|
|
@test "bud with Dockerfile from valid URL" {
|
|
|
|
|
target=url-image
|
|
|
|
|
url=https://raw.githubusercontent.com/projectatomic/buildah/master/tests/bud/from-scratch/Dockerfile
|
|
|
|
|
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
|
|
|
|
|
url=https://raw.githubusercontent.com/projectatomic/buildah/master/tests/bud/from-scratch/Dockerfile.bogus
|
|
|
|
|
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 ]
|
|
|
|
|
[[ "$output" =~ "invalid value \"bogus\" for flag" ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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 ]
|
|
|
|
|
[[ "$output" =~ "invalid value \"bogus\" for flag" ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
run buildah -debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.args ${TESTSDIR}/bud/run-scenarios
|
|
|
|
|
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
|
|
|
|
|
run buildah -debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Decomposed.in ${TESTSDIR}/bud/preprocess
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "$output"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bud with preprocessor error" {
|
|
|
|
|
target=alpine-image
|
|
|
|
|
run buildah -debug=false bud -q --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Error.in ${TESTSDIR}/bud/preprocess
|
|
|
|
|
echo "$output"
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
}
|