Skip to content

Commit

Permalink
remove multi-arch.bash but 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 Aug 5, 2020
1 parent f668854 commit 922e507
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 106 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- name: "fedora32"
before_install:
- sudo ./script/install-vagrant.sh
- make .download_test_images
- ln -sf Vagrantfile.fedora32 Vagrantfile
- sudo vagrant up && sudo mkdir -p /root/.ssh && sudo sh -c "vagrant ssh-config >> /root/.ssh/config"
script:
Expand All @@ -39,6 +40,7 @@ jobs:
- name: "centos7"
before_install:
- sudo ./script/install-vagrant.sh
- make .download_test_images
- ln -sf Vagrantfile.centos7 Vagrantfile
- sudo vagrant up && sudo mkdir -p /root/.ssh && sudo sh -c "vagrant ssh-config >> /root/.ssh/config"
script:
Expand All @@ -62,6 +64,10 @@ services:
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y libseccomp-dev
- 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
- GO111MODULE=off go get -u golang.org/x/lint/golint
- GO111MODULE=off go get -u github.com/vbatts/git-validation
- env | grep TRAVIS_
Expand Down
26 changes: 2 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,9 @@ 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
ADD tests/integration/testdata/debian.tar /debian
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CONTAINER_ENGINE := docker
GO := go
export CONTAINER_ENGINE

PREFIX ?= $(DESTDIR)/usr/local
BINDIR := $(PREFIX)/sbin
Expand Down Expand Up @@ -58,9 +59,13 @@ lint:
man:
man/md2man-all.sh

runcimage:
runcimage: | .download_test_images
$(CONTAINER_ENGINE) build $(CONTAINER_ENGINE_BUILD_FLAGS) -t $(RUNC_IMAGE) .

.download_test_images:
make -C tests/integration/testdata/
ln -sf tests/integration/testdata/ "$@"

test: unittest integration rootlessintegration

localtest: localunittest localintegration localrootlessintegration
Expand All @@ -72,7 +77,7 @@ unittest: runcimage
-v $(CURDIR):/go/src/$(PROJECT) \
$(RUNC_IMAGE) make localunittest TESTFLAGS=$(TESTFLAGS)

localunittest: all
localunittest: all | .download_test_images
$(GO) test $(MOD_VENDOR) -timeout 3m -tags "$(BUILDTAGS)" $(TESTFLAGS) -v ./...

integration: runcimage
Expand All @@ -82,7 +87,7 @@ integration: runcimage
-v $(CURDIR):/go/src/$(PROJECT) \
$(RUNC_IMAGE) make localintegration TESTPATH=$(TESTPATH)

localintegration: all
localintegration: all | .download_test_images
bats -t tests/integration$(TESTPATH)

rootlessintegration: runcimage
Expand All @@ -92,7 +97,7 @@ rootlessintegration: runcimage
-e ROOTLESS_TESTPATH \
$(RUNC_IMAGE) make localrootlessintegration

localrootlessintegration: all
localrootlessintegration: all | .download_test_images
tests/rootless.sh

shell: runcimage
Expand All @@ -116,6 +121,7 @@ clean:
rm -f contrib/cmd/recvtty/recvtty
rm -rf release
rm -rf man/man8
make -C tests/integration/testdata/ clean

validate:
script/validate-gofmt
Expand Down
9 changes: 2 additions & 7 deletions Vagrantfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ Vagrant.configure("2") do |config|
# install Go
curl -fsSL "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" | tar Cxz /usr/local
# Install umoci
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
# install bats
git clone https://github.com/bats-core/bats-core
cd bats-core
Expand All @@ -52,8 +48,7 @@ EOF
useradd -u2000 -m -d/home/rootless -s/bin/bash rootless
# Add busybox for libcontainer/integration tests
. /vagrant/tests/integration/multi-arch.bash \
&& mkdir /busybox \
&& curl -fsSL $(get_busybox) | tar xfJC - /busybox
mkdir /busybox
tar --exclude './dev/*' -C /busybox -xf /vagrant/tests/integration/testdata/busybox.tar
SHELL
end
14 changes: 5 additions & 9 deletions Vagrantfile.fedora32
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@ EOF
cat /root/rootless.key.pub >> /home/rootless/.ssh/authorized_keys
chown -R rootless.rootless /home/rootless
# Install umoci
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
# Add busybox for libcontainer/integration tests
. /vagrant/tests/integration/multi-arch.bash \
&& mkdir /busybox /debian \
&& curl -fsSL $(get_busybox) | tar xfJC - /busybox \
&& get_and_extract_debian /debian
# Add busybox and debian for libcontainer/integration tests
for dist in busybox debian; do
mkdir /$dist
tar --exclude './dev/*' -C /${dist} -xf /vagrant/tests/integration/testdata/${dist}.tar
done
# Delegate cgroup v2 controllers to rootless user via --systemd-cgroup
mkdir -p /etc/systemd/system/user@.service.d
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 @@ -420,11 +418,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 image does not exist"
exit 1
fi
tar --exclude './dev/*' -C "$BUSYBOX_BUNDLE"/rootfs -xf "$BUSYBOX_IMAGE"
cd "$BUSYBOX_BUNDLE"
Expand All @@ -435,6 +431,10 @@ function setup_hello() {
setup_recvtty
run mkdir "$HELLO_BUNDLE"
run mkdir "$HELLO_BUNDLE"/rootfs
if [ ! -e "$HELLO_IMAGE" ]; then
echo "hello-world image does not exist"
exit 2
fi
tar --exclude './dev/*' -C "$HELLO_BUNDLE"/rootfs -xf "$HELLO_IMAGE"
cd "$HELLO_BUNDLE"
runc_spec
Expand All @@ -449,17 +449,14 @@ function setup_debian() {

setup_recvtty
run mkdir "$DEBIAN_BUNDLE"

if [ ! -d "$DEBIAN_ROOTFS/rootfs" ]; then
get_and_extract_debian "$DEBIAN_BUNDLE"
run mkdir "$DEBIAN_BUNDLE"/rootfs
if [ ! -e "$DEBIAN_IMAGE" ]; then
echo "debian image does not exist"
exit 3
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
1 change: 1 addition & 0 deletions tests/integration/hooks.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function setup() {

teardown_debian
setup_debian
update_config '.root.readonly |= false' $DEBIAN_BUNDLE
}

function teardown() {
Expand Down
44 changes: 0 additions & 44 deletions tests/integration/multi-arch.bash

This file was deleted.

11 changes: 11 additions & 0 deletions tests/integration/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TEST_IMAGES := debian busybox hello-world
CONTAINER_ENGINE ?= docker

download_images:
$(foreach image, $(TEST_IMAGES),$(shell ./download_oci_image.sh $image))
chmod a+r $(foreach image, $(TEST_IMAGES), $(image).tar)

clean:
-rm *.tar

.PHONY: download_images clean
12 changes: 12 additions & 0 deletions tests/integration/testdata/download_oci_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

IMAGE_TAR="$1".tar

case $(go env GOARCH) in
arm64)
skopeo copy docker://arm64v8/$1:latest "$IMAGE_TAR"
;;
*)
skopeo copy docker://amd64/$1:latest "$IMAGE_TAR"
;;
esac

0 comments on commit 922e507

Please sign in to comment.