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 Jul 15, 2020
1 parent b7d8f3b commit cda7423
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 110 deletions.
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
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,28 @@ lint:
man:
man/md2man-all.sh

runcimage:
runcimage: | .busybox .hello-world .debian
$(CONTAINER_ENGINE) build $(CONTAINER_ENGINE_BUILD_FLAGS) -t $(RUNC_IMAGE) .

.hello-world:
$(CONTAINER_ENGINE) export $(shell $(CONTAINER_ENGINE) create hello-world) -o $(CURDIR)/tests/integration/testdata/hello-world.tar
chmod a+r $(CURDIR)/tests/integration/testdata/hello-world.tar
touch "$@"

.busybox:
$(CONTAINER_ENGINE) export $(shell $(CONTAINER_ENGINE) create busybox) -o $(CURDIR)/tests/integration/testdata/busybox.tar
chmod a+r $(CURDIR)/tests/integration/testdata/busybox.tar
touch "$@"

.debian:
$(CONTAINER_ENGINE) export $(shell $(CONTAINER_ENGINE) create debian) -o $(CURDIR)/tests/integration/testdata/debian.tar
chmod a+r $(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 +88,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 +98,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 +108,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
16 changes: 8 additions & 8 deletions Vagrantfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Vagrant.configure("2") do |config|
yum install -y -q epel-release
(cd /etc/yum.repos.d && curl -O https://copr.fedorainfracloud.org/coprs/adrian/criu-el7/repo/epel-7/adrian-criu-el7-epel-7.repo)
yum install -y -q gcc git iptables jq libseccomp-devel make skopeo criu
# install docker-ce
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
yum clean all
# 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 @@ -51,9 +51,9 @@ EOF
# Add a user for rootless tests
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
systemctl start docker
mkdir /busybox /debian
docker export $(docker create busybox) | tar -C /busybox/ -xvf -
docker export $(docker create debian) | tar -C /debian/ -xvf -
SHELL
end
30 changes: 19 additions & 11 deletions Vagrantfile.fedora32
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,22 @@ install iptables gcc make golang-go libseccomp-devel bats jq git-core criu skope
ts run
EOF
done
dnf clean all
arch=$(arch)
tee /etc/yum.repos.d/docker-ce.repo << EOF
[docker-ce-stable]
name=Docker CE Stable - \$arch
baseurl=https://download.docker.com/linux/fedora/31/\$arch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/fedora/gpg
EOF
dnf makecache
dnf install -y docker-ce docker-ce-cli containerd.io
systemctl enable --now docker
usermod -aG docker $(whoami)
newgrp docker
dnf clean all
# Add a user for rootless tests
useradd -u2000 -m -d/home/rootless -s/bin/bash rootless
Expand All @@ -36,16 +50,6 @@ 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
# Delegate cgroup v2 controllers to rootless user via --systemd-cgroup
mkdir -p /etc/systemd/system/user@.service.d
cat > /etc/systemd/system/user@.service.d/delegate.conf << EOF
Expand All @@ -55,5 +59,9 @@ EOF
Delegate=cpu cpuset io memory pids
EOF
systemctl daemon-reload
systemctl start docker
mkdir /busybox /debian
docker export $(docker create busybox) | tar -C /busybox/ -xvf -
docker export $(docker create debian) | tar -C /debian/ -xvf -
SHELL
end
34 changes: 16 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 images 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 images 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,15 @@ 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 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
update_config '.root.readonly |= false'
}

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 cda7423

Please sign in to comment.