2018-06-11 14:55:51 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
2018-09-03 19:20:52 +08:00
|
|
|
@test "commit-flags-order-verification" {
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 commit cnt1 --tls-verify
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "--tls-verify"
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 commit cnt1 -q
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "-q"
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 commit cnt1 -f=docker --quiet --creds=bla:bla
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "-f=docker"
|
|
|
|
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 commit cnt1 --creds=bla:bla
|
2018-09-03 19:20:52 +08:00
|
|
|
check_options_flag_err "--creds=bla:bla"
|
|
|
|
}
|
|
|
|
|
2018-06-11 14:55:51 +08:00
|
|
|
@test "commit" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
2019-04-02 05:56:29 +08:00
|
|
|
run_buildah images alpine-image
|
2018-06-11 14:55:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit format test" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-oci
|
|
|
|
run_buildah commit --format docker --disable-compression=false --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-docker
|
2018-06-11 14:55:51 +08:00
|
|
|
|
2020-08-12 04:46:36 +08:00
|
|
|
run_buildah inspect --type=image --format '{{.Manifest}}' alpine-image-oci
|
|
|
|
mediatype=$(jq -r '.layers[0].mediaType' <<<"$output")
|
|
|
|
expect_output --from="$mediatype" "application/vnd.oci.image.layer.v1.tar"
|
|
|
|
run_buildah inspect --type=image --format '{{.Manifest}}' alpine-image-docker
|
|
|
|
mediatype=$(jq -r '.layers[1].mediaType' <<<"$output")
|
|
|
|
expect_output --from="$mediatype" "application/vnd.docker.image.rootfs.diff.tar.gzip"
|
2018-06-11 14:55:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit quiet test" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah commit --iidfile /dev/null --signature-policy ${TESTSDIR}/policy.json -q $cid alpine-image
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output ""
|
2018-06-11 14:55:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit rm test" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json --rm $cid alpine-image
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 rm $cid
|
2020-11-10 19:58:31 +08:00
|
|
|
expect_output --substring "error removing container \"alpine-working-container\": container not known"
|
2018-06-11 14:55:51 +08:00
|
|
|
}
|
2018-06-22 23:20:02 +08:00
|
|
|
|
|
|
|
@test "commit-alternate-storage" {
|
Move away from using docker.io
November 2020, docker.io started restricting unauthenticated
image pulls. Try to work around this by using a custom
registries.conf file.
For the most part this means copying images from docker.io
to quay.io, via:
$ skopeo copy --all docker://docker.io/library/img:tag \
docker://quay.io/libpod/img:tag
...for the following values of 'img:tag':
busybox:musl
centos:7 centos:8 centos:latest
composer:latest
debian:latest ubuntu:latest
docker:latest
php:7.2
For each of those, it was necessary to go into the quay.io
GUI, click the image name, click the settings (gear) icon
at bottom left, click 'Make public', and confirm.
This process did not work in four instances, which required
special-casing:
commit.bats : openshift/hello-openshift did not match the
mirroring rules; I switched to alpine instead.
Nalin confirmed on IRC that there was no magic
reason for requiring hello-openshift.
pull.bats : change a SHA. AFAICT there was nothing magic
about the SHA being used, it was just a
convenient one for purposes of testing
pull-by-sha. I simply switched to the SHA
of an image present on quay.
registries.bats : was assuming that fedora-minimal shortname
would be pulled from fedora registry.
Unfortunately, we have a copy on quay
(for podman tests), so that's what we
pull by shortname, and it does not match
the SHA of the fedoraproject.org one.
Solution: pull by tag (fedora-minimal:32)
and hope that nobody ever mirrors that one
on quay.
run.bats : another pull-by-SHA, but this time I changed
the SHA to a named tag, and skopeo copy'd
that image from docker.io to the given name
on quay. This time there _is_ something
magic about that particular SHA (it's an
image with a specific volume quirk) but
there's no actual reason to reference it
by SHA - we simply did so because we have
no control over tag names on docker.io.
Since we control tag names on quay.io,
it's easy and more maintainable to give
this image a descriptive tag.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-08 06:36:43 +08:00
|
|
|
_prefetch alpine
|
2018-06-22 23:20:02 +08:00
|
|
|
echo FROM
|
Move away from using docker.io
November 2020, docker.io started restricting unauthenticated
image pulls. Try to work around this by using a custom
registries.conf file.
For the most part this means copying images from docker.io
to quay.io, via:
$ skopeo copy --all docker://docker.io/library/img:tag \
docker://quay.io/libpod/img:tag
...for the following values of 'img:tag':
busybox:musl
centos:7 centos:8 centos:latest
composer:latest
debian:latest ubuntu:latest
docker:latest
php:7.2
For each of those, it was necessary to go into the quay.io
GUI, click the image name, click the settings (gear) icon
at bottom left, click 'Make public', and confirm.
This process did not work in four instances, which required
special-casing:
commit.bats : openshift/hello-openshift did not match the
mirroring rules; I switched to alpine instead.
Nalin confirmed on IRC that there was no magic
reason for requiring hello-openshift.
pull.bats : change a SHA. AFAICT there was nothing magic
about the SHA being used, it was just a
convenient one for purposes of testing
pull-by-sha. I simply switched to the SHA
of an image present on quay.
registries.bats : was assuming that fedora-minimal shortname
would be pulled from fedora registry.
Unfortunately, we have a copy on quay
(for podman tests), so that's what we
pull by shortname, and it does not match
the SHA of the fedoraproject.org one.
Solution: pull by tag (fedora-minimal:32)
and hope that nobody ever mirrors that one
on quay.
run.bats : another pull-by-SHA, but this time I changed
the SHA to a named tag, and skopeo copy'd
that image from docker.io to the given name
on quay. This time there _is_ something
magic about that particular SHA (it's an
image with a specific volume quirk) but
there's no actual reason to reference it
by SHA - we simply did so because we have
no control over tag names on docker.io.
Since we control tag names on quay.io,
it's easy and more maintainable to give
this image a descriptive tag.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-08 06:36:43 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
cid=$output
|
2018-06-22 23:20:02 +08:00
|
|
|
echo COMMIT
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid "containers-storage:[vfs@${TESTDIR}/root2+${TESTDIR}/runroot2]newimage"
|
2018-06-22 23:20:02 +08:00
|
|
|
echo FROM
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah --storage-driver vfs --root ${TESTDIR}/root2 --runroot ${TESTDIR}/runroot2 from --signature-policy ${TESTSDIR}/policy.json newimage
|
2018-06-22 23:20:02 +08:00
|
|
|
}
|
2018-08-22 04:33:36 +08:00
|
|
|
|
|
|
|
@test "commit-rejected-name" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2020-04-16 21:48:43 +08:00
|
|
|
run_buildah 125 commit --signature-policy ${TESTSDIR}/policy.json $cid ThisNameShouldBeRejected
|
2019-04-05 23:59:54 +08:00
|
|
|
expect_output --substring "must be lower"
|
2018-08-22 04:33:36 +08:00
|
|
|
}
|
2019-04-04 02:57:55 +08:00
|
|
|
|
|
|
|
@test "commit-no-empty-created-by" {
|
2019-04-05 23:59:54 +08:00
|
|
|
if ! python3 -c 'import json, sys' 2> /dev/null ; then
|
2019-04-04 02:57:55 +08:00
|
|
|
skip "python interpreter with json module not found"
|
|
|
|
fi
|
|
|
|
target=new-image
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-04-04 02:57:55 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah config --created-by "untracked actions" $cid
|
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid ${target}
|
|
|
|
run_buildah inspect --format '{{.Config}}' ${target}
|
2019-04-04 02:57:55 +08:00
|
|
|
config="$output"
|
2019-04-05 23:59:54 +08:00
|
|
|
run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config"
|
2019-04-04 02:57:55 +08:00
|
|
|
echo "$output"
|
|
|
|
[ "${status}" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "untracked actions"
|
2019-04-04 02:57:55 +08:00
|
|
|
|
2019-12-12 02:28:27 +08:00
|
|
|
run_buildah config --created-by "" $cid
|
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid ${target}
|
|
|
|
run_buildah inspect --format '{{.Config}}' ${target}
|
2019-04-04 02:57:55 +08:00
|
|
|
config="$output"
|
2019-04-05 23:59:54 +08:00
|
|
|
run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config"
|
2019-04-04 02:57:55 +08:00
|
|
|
echo "$output"
|
|
|
|
[ "${status}" -eq 0 ]
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "/bin/sh"
|
2019-04-04 02:57:55 +08:00
|
|
|
}
|
2019-03-21 01:06:29 +08:00
|
|
|
|
|
|
|
@test "commit-no-name" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-03-21 01:06:29 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid
|
|
|
|
}
|
2019-11-06 11:57:38 +08:00
|
|
|
|
2020-12-22 00:19:56 +08:00
|
|
|
@test "commit should fail with nonexistent authfile" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2020-12-22 00:19:56 +08:00
|
|
|
run_buildah 125 commit --authfile /tmp/nonexistent --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
2019-11-06 11:57:38 +08:00
|
|
|
}
|
2019-11-13 00:50:21 +08:00
|
|
|
|
|
|
|
@test "commit-builder-identity" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
2019-11-13 00:50:21 +08:00
|
|
|
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah --version
|
|
|
|
local -a output_fields=($output)
|
|
|
|
buildah_version=${output_fields[2]}
|
2019-11-13 00:50:21 +08:00
|
|
|
|
2019-12-12 07:21:51 +08:00
|
|
|
run_buildah inspect --format '{{ index .Docker.Config.Labels "io.buildah.version"}}' alpine-image
|
|
|
|
expect_output "$buildah_version"
|
2019-11-13 00:50:21 +08:00
|
|
|
}
|
2019-11-20 04:23:14 +08:00
|
|
|
|
|
|
|
@test "commit-parent-id" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull --signature-policy ${TESTSDIR}/policy.json alpine
|
|
|
|
cid=$output
|
|
|
|
run_buildah inspect --format '{{.FromImageID}}' $cid
|
|
|
|
iid=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json --format docker $cid alpine-image
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah inspect --format '{{.Docker.Parent}}' alpine-image
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "sha256:$iid" "alpine-image -> .Docker.Parent"
|
2019-11-20 04:23:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit-container-id" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch alpine
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah from --quiet --pull --signature-policy ${TESTSDIR}/policy.json alpine
|
2019-12-12 07:21:51 +08:00
|
|
|
|
|
|
|
# There is exactly one container. Get its ID.
|
|
|
|
run_buildah containers --format '{{.ContainerID}}'
|
2019-12-12 03:11:08 +08:00
|
|
|
cid=$output
|
2019-12-12 07:21:51 +08:00
|
|
|
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json --format docker $cid alpine-image
|
2019-12-12 03:11:08 +08:00
|
|
|
run_buildah inspect --format '{{.Docker.Container}}' alpine-image
|
2019-12-12 07:21:51 +08:00
|
|
|
expect_output "$cid" "alpine-image -> .Docker.Container"
|
2019-11-06 18:20:33 +08:00
|
|
|
}
|
2019-10-28 16:25:42 +08:00
|
|
|
|
|
|
|
@test "commit with name" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-12-04 02:18:24 +08:00
|
|
|
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"
|
2019-10-28 16:25:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit to docker-distribution" {
|
2019-12-09 21:45:52 +08:00
|
|
|
_prefetch busybox
|
2019-12-12 04:03:37 +08:00
|
|
|
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name busyboxc busybox
|
2019-10-28 16:25:42 +08:00
|
|
|
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
|
2019-11-20 04:23:14 +08:00
|
|
|
}
|
2020-04-17 23:48:14 +08:00
|
|
|
|
|
|
|
@test "commit encrypted local oci image" {
|
|
|
|
_prefetch busybox
|
|
|
|
mkdir ${TESTDIR}/tmp
|
|
|
|
openssl genrsa -out ${TESTDIR}/tmp/mykey.pem 1024
|
|
|
|
openssl rsa -in ${TESTDIR}/tmp/mykey.pem -pubout > ${TESTDIR}/tmp/mykey.pub
|
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json busybox
|
|
|
|
cid=$output
|
|
|
|
run_buildah commit --iidfile /dev/null --signature-policy ${TESTSDIR}/policy.json --encryption-key jwe:${TESTDIR}/tmp/mykey.pub -q $cid oci:${TESTDIR}/tmp/busybox_enc
|
|
|
|
imgtype -show-manifest oci:${TESTDIR}/tmp/busybox_enc | grep "+encrypted"
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit oci encrypt to registry" {
|
|
|
|
_prefetch busybox
|
|
|
|
mkdir ${TESTDIR}/tmp
|
|
|
|
openssl genrsa -out ${TESTDIR}/tmp/mykey.pem 1024
|
|
|
|
openssl rsa -in ${TESTDIR}/tmp/mykey.pem -pubout > ${TESTDIR}/tmp/mykey.pub
|
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json busybox
|
|
|
|
cid=$output
|
|
|
|
run_buildah commit --iidfile /dev/null --tls-verify=false --creds testuser:testpassword --signature-policy ${TESTSDIR}/policy.json --encryption-key jwe:${TESTDIR}/tmp/mykey.pub -q $cid docker://localhost:5000/buildah/busybox_encrypted:latest
|
|
|
|
# this test, just checks the ability to commit an image to a registry
|
|
|
|
# there is no good way to test the details of the image unless with ./buildah pull, test will be in pull.bats
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
}
|
2020-08-11 17:28:41 +08:00
|
|
|
|
|
|
|
@test "commit omit-timestamp" {
|
|
|
|
_prefetch busybox
|
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json busybox
|
|
|
|
cid=$output
|
|
|
|
run_buildah run $cid touch /test
|
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json --omit-timestamp -q $cid omit
|
|
|
|
run_buildah inspect --format '{{ .Docker.Created }}' omit
|
|
|
|
expect_output --substring "1970-01-01"
|
|
|
|
run_buildah inspect --format '{{ .OCIv1.Created }}' omit
|
|
|
|
expect_output --substring "1970-01-01"
|
|
|
|
|
|
|
|
|
2020-08-27 04:56:57 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json omit
|
|
|
|
cid=$output
|
|
|
|
run_buildah run $cid ls -l /test
|
|
|
|
expect_output --substring "1970"
|
|
|
|
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "commit timestamp" {
|
|
|
|
_prefetch busybox
|
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json busybox
|
|
|
|
cid=$output
|
|
|
|
run_buildah run $cid touch /test
|
|
|
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json --timestamp 0 -q $cid omit
|
|
|
|
run_buildah inspect --format '{{ .Docker.Created }}' omit
|
|
|
|
expect_output --substring "1970-01-01"
|
|
|
|
run_buildah inspect --format '{{ .OCIv1.Created }}' omit
|
|
|
|
expect_output --substring "1970-01-01"
|
|
|
|
|
|
|
|
|
2020-08-11 17:28:41 +08:00
|
|
|
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json omit
|
|
|
|
cid=$output
|
|
|
|
run_buildah run $cid ls -l /test
|
|
|
|
expect_output --substring "1970"
|
|
|
|
|
|
|
|
rm -rf ${TESTDIR}/tmp
|
|
|
|
}
|