-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This simplifies and optimizes getting container images used for tests. Currently, we have three different ways of getting images: 1. (for hello-world) the image is in this repo under tests/integration/testdata. 2. (for busybox) download it from github (the repo that is used for preparing official Docker image) using curl. 3. (for debian) download from Docker hub, using skopeo and umoci. To further complicate things, we have to do this downloading in multiple scenarios (at least 4): locally, in github CI, from Dockefile, inside a Vagrant VM. For each scenario, we have to install skopeo and umoci, and those two are not yet universally available for all the distros that we use. Yet another complication is those images are used for tests/integration (bats-driven tests) as well as for libcontainer/integration (go tests). The tests in libcontainer/integration rely on busybox being available from /busybox, and the bats tests just download the images to a temporary location during every run. It is also hard to support CI for other architectures, because all the machinery for preparing images is so complicated. This commit is an attempt to simplify and optimize getting images, mostly by getting rid of skopeo and umoci dependencies, but also by moving the download logic into one small shell script, which is used from all the places. Benefits: - images (if not present) are only downloaded once; - same images are used for both kind of tests (go and bats); - same images are used for local and inside-docker tests (because source directory is mounted into container); - the download logic is located within 1 simple shell script. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
- Loading branch information
Showing
14 changed files
with
124 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# This script checks if container images needed for tests (currently | ||
# busybox and Debian 10 "Buster") are available locally, and downloads | ||
# them to testdata directory if not. Its output is suitable for use | ||
# from shell via eval (see helpers.bash for usage example). | ||
# | ||
# XXX: Latest available images are fetched. Theoretically, | ||
# this can bring some instability in case of a broken image. | ||
# In this case, images will need to be pinned to a checksum | ||
# on a per-image and per-architecture basis. | ||
|
||
set -e -u -o pipefail | ||
|
||
# Root directory of integration tests. | ||
INTEGRATION_ROOT=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") | ||
# Test data path. | ||
TESTDATA="${INTEGRATION_ROOT}/testdata" | ||
# Sanity check: $TESTDATA directory must exist. | ||
if [ ! -d "$TESTDATA" ]; then | ||
echo "Bad TESTDATA directory: $TESTDATA. Aborting" >&2 | ||
exit 1 | ||
fi | ||
|
||
function get() { | ||
local dest="$1" url="$2" | ||
|
||
[ -e "$dest" ] && return | ||
|
||
# Sanity check: $TESTDATA directory must be writable. | ||
if [ ! -w "$TESTDATA" ]; then | ||
echo "TESTDATA directory ($TESTDATA) not writable. Aborting" >&2 | ||
exit 1 | ||
fi | ||
|
||
curl -o "$dest" -fsSL "$url" | ||
} | ||
|
||
arch=$(go env GOARCH) | ||
# Convert from GOARCH to whatever the URLs below are using. | ||
case $arch in | ||
arm64) | ||
arch=arm64v8 | ||
;; | ||
esac | ||
|
||
# busybox | ||
BUSYBOX_IMAGE="$TESTDATA/busybox-${arch}.tar.xz" | ||
get "$BUSYBOX_IMAGE" \ | ||
"https://github.com/docker-library/busybox/raw/dist-${arch}/stable/glibc/busybox.tar.xz" | ||
echo "BUSYBOX_IMAGE=$BUSYBOX_IMAGE" | ||
|
||
# debian | ||
DEBIAN_IMAGE="$TESTDATA/debian-${arch}.tar.xz" | ||
get "$DEBIAN_IMAGE" \ | ||
"https://github.com/debuerreotype/docker-debian-artifacts/raw/dist-${arch}/buster/rootfs.tar.xz" | ||
echo "DEBIAN_IMAGE=$DEBIAN_IMAGE" | ||
|
||
# hello-world is local, no need to download. | ||
HELLO_IMAGE="$TESTDATA/hello-world-${arch}.tar" | ||
echo "HELLO_IMAGE=$HELLO_IMAGE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.