Skip to content

Commit

Permalink
remove multi-arch.bash and use docker to get images directly
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
  • Loading branch information
XiaodongLoong committed Jul 7, 2020
1 parent 819fcc6 commit 3678286
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 91 deletions.
26 changes: 2 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
33 changes: 15 additions & 18 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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() {
Expand Down
44 changes: 0 additions & 44 deletions tests/integration/multi-arch.bash

This file was deleted.

0 comments on commit 3678286

Please sign in to comment.