mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 14:13:58 +08:00
5ab0588432
This simplifies and optimizes getting container images used for tests. Currently, we have three different ways of getting images: 1. (for hello-world) the image is in this repo under tests/integration/testdata. 2. (for busybox) download it from github (the repo that is used for preparing official Docker image) using curl. 3. (for debian) download from Docker hub, using skopeo and umoci. To further complicate things, we have to do this downloading in multiple scenarios (at least 4): locally, in github CI, from Dockefile, inside a Vagrant VM. For each scenario, we have to install skopeo and umoci, and those two are not yet universally available for all the distros that we use. Yet another complication is those images are used for tests/integration (bats-driven tests) as well as for libcontainer/integration (go tests). The tests in libcontainer/integration rely on busybox being available from /busybox, and the bats tests just download the images to a temporary location during every run. It is also hard to support CI for other architectures, because all the machinery for preparing images is so complicated. This commit is an attempt to simplify and optimize getting images, mostly by getting rid of skopeo and umoci dependencies, but also by moving the download logic into one small shell script, which is used from all the places. Benefits: - images (if not present) are only downloaded once; - same images are used for both kind of tests (go and bats); - same images are used for local and inside-docker tests (because source directory is mounted into container); - the download logic is located within 1 simple shell script. [v2: fix eval; more doc to get-images; print URL if curl failed] [v3: use "slim" debian, twice as small] [v4: fix not using $image in setup_bundle] [v5: don't remove TESTDATA from helpers.bash] [v6: add i386 support] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
50 lines
1.5 KiB
Ruby
50 lines
1.5 KiB
Ruby
# -*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
|
|
Vagrant.configure("2") do |config|
|
|
# Fedora box is used for testing cgroup v2 support
|
|
config.vm.box = "fedora/33-cloud-base"
|
|
config.vm.provider :virtualbox do |v|
|
|
v.memory = 2048
|
|
v.cpus = 2
|
|
end
|
|
config.vm.provider :libvirt do |v|
|
|
v.memory = 2048
|
|
v.cpus = 2
|
|
end
|
|
config.vm.provision "shell", inline: <<-SHELL
|
|
set -e -u -o pipefail
|
|
# Work around dnf mirror failures by retrying a few times
|
|
for i in $(seq 0 2); do
|
|
sleep $i
|
|
cat << EOF | dnf -y shell && break
|
|
config exclude kernel,kernel-core
|
|
config install_weak_deps false
|
|
update
|
|
install iptables gcc make golang-go glibc-static libseccomp-devel bats jq git-core criu
|
|
ts run
|
|
EOF
|
|
done
|
|
dnf clean all
|
|
|
|
# Add a user for rootless tests
|
|
useradd -u2000 -m -d/home/rootless -s/bin/bash rootless
|
|
|
|
# Allow root to execute `ssh rootless@localhost` in tests/rootless.sh
|
|
ssh-keygen -t ecdsa -N "" -f /root/rootless.key
|
|
mkdir -m 0700 -p /home/rootless/.ssh
|
|
cat /root/rootless.key.pub >> /home/rootless/.ssh/authorized_keys
|
|
chown -R rootless.rootless /home/rootless
|
|
|
|
# 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
|
|
[Service]
|
|
# default: Delegate=pids memory
|
|
# NOTE: delegation of cpuset requires systemd >= 244 (Fedora >= 32, Ubuntu >= 20.04). cpuset is ignored on Fedora 31.
|
|
Delegate=cpu cpuset io memory pids
|
|
EOF
|
|
systemctl daemon-reload
|
|
SHELL
|
|
end
|