Skip to content

Commit

Permalink
Merge pull request #9491 from edsantiago/testimage_multiarch
Browse files Browse the repository at this point in the history
system test image: build it multiarch
  • Loading branch information
openshift-merge-robot committed Feb 25, 2021
2 parents b220d6c + bee21f1 commit bde1d3f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 19 deletions.
4 changes: 2 additions & 2 deletions test/system/030-run.bats
Expand Up @@ -139,7 +139,7 @@ echo $rand | 0 | $rand
is "$output" "" "--pull=never [present]: no output"

# Now test with a remote image which we don't have present (the 00 tag)
NONLOCAL_IMAGE="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:00000000"
NONLOCAL_IMAGE="$PODMAN_NONLOCAL_IMAGE_FQN"

run_podman 125 run --pull=never $NONLOCAL_IMAGE true
is "$output" "Error: unable to find a name and tag match for $NONLOCAL_IMAGE in repotags: no such image" "--pull=never [with image not present]: error"
Expand Down Expand Up @@ -175,7 +175,7 @@ echo $rand | 0 | $rand
# 'run --rmi' deletes the image in the end unless it's used by another container
@test "podman run --rmi" {
# Name of a nonlocal image. It should be pulled in by the first 'run'
NONLOCAL_IMAGE="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:00000000"
NONLOCAL_IMAGE="$PODMAN_NONLOCAL_IMAGE_FQN"
run_podman 1 image exists $NONLOCAL_IMAGE

# Run a container, without --rm; this should block subsequent --rmi
Expand Down
4 changes: 3 additions & 1 deletion test/system/070-build.bats
Expand Up @@ -305,8 +305,10 @@ Cmd[0] | /bin/mydefaultcmd
Cmd[1] | $s_echo
WorkingDir | $workdir
Labels.$label_name | $label_value
Labels.\"io.buildah.version\" | $buildah_version
"
# FIXME: 2021-02-24: Fixed in buildah #3036; reenable this once podman
# vendors in a newer buildah!
# Labels.\"io.buildah.version\" | $buildah_version

parse_table "$tests" | while read field expect; do
actual=$(jq -r ".[0].Config.$field" <<<"$output")
Expand Down
52 changes: 37 additions & 15 deletions test/system/build-testimage
Expand Up @@ -12,6 +12,9 @@
# still need a fedora image for that.
#

# Buildah binary
BUILDAH=${BUILDAH:-buildah}

# Tag for this new image
YMD=$(date +%Y%m%d)

Expand Down Expand Up @@ -58,7 +61,8 @@ chmod 755 pause
# - check for updates @ https://hub.docker.com/_/alpine
# busybox-extras provides httpd needed in 500-networking.bats
cat >Containerfile <<EOF
FROM docker.io/library/alpine:3.12.0
ARG ARCH=please-override-arch
FROM docker.io/\${ARCH}/alpine:3.12.0
RUN apk add busybox-extras
ADD testimage-id pause /home/podman/
LABEL created_by=$create_script
Expand All @@ -69,26 +73,44 @@ EOF

# --squash-all : needed by 'tree' test in 070-build.bats
podman rmi -f testimage &> /dev/null || true
podman build --squash-all -t testimage .

# We need to use buildah because (as of 2021-02-23) only buildah has --manifest
# and because Dan says arch emulation is not currently working on podman
# (no further details).
# Arch emulation on Fedora requires the qemu-user-static package.
for arch in amd64 ppc64le s390x;do
${BUILDAH} bud \
--arch=$arch \
--build-arg ARCH=$arch \
--manifest=testimage \
--squash \
.
done

# Clean up
cd /tmp
rm -rf $tmpdir

# Tag and push to quay.
podman tag testimage quay.io/libpod/testimage:$YMD
podman push quay.io/libpod/testimage:$YMD
# Tag image and push (all arches) to quay.
remote_tag=quay.io/libpod/testimage:$YMD
podman tag testimage ${remote_tag}
${BUILDAH} manifest push --all ${remote_tag} docker://${remote_tag}

# Side note: there should always be a testimage tagged ':00000000'
# (eight zeroes) in the same location; this is used by tests which
# need to pull a non-locally-cached image. This image will rarely
# if ever need to change, nor in fact does it even have to be a
# copy of this testimage since all we use it for is 'true'.
# Side note: there should always be a testimage tagged ':0000000<X>'
# (eight digits, zero-padded sequence ID) in the same location; this is
# used by tests which need to pull a non-locally-cached image. This
# image will rarely if ever need to change, nor in fact does it even
# have to be a copy of this testimage since all we use it for is 'true'.
# However, it does need to be multiarch :-(
#
# As of 2020-09-02 it is simply busybox, because it is super small:
# As of 2021-02-24 it is simply busybox, because it is super small,
# but it's complicated because of multiarch:
#
# podman pull docker.io/library/busybox:1.32.0
# podman tag docker.io/library/busybox:1.32.0 \
# quay.io/libpod/testimage:00000000
# podman push quay.io/libpod/testimage:00000000
# img=quay.io/libpod/testimage:00000001
# buildah manifest create $img
# for arch in amd64 ppc64le s390x;do
# buildah pull --arch $arch docker.io/$arch/busybox:1.32.0
# buildah manifest add $img docker.io/$arch/busybox:1.32.0
# done
# buildah manifest push --all $img docker://$img
#
7 changes: 6 additions & 1 deletion test/system/helpers.bash
Expand Up @@ -7,9 +7,14 @@ PODMAN=${PODMAN:-podman}
PODMAN_TEST_IMAGE_REGISTRY=${PODMAN_TEST_IMAGE_REGISTRY:-"quay.io"}
PODMAN_TEST_IMAGE_USER=${PODMAN_TEST_IMAGE_USER:-"libpod"}
PODMAN_TEST_IMAGE_NAME=${PODMAN_TEST_IMAGE_NAME:-"testimage"}
PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20200929"}
PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20210223"}
PODMAN_TEST_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG"

# Remote image that we *DO NOT* fetch or keep by default; used for testing pull
# This changed from 0 to 1 on 2021-02-24 due to multiarch considerations; it
# should change only very rarely.
PODMAN_NONLOCAL_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:00000001"

# Because who wants to spell that out each time?
IMAGE=$PODMAN_TEST_IMAGE_FQN

Expand Down

0 comments on commit bde1d3f

Please sign in to comment.