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-25 00:49:22 +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-28 02:46:35 +08:00
|
|
|
cid=$(buildah from alpine --pull --signature-policy ${TESTSDIR}/policy.json --name i-love-naming-things)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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-28 02:46:35 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
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-28 02:46:35 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --name alpine-working-image-for-test alpine)
|
2017-03-25 00:49:22 +08:00
|
|
|
root=$(buildah mount alpine-working-image-for-test)
|
|
|
|
|
buildah unmount alpine-working-image-for-test
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm alpine-working-image-for-test
|
2017-03-16 05:25:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "by-root" {
|
2017-03-28 02:46:35 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
2017-03-25 00:49:22 +08:00
|
|
|
root=$(buildah mount $cid)
|
|
|
|
|
buildah unmount $cid
|
2017-03-24 04:45:35 +08:00
|
|
|
buildah rm $cid
|
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-28 02:46:35 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
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
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:yet-another-new-image
|
|
|
|
|
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-24 04:45:35 +08:00
|
|
|
buildah rm $yetanothernewcid
|
2017-03-07 07:11:40 +08:00
|
|
|
}
|