diff --git a/Makefile b/Makefile index 6a1a3e6c14..8d70c2c418 100644 --- a/Makefile +++ b/Makefile @@ -202,6 +202,10 @@ test-integration: # Helper target to set up SKOPEO_BINARY variable for local test targets +# SKOPEO_BINARY only takes effect on `test-integration-local` and +# `test-system-local` targets. It's not propagated into the container used for `test-integration` and +# `test-system`. These targets will (build and) use skopeo binary at +# ./bin/skopeo. .eval-skopeo-binary: $(if $(SKOPEO_BINARY),,bin/skopeo) $(eval SKOPEO_BINARY := $(or $(SKOPEO_BINARY),./bin/skopeo)) @echo "Testing with $(SKOPEO_BINARY) ..." @@ -226,7 +230,7 @@ test-system: # Primarily intended for CI. test-system-local: .eval-skopeo-binary hack/warn-destructive-tests.sh - bats --tap systemtest + hack/test-system.sh test-unit: # Just call (make test unit-local) here instead of worrying about environment differences @@ -265,8 +269,3 @@ vendor: vendor-in-container: podman run --privileged --rm --env HOME=/root -v $(CURDIR):/src -w /src golang $(MAKE) vendor - -# CAUTION: This is not a replacement for RPMs provided by your distro. -# Only intended to build and test the latest unreleased changes. -rpm: - rpkg local diff --git a/hack/test-system.sh b/hack/test-system.sh new file mode 100755 index 0000000000..4be68e786a --- /dev/null +++ b/hack/test-system.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +# These tests can run in/outside of a container. However, +# not all storage drivers are supported in a container +# environment. Detect this and setup storage when +# running in a container. +# +# Paradoxically (FIXME: clean this up), SKOPEO_CONTAINER_TESTS is set +# both inside a container and without a container (in a CI VM); it actually means +# "it is safe to destructively modify the system for tests". +# +# On a CI VM, we can just use Podman as it is already configured; the changes below, +# to use VFS, are necessary only inside a container, because overlay-inside-overlay +# does not work. So, make these changes conditional on both +# SKOPEO_CONTAINER_TESTS (for acceptability to do destructive modification) and !CI +# (for necessity to adjust for in-container operation) +if ((SKOPEO_CONTAINER_TESTS)) && [[ "$CI" != true ]]; then + if [[ -r /etc/containers/storage.conf ]]; then + echo "MODIFYING existing storage.conf" + sed -i \ + -e 's/^driver\s*=.*/driver = "vfs"/' \ + -e 's/^mountopt/#mountopt/' \ + /etc/containers/storage.conf + else + echo "CREATING NEW storage.conf" + cat >> /etc/containers/storage.conf << EOF +[storage] +driver = "vfs" +runroot = "/run/containers/storage" +graphroot = "/var/lib/containers/storage" +EOF + fi + # The logic of finding the relevant storage.conf file is convoluted + # and in effect differs between Skopeo and Podman, at least in some versions; + # explicitly point at the file we want to use to hopefully avoid that. + export CONTAINERS_STORAGE_CONF=/etc/containers/storage.conf +fi + +bats --tap systemtest