diff --git a/Dockerfile b/Dockerfile index b1511121e69..292493e9ffd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,33 +67,11 @@ RUN mkdir -p /usr/src/criu \ && cd - \ && rm -rf /usr/src/criu -# install skopeo -RUN echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_Unstable/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list \ - && wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_Unstable/Release.key -O- | sudo apt-key add - \ - && apt-get update \ - && apt-get install -y --no-install-recommends skopeo \ - && rm -rf /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list \ - && apt-get clean \ - && rm -rf /var/cache/apt /var/lib/apt/lists/*; - -# install umoci -RUN curl -o /usr/local/bin/umoci -fsSL https://github.com/opencontainers/umoci/releases/download/v0.4.5/umoci.amd64 \ - && chmod +x /usr/local/bin/umoci - COPY script/tmpmount / WORKDIR /go/src/github.com/opencontainers/runc ENTRYPOINT ["/tmpmount"] # setup a playground for us to spawn containers in -COPY tests/integration/multi-arch.bash tests/integration/ -ENV ROOTFS /busybox -RUN mkdir -p "${ROOTFS}" -RUN . tests/integration/multi-arch.bash \ - && curl -fsSL `get_busybox` | tar xfJC - "${ROOTFS}" - -ENV DEBIAN_ROOTFS /debian -RUN mkdir -p "${DEBIAN_ROOTFS}" -RUN . tests/integration/multi-arch.bash \ - && get_and_extract_debian "$DEBIAN_ROOTFS" +ADD tests/integration/testdata/busybox.tar /busybox -COPY . . +ADD tests/integration/testdata/debian.tar /debian diff --git a/Makefile b/Makefile index aa7d95a5e0c..5445f4c1aa2 100644 --- a/Makefile +++ b/Makefile @@ -58,12 +58,25 @@ lint: man: man/md2man-all.sh -runcimage: +runcimage: | .busybox .hello-world .debian $(CONTAINER_ENGINE) build $(CONTAINER_ENGINE_BUILD_FLAGS) -t $(RUNC_IMAGE) . +.hello-world: + docker export $(shell docker create hello-world) -o $(CURDIR)/tests/integration/testdata/hello-world.tar + touch "$@" + +.busybox: + docker export $(shell docker create busybox) -o $(CURDIR)/tests/integration/testdata/busybox.tar + touch "$@" + +.debian: + docker export $(shell docker create debian) -o $(CURDIR)/tests/integration/testdata/debian.tar + touch "$@" + test: unittest integration rootlessintegration -localtest: localunittest localintegration localrootlessintegration +localtest: | all .busybox .hello-world .debian + make localunittest localintegration localrootlessintegration unittest: runcimage $(CONTAINER_ENGINE) run $(CONTAINER_ENGINE_RUN_FLAGS) \ @@ -72,7 +85,7 @@ unittest: runcimage -v $(CURDIR):/go/src/$(PROJECT) \ $(RUNC_IMAGE) make localunittest TESTFLAGS=$(TESTFLAGS) -localunittest: all +localunittest: | all .busybox .hello-world .debian $(GO) test $(MOD_VENDOR) -timeout 3m -tags "$(BUILDTAGS)" $(TESTFLAGS) -v ./... integration: runcimage @@ -82,7 +95,7 @@ integration: runcimage -v $(CURDIR):/go/src/$(PROJECT) \ $(RUNC_IMAGE) make localintegration TESTPATH=$(TESTPATH) -localintegration: all +localintegration: | all .busybox .hello-world .debian bats -t tests/integration$(TESTPATH) rootlessintegration: runcimage @@ -92,7 +105,7 @@ rootlessintegration: runcimage -e ROOTLESS_TESTPATH \ $(RUNC_IMAGE) make localrootlessintegration -localrootlessintegration: all +localrootlessintegration: | all .busybox .hello-world .debian tests/rootless.sh shell: runcimage diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index b62b6ba491c..15f0d13b40d 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -3,8 +3,6 @@ # Root directory of integration tests. INTEGRATION_ROOT=$(dirname "$(readlink -f "$BASH_SOURCE")") -. ${INTEGRATION_ROOT}/multi-arch.bash - RUNC="${INTEGRATION_ROOT}/../../runc" RECVTTY="${INTEGRATION_ROOT}/../../contrib/cmd/recvtty/recvtty" GOPATH="$(mktemp -d --tmpdir runc-integration-gopath.XXXXXX)" @@ -13,15 +11,15 @@ GOPATH="$(mktemp -d --tmpdir runc-integration-gopath.XXXXXX)" TESTDATA="${INTEGRATION_ROOT}/testdata" # Busybox image -BUSYBOX_IMAGE="$BATS_TMPDIR/busybox.tar" +BUSYBOX_IMAGE="$TESTDATA/busybox.tar" BUSYBOX_BUNDLE="$BATS_TMPDIR/busyboxtest" # hello-world in tar format -HELLO_FILE=`get_hello` -HELLO_IMAGE="$TESTDATA/$HELLO_FILE" +HELLO_IMAGE="$TESTDATA/hello-world.tar" HELLO_BUNDLE="$BATS_TMPDIR/hello-world" # debian image +DEBIAN_IMAGE="$TESTDATA/debian.tar" DEBIAN_BUNDLE="$BATS_TMPDIR/debiantest" # CRIU PATH @@ -415,11 +413,9 @@ function setup_busybox() { setup_recvtty run mkdir "$BUSYBOX_BUNDLE" run mkdir "$BUSYBOX_BUNDLE"/rootfs - if [ -e "/testdata/busybox.tar" ]; then - BUSYBOX_IMAGE="/testdata/busybox.tar" - fi if [ ! -e $BUSYBOX_IMAGE ]; then - curl -o $BUSYBOX_IMAGE -sSL `get_busybox` + echo "busybox images does not exist" + exit 1 fi tar --exclude './dev/*' -C "$BUSYBOX_BUNDLE"/rootfs -xf "$BUSYBOX_IMAGE" cd "$BUSYBOX_BUNDLE" @@ -430,6 +426,10 @@ function setup_hello() { setup_recvtty run mkdir "$HELLO_BUNDLE" run mkdir "$HELLO_BUNDLE"/rootfs + if [ ! -e "$HELLO_IMAGE" ]; then + echo "hello-world images does not exist" + exit 2 + fi tar --exclude './dev/*' -C "$HELLO_BUNDLE"/rootfs -xf "$HELLO_IMAGE" cd "$HELLO_BUNDLE" runc_spec @@ -444,17 +444,14 @@ function setup_debian() { setup_recvtty run mkdir "$DEBIAN_BUNDLE" - - if [ ! -d "$DEBIAN_ROOTFS/rootfs" ]; then - get_and_extract_debian "$DEBIAN_BUNDLE" + rum mkdir "$DEBIAN_BUNDLE"/rootfs + if [ ! -e "$DEBIAN_IMAGE" ]; then + echo "debian images does not exist" + exit 2 fi - - # Use the cached version - if [ ! -d "$DEBIAN_BUNDLE/rootfs" ]; then - cp -r "$DEBIAN_ROOTFS"/* "$DEBIAN_BUNDLE/" - fi - + tar --exclude './dev/*' -C "$DEBIAN_BUNDLE"/rootfs -xf "$DEBIAN_IMAGE" cd "$DEBIAN_BUNDLE" + runc_spec } function teardown_running_container() { diff --git a/tests/integration/multi-arch.bash b/tests/integration/multi-arch.bash deleted file mode 100644 index c0519146b0b..00000000000 --- a/tests/integration/multi-arch.bash +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -get_busybox() { - case $(go env GOARCH) in - arm64) - echo 'https://github.com/docker-library/busybox/raw/dist-arm64v8/glibc/busybox.tar.xz' - ;; - *) - echo 'https://github.com/docker-library/busybox/raw/dist-amd64/glibc/busybox.tar.xz' - ;; - esac -} - -get_hello() { - case $(go env GOARCH) in - arm64) - echo 'hello-world-aarch64.tar' - ;; - *) - echo 'hello-world.tar' - ;; - esac -} - -get_and_extract_debian() { - tmp=$(mktemp -d) - cd "$tmp" - - debian="debian:3.11.6" - - case $(go env GOARCH) in - arm64) - skopeo copy docker://arm64v8/debian:buster "oci:$debian" - ;; - *) - skopeo copy docker://amd64/debian:buster "oci:$debian" - ;; - esac - - args="$([ -z "${ROOTLESS_TESTPATH+x}" ] && echo "--rootless")" - umoci unpack $args --image "$debian" "$1" - - cd - - rm -rf "$tmp" -}