From 52d0facb7788d418596e51be079b1fd1f31775ae Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Tue, 22 Oct 2019 19:50:25 +0800 Subject: [PATCH 01/11] Tests: Add two test for buildah add Add following tests for buildah add 1. buildah add test with --chown 2. buildah add url test Signed-off-by: Yiqiao Pu --- tests/add.bats | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/add.bats b/tests/add.bats index 5785dd3490..7bb975ccf1 100644 --- a/tests/add.bats +++ b/tests/add.bats @@ -140,3 +140,24 @@ load helpers expect_output "644" run_buildah rm $newcid } + +@test "add with chown" { + createrandom ${TESTDIR}/randomfile + cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) + run_buildah add --chown bin:bin $cid ${TESTDIR}/randomfile /tmp/random + run_buildah run $cid ls -l /tmp/random + + expect_output --substring bin.*bin + buildah rm $cid +} + +@test "add url" { + cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) + run_buildah add $cid https://github.com/containers/buildah/raw/master/README.md + run_buildah run $cid ls /README.md + + run_buildah add $cid https://github.com/containers/buildah/raw/master/README.md /home + run_buildah run $cid ls /home/README.md + + buildah rm $cid +} From 26d9139d578aaba2f3f62444bdc2b4aa5cdb9ac1 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Tue, 22 Oct 2019 21:04:36 +0800 Subject: [PATCH 02/11] Tests: Add buildah bud with --quiet test Signed-off-by: Yiqiao Pu --- tests/bud.bats | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/bud.bats b/tests/bud.bats index 5cacbdab53..fcfad3b726 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -1882,3 +1882,11 @@ EOM run_buildah 1 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy/Dockerfile.url ${TESTSDIR}/bud/copy rm -r ${TESTSDIR}/bud/copy } + +@test "bud quiet" { + run_buildah bud --format docker -t quiet-test --signature-policy ${TESTSDIR}/policy.json -q ${TESTSDIR}/bud/shell + expect_line_count 1 + expect_output --substring "^[0-9a-z]{64}$" + + buildah rmi quiet-test +} From 27d417cdcb4260986d5fabbff5a9fc3f6390beda Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Mon, 28 Oct 2019 16:25:42 +0800 Subject: [PATCH 03/11] Tests: Add two commit test Add following test cases for commit: - commit with name - commit to docker-distribution Signed-off-by: Yiqiao Pu --- tests/commit.bats | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/commit.bats b/tests/commit.bats index a1282ab113..fde5b6c639 100644 --- a/tests/commit.bats +++ b/tests/commit.bats @@ -134,4 +134,20 @@ load helpers containerid=$(buildah inspect --format '{{.Docker.Container}}' alpine-image) echo recorded container ID: "$containerid" [ "$containerid" = "$cid" ] + +@test "commit with name" { + buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc busybox + run_buildah --log-level=error commit --signature-policy ${TESTSDIR}/policy.json busyboxc commitbyname/busyboxbyname + cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json localhost/commitbyname/busyboxbyname) + run_buildah inspect --format '{{.Container}}' $cid + expect_output $cid + buildah rm busyboxc $cid + buildah rmi commitbyname/busyboxbyname +} + +@test "commit to docker-distribution" { + buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc busybox + run_buildah commit --signature-policy ${TESTSDIR}/policy.json --tls-verify=false --creds testuser:testpassword busyboxc docker://localhost:5000/commit/busybox + run_buildah from --signature-policy ${TESTSDIR}/policy.json --name fromdocker --tls-verify=false --creds testuser:testpassword docker://localhost:5000/commit/busybox + buildah rm busyboxc fromdocker } From e809e2c98cd18e34f6c0c00b86e1301f3b0801ed Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Mon, 28 Oct 2019 21:11:39 +0800 Subject: [PATCH 04/11] Tests: Add some buildah from tests Signed-off-by: Yiqiao Pu --- tests/from.bats | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/from.bats b/tests/from.bats index 7e6631f406..1273d35949 100644 --- a/tests/from.bats +++ b/tests/from.bats @@ -327,6 +327,7 @@ load helpers container_name=mycontainer cid=$(buildah from --name=${container_name} --pull --signature-policy ${TESTSDIR}/policy.json alpine) buildah --log-level=error inspect --format '{{.Container}}' ${container_name} + buildah rm $cid } @test "from cidfile test" { @@ -364,3 +365,19 @@ load helpers @test "from should fail with nonexist authfil" { run_buildah 1 from --authfile /tmp/nonexist --pull --signature-policy ${TESTSDIR}/policy.json alpine } + +@test "from pull always test" { + run buildah pull --signature-policy ${TESTSDIR}/policy.json docker.io/busybox + run_buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc --pull-always docker.io/busybox + expect_output --substring "Getting" + buildah commit --signature-policy ${TESTSDIR}/policy.json busyboxc fakename-img + run_buildah 1 from --signature-policy ${TESTSDIR}/policy.json --pull-always fakename-img + buildah rm busyboxc + buildah rmi fakename-img +} + +@test "from quiet test" { + run buildah rmi docker.io/busybox + run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet docker.io/busybox + [[ "$output" != "Getting"* ]] +} From 0509a5920a264e27b161fe97958a7784fabcdc9b Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Wed, 6 Nov 2019 17:18:48 +0800 Subject: [PATCH 05/11] Tests: Add image digest test Signed-off-by: Yiqiao Pu --- tests/images.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/images.bats b/tests/images.bats index 31eb841d0b..c4bcdbe1c1 100644 --- a/tests/images.bats +++ b/tests/images.bats @@ -157,3 +157,9 @@ load helpers buildah rm -a buildah rmi -a -f } + +@test "image digest test" { + buildah pull --signature-policy ${TESTSDIR}/policy.json busybox + run_buildah images --digests + expect_output --substring "sha256:" +} From ea3f17c7322592c8840214b2f38f47e1c535616c Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Tue, 29 Oct 2019 14:37:00 +0800 Subject: [PATCH 06/11] Tests: Add test cases for push test Add following test cases for push: - buildah push image to containers-storage - buildah push image to docker-archive and oci-archive - buildah push image to docker and docker registry Signed-off-by: Yiqiao Pu --- tests/push.bats | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/push.bats b/tests/push.bats index 8fad0f797b..cee116d7d4 100644 --- a/tests/push.bats +++ b/tests/push.bats @@ -109,3 +109,43 @@ load helpers run_buildah 1 push --signature-policy ${TESTSDIR}/policy.json busybox docker://registry.example.com/evenbusierbox expect_output --substring 'push to registry at "registry.example.com" denied by policy: not in allowed registries list' } + + +@test "buildah push image to containers-storage" { + buildah pull --signature-policy ${TESTSDIR}/policy.json busybox + run_buildah push --signature-policy ${TESTSDIR}/policy.json busybox containers-storage:newimage:latest + run_buildah images + expect_output --substring "newimage" + buildah rmi newimage busybox +} + +@test "buildah push image to docker-archive and oci-archive" { + buildah pull --signature-policy ${TESTSDIR}/policy.json busybox + for dest in docker-archive oci-archive; do + mkdir ${TESTDIR}/tmp + run_buildah push --signature-policy ${TESTSDIR}/policy.json busybox $dest:${TESTDIR}/tmp/busybox.tar:latest + ls ${TESTDIR}/tmp/busybox.tar + rm -rf ${TESTDIR}/tmp + done +} + +@test "buildah push image to docker and docker registry" { + run which docker + if [[ $status -ne 0 ]]; then + skip "docker is not installed" + fi + + buildah pull --signature-policy ${TESTSDIR}/policy.json busybox + run_buildah push --signature-policy ${TESTSDIR}/policy.json busybox docker-daemon:buildah/busybox:latest + run docker images + expect_output --substring "buildah/busybox" + docker rmi buildah/busybox + + run_buildah push --signature-policy ${TESTSDIR}/policy.json --tls-verify=false --creds testuser:testpassword docker.io/busybox:latest docker://localhost:5000/buildah/busybox:latest + docker login localhost:5000 --username testuser --password testpassword + docker pull localhost:5000/buildah/busybox:latest + output=$(docker images) + expect_output --substring "buildah/busybox" + docker rmi localhost:5000/buildah/busybox:latest + docker logout localhost:5000 +} From 73ba32bd63ee878f31b2a6c09d6bd331785e2277 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Tue, 29 Oct 2019 14:40:54 +0800 Subject: [PATCH 07/11] Tests: Add a test for tag by id Signed-off-by: Yiqiao Pu --- tests/tag.bats | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/tag.bats b/tests/tag.bats index 941db5ad20..06c4b721f8 100644 --- a/tests/tag.bats +++ b/tests/tag.bats @@ -2,7 +2,7 @@ load helpers -@test "tag" { +@test "tag by name" { cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json scratch) run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" scratch-image run_buildah 1 inspect --type image tagged-image @@ -11,3 +11,15 @@ load helpers run_buildah inspect --type image tagged-also-image run_buildah inspect --type image named-image } + +@test "tag by id" { + buildah pull --signature-policy ${TESTSDIR}/policy.json busybox + id=$(buildah images -q busybox) + run_buildah tag $id busybox1 + run_buildah from busybox1 + run_buildah mount busybox1-working-container + run_buildah unmount busybox1-working-container + run_buildah rm busybox1-working-container + run_buildah rmi busybox1 + run_buildah inspect --type image busybox +} From e02131af38f09673998f82b277cc6c30d2a3e9a8 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Wed, 6 Nov 2019 17:46:53 +0800 Subject: [PATCH 08/11] Test: Get permission in add test The permission may different in different system. Not always a fix value. So update the scripts to get the permission during the test. Signed-off-by: Yiqiao Pu --- tests/add.bats | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/add.bats b/tests/add.bats index 7bb975ccf1..65348badbf 100644 --- a/tests/add.bats +++ b/tests/add.bats @@ -108,36 +108,38 @@ load helpers @test "add single file creates absolute path with correct permissions" { imgName=ubuntu-image createrandom ${TESTDIR}/distutils.cfg + permission=$(stat -c "%a" ${TESTDIR}/distutils.cfg) cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ubuntu) run_buildah add $cid ${TESTDIR}/distutils.cfg /usr/lib/python3.7/distutils run_buildah run $cid stat -c "%a" /usr/lib/python3.7/distutils root=$(buildah mount $cid) - expect_output "644" + expect_output $permission run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:${imgName} run_buildah rm $cid newcid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${imgName}) run_buildah run $newcid stat -c "%a" /usr/lib/python3.7/distutils - expect_output "644" + expect_output $permission run_buildah rm $newcid } @test "add single file creates relative path with correct permissions" { imgName=ubuntu-image createrandom ${TESTDIR}/distutils.cfg + permission=$(stat -c "%a" ${TESTDIR}/distutils.cfg) cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ubuntu) run_buildah add $cid ${TESTDIR}/distutils.cfg lib/custom run_buildah run $cid stat -c "%a" lib/custom root=$(buildah mount $cid) - expect_output "644" + expect_output $permission run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:${imgName} run_buildah rm $cid newcid=$(buildah from --signature-policy ${TESTSDIR}/policy.json ${imgName}) run_buildah run $newcid stat -c "%a" lib/custom - expect_output "644" + expect_output $permission run_buildah rm $newcid } From 1e93f4addee02ba01a2be1aefe1ac06888acb20e Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Wed, 6 Nov 2019 18:20:33 +0800 Subject: [PATCH 09/11] Tests: Add container name and id check in containers test steps Add some checkpoint for checking container name and id inside the tests. Signed-off-by: Yiqiao Pu --- tests/commit.bats | 1 + tests/containers.bats | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tests/commit.bats b/tests/commit.bats index fde5b6c639..c7f8a06a97 100644 --- a/tests/commit.bats +++ b/tests/commit.bats @@ -134,6 +134,7 @@ load helpers containerid=$(buildah inspect --format '{{.Docker.Container}}' alpine-image) echo recorded container ID: "$containerid" [ "$containerid" = "$cid" ] +} @test "commit with name" { buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc busybox diff --git a/tests/containers.bats b/tests/containers.bats index 44f8ac3898..cb7aee5e65 100644 --- a/tests/containers.bats +++ b/tests/containers.bats @@ -27,6 +27,8 @@ load helpers cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) run_buildah --log-level=error containers --format "{{.ContainerName}}" expect_line_count 2 + expect_output --from="${lines[0]}" "alpine-working-container" + expect_output --from="${lines[1]}" "busybox-working-container" buildah rm -a buildah rmi -a -f @@ -45,6 +47,7 @@ load helpers cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) run_buildah --log-level=error containers --noheading expect_line_count 2 + [[ "$output" != "NAME"* ]] buildah rm -a buildah rmi -a -f @@ -56,6 +59,9 @@ load helpers run_buildah --log-level=error containers --quiet expect_line_count 2 + [[ "${lines[0]}" != "$cid1"* ]] + [[ "${lines[1]}" != "$cid2"* ]] + buildah rm -a buildah rmi -a -f } From 03be32113263f839a367d0052101cbcb92b20ecb Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Wed, 6 Nov 2019 18:42:59 +0800 Subject: [PATCH 10/11] Tests: Add inspect test check steps Add check steps for inspect with container id and image id. Signed-off-by: Yiqiao Pu --- tests/inspect.bats | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/inspect.bats b/tests/inspect.bats index 361513421f..f3e96827e2 100644 --- a/tests/inspect.bats +++ b/tests/inspect.bats @@ -23,6 +23,17 @@ load helpers [ "$out1" != "" ] [ "$out1" = "$out2" ] + + imageid=$(buildah images -q alpine-image) + containerid=$(buildah containers -q) + + out3=$(buildah inspect --format '{{.OCIv1.Config}}' $containerid) + out4=$(buildah inspect --type image --format '{{.OCIv1.Config}}' $imageid) + [ "$out3" = "$out1" ] + [ "$out4" = "$out1" ] + + buildah rm $cid + buildah rmi alpine-image alpine } @test "inspect-config-is-json" { From e3e38a864acbc95f3b052aeed75a566f38b8373e Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 3 Dec 2019 11:18:24 -0700 Subject: [PATCH 11/11] PR takeover of #1966 PR 1966 has languished for three weeks without activity from submitter. In the interests of getting it online, I have taken it over and: - rebased - fixed several misunderstandings (bugs) noted in review feedback - fixed a few more I also slightly rewrote two tests (tag by id, commit with name) that were incomprehensible to me: unnecessary mount/umount and no actual testing of anything other than checking exit status. I believe the new code is closer to the intention of testing but please pay closer attention to those bits. Also: fixed the basic 'inspect' test. It looks like at some point in the last month #1917 added a version string to the buildah-inspect output. The test was fixed on master, but ypu's PR did not incorporate those fixes and the test was breaking. I took the liberty of cleaning up the entire test for readability and maintainability. Signed-off-by: Ed Santiago --- tests/bud.bats | 2 +- tests/commit.bats | 23 +++++++++++++------ tests/containers.bats | 9 +++++--- tests/from.bats | 19 +++++++++------- tests/inspect.bats | 52 ++++++++++++++++++++++++++----------------- tests/tag.bats | 19 +++++++++++----- 6 files changed, 79 insertions(+), 45 deletions(-) diff --git a/tests/bud.bats b/tests/bud.bats index fcfad3b726..4ccac2ad8c 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -1886,7 +1886,7 @@ EOM @test "bud quiet" { run_buildah bud --format docker -t quiet-test --signature-policy ${TESTSDIR}/policy.json -q ${TESTSDIR}/bud/shell expect_line_count 1 - expect_output --substring "^[0-9a-z]{64}$" + expect_output --substring '^[0-9a-f]{64}$' buildah rmi quiet-test } diff --git a/tests/commit.bats b/tests/commit.bats index c7f8a06a97..3f998f8699 100644 --- a/tests/commit.bats +++ b/tests/commit.bats @@ -137,13 +137,22 @@ load helpers } @test "commit with name" { - buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc busybox - run_buildah --log-level=error commit --signature-policy ${TESTSDIR}/policy.json busyboxc commitbyname/busyboxbyname - cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json localhost/commitbyname/busyboxbyname) - run_buildah inspect --format '{{.Container}}' $cid - expect_output $cid - buildah rm busyboxc $cid - buildah rmi commitbyname/busyboxbyname + run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json --name busyboxc busybox + expect_output "busyboxc" + + # Commit with a new name + newname="commitbyname/busyboxname" + run_buildah commit --signature-policy ${TESTSDIR}/policy.json busyboxc $newname + + run_buildah from --signature-policy ${TESTSDIR}/policy.json localhost/$newname + expect_output "busyboxname-working-container" + + cname=$output + run_buildah inspect --format '{{.FromImage}}' $cname + expect_output "localhost/$newname:latest" + + buildah rm busyboxc $cname + buildah rmi $newname } @test "commit to docker-distribution" { diff --git a/tests/containers.bats b/tests/containers.bats index cb7aee5e65..c8843ef71e 100644 --- a/tests/containers.bats +++ b/tests/containers.bats @@ -47,7 +47,9 @@ load helpers cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) run_buildah --log-level=error containers --noheading expect_line_count 2 - [[ "$output" != "NAME"* ]] + if [[ $output =~ "NAME" ]]; then + expect_output "[no instance of 'NAME']" "'NAME' header should be absent" + fi buildah rm -a buildah rmi -a -f @@ -59,8 +61,9 @@ load helpers run_buildah --log-level=error containers --quiet expect_line_count 2 - [[ "${lines[0]}" != "$cid1"* ]] - [[ "${lines[1]}" != "$cid2"* ]] + # Both lines should be CIDs and nothing else. + expect_output --substring --from="${lines[0]}" '^[0-9a-f]{64}$' + expect_output --substring --from="${lines[1]}" '^[0-9a-f]{64}$' buildah rm -a buildah rmi -a -f diff --git a/tests/from.bats b/tests/from.bats index 1273d35949..d8be616608 100644 --- a/tests/from.bats +++ b/tests/from.bats @@ -362,22 +362,25 @@ load helpers buildah rmi --all --force } -@test "from should fail with nonexist authfil" { - run_buildah 1 from --authfile /tmp/nonexist --pull --signature-policy ${TESTSDIR}/policy.json alpine +@test "from with nonexistent authfile: fails" { + run_buildah 1 from --authfile /no/such/file --pull --signature-policy ${TESTSDIR}/policy.json alpine + expect_output "error checking authfile path /no/such/file: stat /no/such/file: no such file or directory" } -@test "from pull always test" { +@test "from --pull-always: emits 'Getting' even if image is cached" { run buildah pull --signature-policy ${TESTSDIR}/policy.json docker.io/busybox run_buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc --pull-always docker.io/busybox expect_output --substring "Getting" buildah commit --signature-policy ${TESTSDIR}/policy.json busyboxc fakename-img run_buildah 1 from --signature-policy ${TESTSDIR}/policy.json --pull-always fakename-img - buildah rm busyboxc - buildah rmi fakename-img + run_buildah rm busyboxc + run_buildah rmi fakename-img } -@test "from quiet test" { - run buildah rmi docker.io/busybox +@test "from --quiet: should not emit progress messages" { + # Force a pull. Normally this would say 'Getting image ...' and other + # progress messages. With --quiet, we should see only the container name. + run_buildah '?' rmi busybox run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet docker.io/busybox - [[ "$output" != "Getting"* ]] + expect_output "busybox-working-container" } diff --git a/tests/inspect.bats b/tests/inspect.bats index f3e96827e2..a0e9a35b3c 100644 --- a/tests/inspect.bats +++ b/tests/inspect.bats @@ -14,26 +14,38 @@ load helpers } @test "inspect" { - cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine) - run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" alpine-image - - buildah_version=$(buildah --version | awk '{ print $3 }') - out1=$(buildah inspect --format '{{.OCIv1.Config}}' alpine) - out2=$(buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image | sed "s/io.buildah.version:${buildah_version}//g") - - [ "$out1" != "" ] - [ "$out1" = "$out2" ] - - imageid=$(buildah images -q alpine-image) - containerid=$(buildah containers -q) - - out3=$(buildah inspect --format '{{.OCIv1.Config}}' $containerid) - out4=$(buildah inspect --type image --format '{{.OCIv1.Config}}' $imageid) - [ "$out3" = "$out1" ] - [ "$out4" = "$out1" ] - - buildah rm $cid - buildah rmi alpine-image alpine + run_buildah from --quiet --pull --signature-policy ${TESTSDIR}/policy.json alpine + cid=$output + run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" alpine-image + + # e.g. { map[] [PATH=/....] [] [/bin/sh] map[] map[] } + run_buildah inspect --format '{{.OCIv1.Config}}' alpine + expect_output --substring "map.*PATH=.*/bin/sh.*map" + inspect_basic=$output + + # Now inspect the committed image. Output should be _mostly_ the same... + run_buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image + inspect_after_commit=$output + + # ...except that at some point in November 2019 buildah-inspect started + # including version. Strip it out, + buildah_version=$(buildah --version | awk '{ print $3 }') + inspect_cleaned=$(echo "$inspect_after_commit" | sed "s/io.buildah.version:${buildah_version}//g") + expect_output --from="$inspect_cleaned" "$inspect_basic" + + imageid=$(buildah images -q alpine-image) + containerid=$(buildah containers -q) + + # This one should not include buildah version + run_buildah inspect --format '{{.OCIv1.Config}}' $containerid + expect_output "$inspect_basic" + + # This one should. + run_buildah inspect --type image --format '{{.OCIv1.Config}}' $imageid + expect_output "$inspect_after_commit" + + buildah rm $cid + buildah rmi alpine-image alpine } @test "inspect-config-is-json" { diff --git a/tests/tag.bats b/tests/tag.bats index 06c4b721f8..7caceefcf0 100644 --- a/tests/tag.bats +++ b/tests/tag.bats @@ -13,13 +13,20 @@ load helpers } @test "tag by id" { - buildah pull --signature-policy ${TESTSDIR}/policy.json busybox - id=$(buildah images -q busybox) + run_buildah pull --quiet --signature-policy ${TESTSDIR}/policy.json busybox + id=$output + + # Tag by ID, then make a container from that tag run_buildah tag $id busybox1 - run_buildah from busybox1 - run_buildah mount busybox1-working-container - run_buildah unmount busybox1-working-container + run_buildah from busybox1 # gives us busybox1-working-container + + # The from-name should be busybox1, but ID should be same as pulled image + run_buildah inspect --format '{{ .FromImage }}' busybox1-working-container + expect_output "localhost/busybox1:latest" + run_buildah inspect --format '{{ .FromImageID }}' busybox1-working-container + expect_output $id + + # Clean up run_buildah rm busybox1-working-container run_buildah rmi busybox1 - run_buildah inspect --type image busybox }