@@ -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
2020LIMACTL_CREATE=(limactl create --tty=false --cpus=1 --memory=1)
2121
22+ CONTAINER_ENGINE=" nerdctl"
23+
2224declare -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" )
3941WARNING " Alpine does not support systemd"
4042CHECKS[" systemd" ]=
41- CHECKS[" containerd-user " ]=
43+ CHECKS[" container-engine " ]=
4244;;
4345" k3s" )
4446ERROR " File \" $FILE \" is not testable with this script"
@@ -62,6 +64,9 @@ case "$NAME" in
6264CHECKS[" port-forwards" ]=" "
6365CHECKS[" user-v2" ]=1
6466;;
67+ " docker" )
68+ CONTAINER_ENGINE=" docker"
69+ ;;
6570esac
6671
6772if limactl ls -q | grep -q " $NAME " ; then
172177nginx_image=" ghcr.io/stargz-containers/nginx:1.19-alpine-org"
173178alpine_image=" ghcr.io/containerd/alpine:3.14.0"
174179
175- if [[ -n ${CHECKS["containerd-user "]} ]]; then
180+ if [[ -n ${CHECKS["container-engine "]} ]]; then
176181INFO " Run a nginx container with port forwarding 127.0.0.1:8080"
177182set -x
178- if ! limactl shell " $NAME " nerdctl info; then
183+ if ! limactl shell " $NAME " $CONTAINER_ENGINE info; then
179184limactl shell " $NAME " sudo cat /var/log/cloud-init-output.log
180- ERROR ' "nerdctl info" failed'
185+ ERROR " \" ${CONTAINER_ENGINE} info\ " failed"
181186exit 1
182187fi
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
186191timeout 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
189194set +x
190195if [[ -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
193198INFO " Testing home bind mount (\" $hometmp \" )"
194199rm -rf " $hometmp "
195200mkdir -p " $hometmp "
196201defer " rm -rf \" $hometmp \" "
197202set -x
198- limactl shell " $NAME " nerdctl pull --quiet ${alpine_image}
203+ limactl shell " $NAME " $CONTAINER_ENGINE pull --quiet ${alpine_image}
199204echo " random-content-${RANDOM} " > " $hometmp /random"
200205expected=" $( 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) "
202207INFO " $hometmp /random: expected=${expected} , got=${got} "
203208if [ " $got " != " $expected " ]; then
204209ERROR " Home directory is not shared?"
@@ -225,8 +230,8 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
225230fi
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"
230235if [ " $( uname) " = " Darwin" ]; then
231236# macOS runners seem to use `localhost` as the hostname, so the perl lookup just returns `127.0.0.1`
232237hostip=$( system_profiler SPNetworkDataType -json | jq -r ' first(.SPNetworkDataType[] | select(.ip_address) | .ip_address) | first' )
@@ -245,9 +250,9 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
245250rm nerdctl-full.tgz
246251sudo=" sudo"
247252fi
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
252257timeout 3m bash -euxc " until curl -f --retry 30 --retry-connrefused http://${hostip} :8888; do sleep 3; done"
253258fi
0 commit comments