summaryrefslogtreecommitdiff
path: root/test/podman_build.bats
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2017-12-20 17:54:13 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-23 11:47:33 +0000
commitea5620182f6dc1fabc33e1a8d453d070fba0952c (patch)
treeb19193b6ba56b5be899a2619e7adde5c6e1c9787 /test/podman_build.bats
parent7f531263e6e41195278f205ad01274487cc1c1e0 (diff)
downloadpodman-ea5620182f6dc1fabc33e1a8d453d070fba0952c.tar.gz
podman-ea5620182f6dc1fabc33e1a8d453d070fba0952c.tar.bz2
podman-ea5620182f6dc1fabc33e1a8d453d070fba0952c.zip
Initial podman build
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com> Closes: #162 Approved by: rhatdan
Diffstat (limited to 'test/podman_build.bats')
-rw-r--r--test/podman_build.bats265
1 files changed, 265 insertions, 0 deletions
diff --git a/test/podman_build.bats b/test/podman_build.bats
new file mode 100644
index 000000000..159737019
--- /dev/null
+++ b/test/podman_build.bats
@@ -0,0 +1,265 @@
+#!/usr/bin/env bats
+
+load helpers
+
+@test "build-from-scratch" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ target=scratch-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} ${BUILDAH_TESTSDIR}/build/from-scratch
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+ [ "$status" -eq 0 ]
+}
+
+@test "build-from-multiple-files-one-from" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ target=scratch-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom
+ cid=$(buildah from ${target})
+ root=$(buildah mount ${cid})
+ cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch
+ cmp $root/Dockerfile2.nofrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom
+ run test -s $root/etc/passwd
+ [ "$status" -ne 0 ]
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+
+ target=alpine-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom
+ cid=$(buildah from ${target})
+ root=$(buildah mount ${cid})
+ cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine
+ cmp $root/Dockerfile2.nofrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.nofrom
+ run test -s $root/etc/passwd
+ [ "$status" -eq 0 ]
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+}
+
+@test "build-from-multiple-files-two-froms" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ target=scratch-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom
+ cid=$(buildah from ${target})
+ root=$(buildah mount ${cid})
+ cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.scratch
+ cmp $root/Dockerfile2.withfrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom
+ run test -s $root/etc/passwd
+ [ "$status" -ne 0 ]
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+
+ target=alpine-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine -f ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom
+ cid=$(buildah from ${target})
+ root=$(buildah mount ${cid})
+ cmp $root/Dockerfile1 ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine
+ cmp $root/Dockerfile2.withfrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom
+ run test -s $root/etc/passwd
+ [ "$status" -eq 0 ]
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+}
+
+@test "build-preserve-subvolumes" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ # This Dockerfile needs us to be able to handle a working RUN instruction.
+ if ! which runc ; then
+ skip
+ fi
+ target=volume-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} ${BUILDAH_TESTSDIR}/build/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
+ test -s $root/vol/Dockerfile
+ test -s $root/vol/Dockerfile2
+ run test -s $root/vol/anothervolfile
+ [ "$status" -ne 0 ]
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-http-Dockerfile" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ starthttpd ${BUILDAH_TESTSDIR}/build/from-scratch
+ target=scratch-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f http://0.0.0.0:${HTTP_SERVER_PORT}/Dockerfile .
+ stophttpd
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-http-context-with-Dockerfile" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ starthttpd ${BUILDAH_TESTSDIR}/build/http-context
+ target=scratch-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar
+ stophttpd
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-http-context-dir-with-Dockerfile-pre" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ starthttpd ${BUILDAH_TESTSDIR}/build/http-context-subdir
+ target=scratch-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f context/Dockerfile http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar
+ stophttpd
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-http-context-dir-with-Dockerfile-post" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ starthttpd ${BUILDAH_TESTSDIR}/build/http-context-subdir
+ target=scratch-image
+ kpod build http://0.0.0.0:${HTTP_SERVER_PORT}/context.tar --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f context/Dockerfile
+ stophttpd
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-git-context" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ # 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
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} "${gitrepo}"
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-github-context" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ target=github-image
+ # Any repo should do, but this one is small and is FROM: scratch.
+ gitrepo=github.com/projectatomic/nulecule-library
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} "${gitrepo}"
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ buildah --debug=false images -q
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-additional-tags" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ target=scratch-image
+ target2=another-scratch-image
+ target3=so-many-scratch-images
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -t ${target2} -t ${target3} ${BUILDAH_TESTSDIR}/build/from-scratch
+ run buildah --debug=false images
+ cid=$(buildah from ${target})
+ kpod rm ${cid}
+ cid=$(buildah from library/${target2})
+ kpod rm ${cid}
+ cid=$(buildah from ${target3}:latest)
+ kpod rm ${cid}
+ kpod rmi -f $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-volume-perms" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ # This Dockerfile needs us to be able to handle a working RUN instruction.
+ if ! which runc ; then
+ skip
+ fi
+ target=volume-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} ${BUILDAH_TESTSDIR}/build/volume-perms
+ cid=$(buildah from ${target})
+ root=$(buildah mount ${cid})
+ run test -s $root/vol/subvol/subvolfile
+ [ "$status" -ne 0 ]
+ run stat -c %f $root/vol/subvol
+ [ "$output" = 41ed ]
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}
+
+@test "build-from-glob" {
+ if ! which buildah ; then
+ skip "Buildah not installed"
+ fi
+ target=alpine-image
+ kpod build --signature-policy ${BUILDAH_TESTSDIR}/policy.json -t ${target} -f Dockerfile2.glob ${BUILDAH_TESTSDIR}/build/from-multiple-files
+ cid=$(buildah from ${target})
+ root=$(buildah mount ${cid})
+ cmp $root/Dockerfile1.alpine ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile1.alpine
+ cmp $root/Dockerfile2.withfrom ${BUILDAH_TESTSDIR}/build/from-multiple-files/Dockerfile2.withfrom
+ kpod rm ${cid}
+ kpod rmi $(buildah --debug=false images -q)
+ run buildah --debug=false images -q
+ [ "$output" = "" ]
+}