2017-03-07 07:11:40 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
|
|
@test "from" {
|
2017-03-28 02:46:35 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
2017-03-29 05:38:15 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json scratch)
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
2018-02-23 23:54:23 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --name i-love-naming-things alpine)
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm i-love-naming-things
|
2017-03-18 05:46:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "from-defaultpull" {
|
2017-03-28 02:46:35 +08:00
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine)
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
2017-03-18 05:46:21 +08:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 05:38:15 +08:00
|
|
|
@test "from-scratch" {
|
|
|
|
|
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json scratch)
|
|
|
|
|
buildah rm $cid
|
|
|
|
|
cid=$(buildah from --pull=true --signature-policy ${TESTSDIR}/policy.json scratch)
|
|
|
|
|
buildah rm $cid
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-18 05:46:21 +08:00
|
|
|
@test "from-nopull" {
|
2017-03-28 02:46:35 +08:00
|
|
|
run buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
2017-03-25 00:49:22 +08:00
|
|
|
[ "$status" -eq 1 ]
|
2017-03-07 07:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "mount" {
|
2017-03-29 05:38:15 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json scratch)
|
2017-03-25 00:49:22 +08:00
|
|
|
root=$(buildah mount $cid)
|
|
|
|
|
buildah unmount $cid
|
|
|
|
|
root=$(buildah mount $cid)
|
2017-03-28 02:46:35 +08:00
|
|
|
touch $root/foobar
|
2017-03-25 00:49:22 +08:00
|
|
|
buildah unmount $cid
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
2017-03-07 07:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
2017-03-16 05:25:05 +08:00
|
|
|
@test "by-name" {
|
2017-03-29 05:38:15 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --name scratch-working-image-for-test scratch)
|
|
|
|
|
root=$(buildah mount scratch-working-image-for-test)
|
|
|
|
|
buildah unmount scratch-working-image-for-test
|
|
|
|
|
buildah rm scratch-working-image-for-test
|
2017-03-16 05:25:05 +08:00
|
|
|
}
|
|
|
|
|
|
2017-03-07 07:11:40 +08:00
|
|
|
@test "commit" {
|
2017-03-25 00:49:22 +08:00
|
|
|
createrandom ${TESTDIR}/randomfile
|
|
|
|
|
createrandom ${TESTDIR}/other-randomfile
|
2017-03-07 07:11:40 +08:00
|
|
|
|
2017-03-29 05:38:15 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json scratch)
|
2017-03-25 00:49:22 +08:00
|
|
|
root=$(buildah mount $cid)
|
|
|
|
|
cp ${TESTDIR}/randomfile $root/randomfile
|
|
|
|
|
buildah unmount $cid
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
2017-03-07 07:11:40 +08:00
|
|
|
|
2017-03-28 02:46:35 +08:00
|
|
|
newcid=$(buildah from new-image)
|
2017-03-25 00:49:22 +08:00
|
|
|
newroot=$(buildah mount $newcid)
|
|
|
|
|
test -s $newroot/randomfile
|
|
|
|
|
cmp ${TESTDIR}/randomfile $newroot/randomfile
|
|
|
|
|
cp ${TESTDIR}/other-randomfile $newroot/other-randomfile
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:other-new-image
|
|
|
|
|
# Not an allowed ordering of arguments and flags. Check that it's rejected.
|
|
|
|
|
run buildah commit $newcid --signature-policy ${TESTSDIR}/policy.json containers-storage:rejected-new-image
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:another-new-image
|
2017-03-28 23:16:46 +08:00
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid yet-another-new-image
|
2017-03-29 05:08:37 +08:00
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:gratuitous-new-image
|
2017-03-25 00:49:22 +08:00
|
|
|
buildah unmount $newcid
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $newcid
|
2017-03-07 07:11:40 +08:00
|
|
|
|
2017-03-28 02:46:35 +08:00
|
|
|
othernewcid=$(buildah from other-new-image)
|
2017-03-25 00:49:22 +08:00
|
|
|
othernewroot=$(buildah mount $othernewcid)
|
|
|
|
|
test -s $othernewroot/randomfile
|
|
|
|
|
cmp ${TESTDIR}/randomfile $othernewroot/randomfile
|
|
|
|
|
test -s $othernewroot/other-randomfile
|
|
|
|
|
cmp ${TESTDIR}/other-randomfile $othernewroot/other-randomfile
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $othernewcid
|
2017-03-18 05:46:21 +08:00
|
|
|
|
2017-03-28 02:46:35 +08:00
|
|
|
anothernewcid=$(buildah from another-new-image)
|
2017-03-25 00:49:22 +08:00
|
|
|
anothernewroot=$(buildah mount $anothernewcid)
|
|
|
|
|
test -s $anothernewroot/randomfile
|
|
|
|
|
cmp ${TESTDIR}/randomfile $anothernewroot/randomfile
|
|
|
|
|
test -s $anothernewroot/other-randomfile
|
|
|
|
|
cmp ${TESTDIR}/other-randomfile $anothernewroot/other-randomfile
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $anothernewcid
|
2017-03-18 05:46:21 +08:00
|
|
|
|
2017-03-28 02:46:35 +08:00
|
|
|
yetanothernewcid=$(buildah from yet-another-new-image)
|
2017-03-25 00:49:22 +08:00
|
|
|
yetanothernewroot=$(buildah mount $yetanothernewcid)
|
|
|
|
|
test -s $yetanothernewroot/randomfile
|
|
|
|
|
cmp ${TESTDIR}/randomfile $yetanothernewroot/randomfile
|
|
|
|
|
test -s $yetanothernewroot/other-randomfile
|
|
|
|
|
cmp ${TESTDIR}/other-randomfile $yetanothernewroot/other-randomfile
|
2017-03-29 05:08:37 +08:00
|
|
|
buildah delete $yetanothernewcid
|
|
|
|
|
|
2017-07-14 20:57:26 +08:00
|
|
|
newcid=$(buildah from new-image)
|
|
|
|
|
buildah commit --rm --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:remove-container-image
|
|
|
|
|
run buildah mount $newcid
|
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
|
|
|
|
|
buildah rmi remove-container-image
|
2017-03-29 05:08:37 +08:00
|
|
|
buildah rmi containers-storage:other-new-image
|
|
|
|
|
buildah rmi another-new-image
|
|
|
|
|
run buildah --debug=false images -q
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
for id in $output ; do
|
|
|
|
|
buildah rmi $id
|
|
|
|
|
done
|
|
|
|
|
run buildah --debug=false images -q
|
2017-11-08 06:19:51 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2017-03-29 05:08:37 +08:00
|
|
|
[ "$output" == "" ]
|
2017-03-07 07:11:40 +08:00
|
|
|
}
|