Skip to content

Commit e561a8e

Browse files
committed
CI: test template://docker
Signed-off-by: Akihiro Suda <[email protected]>
1 parent f10a6d2 commit e561a8e

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

.cirrus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ task:
4646
TEMPLATE: archlinux.yaml
4747
TEMPLATE: opensuse.yaml
4848
TEMPLATE: experimental/net-user-v2.yaml
49+
TEMPLATE: docker.yaml
4950
lima_cache:
5051
fingerprint_script: uname -s ; cat templates/$TEMPLATE
5152
folder: /home/testuser/.cache/lima

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Distro:
2727
Container engines:
2828
- [`apptainer.yaml`](./apptainer.yaml): Apptainer
2929
- [`apptainer-rootful.yaml`](./apptainer-rootful.yaml): Apptainer (rootful)
30-
- [`docker.yaml`](./docker.yaml): Docker
30+
- [`docker.yaml`](./docker.yaml): Docker
3131
- [`docker-rootful.yaml`](./docker-rootful.yaml): Docker (rootful)
3232
- [`podman.yaml`](./podman.yaml): Podman
3333
- [`podman-rootful.yaml`](./podman-rootful.yaml): Podman (rootful)

hack/test-templates.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ limactl validate "$FILE"
1919
# --cpus=1 is needed for running vz on GHA: https://github.com/lima-vm/lima/pull/1511#issuecomment-1574937888
2020
LIMACTL_CREATE=(limactl create --tty=false --cpus=1 --memory=1)
2121

22+
CONTAINER_ENGINE="nerdctl"
23+
2224
declare -A CHECKS=(
2325
["systemd"]="1"
2426
["systemd-strict"]="1"
2527
["mount-home"]="1"
26-
["containerd-user"]="1"
28+
["container-engine"]="1"
2729
["restart"]="1"
2830
# snapshot tests are too flaky (especially with archlinux)
2931
["snapshot-online"]=""
@@ -38,7 +40,7 @@ case "$NAME" in
3840
"alpine")
3941
WARNING "Alpine does not support systemd"
4042
CHECKS["systemd"]=
41-
CHECKS["containerd-user"]=
43+
CHECKS["container-engine"]=
4244
;;
4345
"k3s")
4446
ERROR "File \"$FILE\" is not testable with this script"
@@ -62,6 +64,9 @@ case "$NAME" in
6264
CHECKS["port-forwards"]=""
6365
CHECKS["user-v2"]=1
6466
;;
67+
"docker")
68+
CONTAINER_ENGINE="docker"
69+
;;
6570
esac
6671

6772
if limactl ls -q | grep -q "$NAME"; then
@@ -172,33 +177,33 @@ fi
172177
nginx_image="ghcr.io/stargz-containers/nginx:1.19-alpine-org"
173178
alpine_image="ghcr.io/containerd/alpine:3.14.0"
174179

175-
if [[ -n ${CHECKS["containerd-user"]} ]]; then
180+
if [[ -n ${CHECKS["container-engine"]} ]]; then
176181
INFO "Run a nginx container with port forwarding 127.0.0.1:8080"
177182
set -x
178-
if ! limactl shell "$NAME" nerdctl info; then
183+
if ! limactl shell "$NAME" $CONTAINER_ENGINE info; then
179184
limactl shell "$NAME" sudo cat /var/log/cloud-init-output.log
180-
ERROR '"nerdctl info" failed'
185+
ERROR "\"${CONTAINER_ENGINE} info\" failed"
181186
exit 1
182187
fi
183-
limactl shell "$NAME" nerdctl pull --quiet ${nginx_image}
184-
limactl shell "$NAME" nerdctl run -d --name nginx -p 127.0.0.1:8080:80 ${nginx_image}
188+
limactl shell "$NAME" $CONTAINER_ENGINE pull --quiet ${nginx_image}
189+
limactl shell "$NAME" $CONTAINER_ENGINE run -d --name nginx -p 127.0.0.1:8080:80 ${nginx_image}
185190

186191
timeout 3m bash -euxc "until curl -f --retry 30 --retry-connrefused http://127.0.0.1:8080; do sleep 3; done"
187192

188-
limactl shell "$NAME" nerdctl rm -f nginx
193+
limactl shell "$NAME" $CONTAINER_ENGINE rm -f nginx
189194
set +x
190195
if [[ -n ${CHECKS["mount-home"]} ]]; then
191-
hometmp="$HOME/lima-nerdctl-test-tmp"
196+
hometmp="$HOME/lima-container-engine-test-tmp"
192197
# test for https://github.com/lima-vm/lima/issues/187
193198
INFO "Testing home bind mount (\"$hometmp\")"
194199
rm -rf "$hometmp"
195200
mkdir -p "$hometmp"
196201
defer "rm -rf \"$hometmp\""
197202
set -x
198-
limactl shell "$NAME" nerdctl pull --quiet ${alpine_image}
203+
limactl shell "$NAME" $CONTAINER_ENGINE pull --quiet ${alpine_image}
199204
echo "random-content-${RANDOM}" >"$hometmp/random"
200205
expected="$(cat "$hometmp/random")"
201-
got="$(limactl shell "$NAME" nerdctl run --rm -v "$hometmp/random":/mnt/foo ${alpine_image} cat /mnt/foo)"
206+
got="$(limactl shell "$NAME" $CONTAINER_ENGINE run --rm -v "$hometmp/random":/mnt/foo ${alpine_image} cat /mnt/foo)"
202207
INFO "$hometmp/random: expected=${expected}, got=${got}"
203208
if [ "$got" != "$expected" ]; then
204209
ERROR "Home directory is not shared?"
@@ -225,8 +230,8 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
225230
fi
226231
"${scriptdir}/test-port-forwarding.pl" "${NAME}"
227232

228-
if [[ -n ${CHECKS["containerd-user"]} || ${NAME} == "alpine" ]]; then
229-
INFO "Testing that 'nerdctl run' binds to 0.0.0.0 by default and is forwarded to the host"
233+
if [[ -n ${CHECKS["container-engine"]} || ${NAME} == "alpine" ]]; then
234+
INFO "Testing that \"${CONTAINER_ENGINE} run\" binds to 0.0.0.0 by default and is forwarded to the host"
230235
if [ "$(uname)" = "Darwin" ]; then
231236
# macOS runners seem to use `localhost` as the hostname, so the perl lookup just returns `127.0.0.1`
232237
hostip=$(system_profiler SPNetworkDataType -json | jq -r 'first(.SPNetworkDataType[] | select(.ip_address) | .ip_address) | first')
@@ -245,9 +250,9 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
245250
rm nerdctl-full.tgz
246251
sudo="sudo"
247252
fi
248-
limactl shell "$NAME" $sudo nerdctl info
249-
limactl shell "$NAME" $sudo nerdctl pull --quiet ${nginx_image}
250-
limactl shell "$NAME" $sudo nerdctl run -d --name nginx -p 8888:80 ${nginx_image}
253+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE info
254+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE pull --quiet ${nginx_image}
255+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE run -d --name nginx -p 8888:80 ${nginx_image}
251256

252257
timeout 3m bash -euxc "until curl -f --retry 30 --retry-connrefused http://${hostip}:8888; do sleep 3; done"
253258
fi

0 commit comments

Comments
 (0)