2017-03-07 07:11:40 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
|
|
@test "from" {
|
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --image alpine)
|
|
|
|
|
buildah delete --name=$cid
|
2017-03-18 05:46:21 +08:00
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
|
|
|
|
buildah delete --name=$cid
|
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine i-love-naming-things)
|
|
|
|
|
buildah delete --name=i-love-naming-things
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "from-defaultpull" {
|
|
|
|
|
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json --image alpine)
|
|
|
|
|
buildah delete $cid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "from-nopull" {
|
|
|
|
|
run buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json --image alpine
|
|
|
|
|
[ "$status" -eq 1 ]
|
2017-03-07 07:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "mount" {
|
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --image alpine)
|
|
|
|
|
root=$(buildah mount --name=$cid)
|
|
|
|
|
buildah unmount --name=$cid
|
2017-03-18 05:46:21 +08:00
|
|
|
root=$(buildah mount $cid)
|
|
|
|
|
buildah unmount $cid
|
2017-03-07 07:11:40 +08:00
|
|
|
buildah delete --name=$cid
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 05:25:05 +08:00
|
|
|
@test "by-name" {
|
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --image alpine --name=alpine-working-image-for-test)
|
|
|
|
|
root=$(buildah mount --name=alpine-working-image-for-test)
|
|
|
|
|
buildah unmount --name=alpine-working-image-for-test
|
|
|
|
|
buildah delete --name=alpine-working-image-for-test
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "by-root" {
|
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --image alpine)
|
|
|
|
|
root=$(buildah mount --name=$cid)
|
|
|
|
|
buildah unmount --root=$root
|
|
|
|
|
buildah delete --root=$root
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 07:11:40 +08:00
|
|
|
@test "commit" {
|
2017-03-08 04:54:51 +08:00
|
|
|
createrandom ${TESTDIR}/randomfile
|
|
|
|
|
createrandom ${TESTDIR}/other-randomfile
|
2017-03-07 07:11:40 +08:00
|
|
|
|
|
|
|
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json --image alpine)
|
|
|
|
|
root=$(buildah mount --name=$cid)
|
2017-03-08 04:54:51 +08:00
|
|
|
cp ${TESTDIR}/randomfile $root/randomfile
|
2017-03-07 07:11:40 +08:00
|
|
|
buildah unmount --name=$cid
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json --name=$cid --output=containers-storage:new-image
|
|
|
|
|
buildah delete --name=$cid
|
|
|
|
|
|
|
|
|
|
newcid=$(buildah from --image new-image)
|
|
|
|
|
newroot=$(buildah mount --name=$newcid)
|
|
|
|
|
test -s $newroot/randomfile
|
2017-03-08 04:54:51 +08:00
|
|
|
cmp ${TESTDIR}/randomfile $newroot/randomfile
|
|
|
|
|
cp ${TESTDIR}/other-randomfile $newroot/other-randomfile
|
2017-03-07 07:11:40 +08:00
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json --name=$newcid --output=containers-storage:other-new-image
|
2017-03-18 05:46:21 +08:00
|
|
|
# Not an allowed ordering of arguments and flags. Check that it's rejected.
|
|
|
|
|
run buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid --output=containers-storage:rejected-new-image
|
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json --output=containers-storage:another-new-image $newcid
|
|
|
|
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:yet-another-new-image
|
2017-03-07 07:11:40 +08:00
|
|
|
buildah unmount --name=$newcid
|
|
|
|
|
buildah delete --name=$newcid
|
|
|
|
|
|
|
|
|
|
othernewcid=$(buildah from --image other-new-image)
|
|
|
|
|
othernewroot=$(buildah mount --name=$othernewcid)
|
|
|
|
|
test -s $othernewroot/randomfile
|
2017-03-08 04:54:51 +08:00
|
|
|
cmp ${TESTDIR}/randomfile $othernewroot/randomfile
|
2017-03-07 07:11:40 +08:00
|
|
|
test -s $othernewroot/other-randomfile
|
2017-03-08 04:54:51 +08:00
|
|
|
cmp ${TESTDIR}/other-randomfile $othernewroot/other-randomfile
|
2017-03-07 07:11:40 +08:00
|
|
|
buildah delete --name=$othernewcid
|
2017-03-18 05:46:21 +08:00
|
|
|
|
|
|
|
|
anothernewcid=$(buildah from --image another-new-image)
|
|
|
|
|
anothernewroot=$(buildah mount --name=$anothernewcid)
|
|
|
|
|
test -s $anothernewroot/randomfile
|
|
|
|
|
cmp ${TESTDIR}/randomfile $anothernewroot/randomfile
|
|
|
|
|
test -s $anothernewroot/other-randomfile
|
|
|
|
|
cmp ${TESTDIR}/other-randomfile $anothernewroot/other-randomfile
|
|
|
|
|
buildah delete --name=$anothernewcid
|
|
|
|
|
|
|
|
|
|
yetanothernewcid=$(buildah from --image yet-another-new-image)
|
|
|
|
|
yetanothernewroot=$(buildah mount --name=$yetanothernewcid)
|
|
|
|
|
test -s $yetanothernewroot/randomfile
|
|
|
|
|
cmp ${TESTDIR}/randomfile $yetanothernewroot/randomfile
|
|
|
|
|
test -s $yetanothernewroot/other-randomfile
|
|
|
|
|
cmp ${TESTDIR}/other-randomfile $yetanothernewroot/other-randomfile
|
|
|
|
|
buildah delete --name=$yetanothernewcid
|
2017-03-07 07:11:40 +08:00
|
|
|
}
|