diff options
author | baude <bbaude@redhat.com> | 2017-11-14 09:50:39 -0600 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-11-20 18:11:08 +0000 |
commit | 3e04604dc2619b1502b609083c3b6ecb0949f1d5 (patch) | |
tree | 34adadd2f86a199bb60bacf57fa8febebe9eb4ab /test/helpers.bash | |
parent | 57599f0075ccab859d4158f7ee891b9b971c731f (diff) | |
download | podman-3e04604dc2619b1502b609083c3b6ecb0949f1d5.tar.gz podman-3e04604dc2619b1502b609083c3b6ecb0949f1d5.tar.bz2 podman-3e04604dc2619b1502b609083c3b6ecb0949f1d5.zip |
Use cached images for integration tests
Add alpine and busybox as the two seeded images that can
be put into the tests' storage without the need to pull
it over the network. Add the following to the kpod_TEST.bats
file:
function setup() {
copy_images
}
Also, export several image names for shorter reference:
* BB -> docker.io/library/busybox:latest
* BB_GLIBC -> docker.io/library/busybox:glibc
* ALPINE -> docker.io/library/alpine:latest
* FEDORA_MINIMAL -> registry.fedoraproject.org/fedora-minimal:latest
And finally, there were two pervasive changes I made in
tests:
* Because we use temporary storage, we do not need to rmi at the end of each test
* We no longer need to pull most images because they are added via copy_images
Signed-off-by: baude <bbaude@redhat.com>
Closes: #43
Approved by: mheon
Diffstat (limited to 'test/helpers.bash')
-rw-r--r-- | test/helpers.bash | 83 |
1 files changed, 23 insertions, 60 deletions
diff --git a/test/helpers.bash b/test/helpers.bash index b760ec2cf..3280e70fd 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -64,7 +64,14 @@ if [[ ! -d "/test.dir" ]]; then fi TESTDIR=$(mktemp -p /test.dir -d) -#mount -t tmpfs tmpfs ${TESTDIR} + +declare -A -g IMAGES +IMAGES+=(["alpine"]=docker.io/library/alpine:latest ["busybox"]=docker.io/library/busybox:latest) + +BB_GLIBC="docker.io/library/busybox:glibc" +BB="docker.io/library/busybox:latest" +ALPINE="docker.io/library/alpine:latest" +FEDORA_MINIMAL="registry.fedoraproject.org/fedora-minimal:latest" # kpod pull needs a configuration file for shortname pulls export REGISTRIES_CONFIG_PATH="$INTEGRATION_ROOT/registries.conf" @@ -109,68 +116,18 @@ cp "$CONMON_BINARY" "$TESTDIR/conmon" PATH=$PATH:$TESTDIR -# Make sure we have a copy of the redis:alpine image. -if ! [ -d "$ARTIFACTS_PATH"/redis-image ]; then - mkdir -p "$ARTIFACTS_PATH"/redis-image - if ! "$COPYIMG_BINARY" --import-from=docker://redis:alpine --export-to=dir:"$ARTIFACTS_PATH"/redis-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://redis" - rm -fr "$ARTIFACTS_PATH"/redis-image - exit 1 - fi -fi - -# TODO: remove the code below for pulling redis:alpine using a canonical reference once -# https://github.com/kubernetes-incubator/cri-o/issues/531 is complete and we can -# pull the image using a tagged reference and then subsequently find the image without -# having to explicitly record the canonical reference as one of the image's names -if ! [ -d "$ARTIFACTS_PATH"/redis-image-digest ]; then - mkdir -p "$ARTIFACTS_PATH"/redis-image-digest - if ! "$COPYIMG_BINARY" --import-from=docker://redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b --export-to=dir:"$ARTIFACTS_PATH"/redis-image-digest --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://redis@sha256:03789f402b2ecfb98184bf128d180f398f81c63364948ff1454583b02442f73b" - rm -fr "$ARTIFACTS_PATH"/redis-image-digest - exit 1 - fi -fi - -# Make sure we have a copy of the runcom/stderr-test image. -if ! [ -d "$ARTIFACTS_PATH"/stderr-test ]; then - mkdir -p "$ARTIFACTS_PATH"/stderr-test - if ! "$COPYIMG_BINARY" --import-from=docker://runcom/stderr-test:latest --export-to=dir:"$ARTIFACTS_PATH"/stderr-test --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://stderr-test" - rm -fr "$ARTIFACTS_PATH"/stderr-test - exit 1 - fi -fi - -# Make sure we have a copy of the busybox:latest image. -if ! [ -d "$ARTIFACTS_PATH"/busybox-image ]; then - mkdir -p "$ARTIFACTS_PATH"/busybox-image - if ! "$COPYIMG_BINARY" --import-from=docker://busybox --export-to=dir:"$ARTIFACTS_PATH"/busybox-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://busybox" - rm -fr "$ARTIFACTS_PATH"/busybox-image - exit 1 +for key in ${!IMAGES[@]}; do + if ! [ -d "$ARTIFACTS_PATH"/${key} ]; then + mkdir -p "$ARTIFACTS_PATH"/${key} + if ! "$COPYIMG_BINARY" --import-from=docker://${IMAGES[${key}]} --export-to=dir:"$ARTIFACTS_PATH"/${key} --signature-policy="$INTEGRATION_ROOT"/policy.json ; then + echo "Error pulling docker://${IMAGES[${key}]}" + rm -fr "$ARTIFACTS_PATH"/${key} + exit 1 + fi fi -fi -# Make sure we have a copy of the mrunalp/oom:latest image. -if ! [ -d "$ARTIFACTS_PATH"/oom-image ]; then - mkdir -p "$ARTIFACTS_PATH"/oom-image - if ! "$COPYIMG_BINARY" --import-from=docker://mrunalp/oom --export-to=dir:"$ARTIFACTS_PATH"/oom-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://mrunalp/oom" - rm -fr "$ARTIFACTS_PATH"/oom-image - exit 1 - fi -fi +done -# Make sure we have a copy of the mrunalp/image-volume-test:latest image. -if ! [ -d "$ARTIFACTS_PATH"/image-volume-test-image ]; then - mkdir -p "$ARTIFACTS_PATH"/image-volume-test-image - if ! "$COPYIMG_BINARY" --import-from=docker://mrunalp/image-volume-test --export-to=dir:"$ARTIFACTS_PATH"/image-volume-test-image --signature-policy="$INTEGRATION_ROOT"/policy.json ; then - echo "Error pulling docker://mrunalp/image-volume-test-image" - rm -fr "$ARTIFACTS_PATH"/image-volume-test-image - exit 1 - fi -fi # Communicate with Docker on the host machine. # Should rarely use this. @@ -344,3 +301,9 @@ function cleanup_network_conf() { function temp_sandbox_conf() { sed -e s/\"namespace\":.*/\"namespace\":\ \"$1\",/g "$TESTDATA"/sandbox_config.json > $TESTDIR/sandbox_config_$1.json } + +function copy_images() { + for key in ${!IMAGES[@]}; do + "$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name=${IMAGES[${key}]} --import-from=dir:"$ARTIFACTS_PATH"/${key} --add-name=${IMAGES[${key}]} + done +} |