Skip to content

Commit 52d0a92

Browse files
committed
hack/test-templates.sh: Add "ssh-over-vsock"
Signed-off-by: Norio Nomura <norio.nomura@gmail.com> # Conflicts: # hack/test-templates.sh hack/test-templates.sh: avoid using `limactl restart` Signed-off-by: Norio Nomura <norio.nomura@gmail.com> hack/test-templates.sh: change order of tests Signed-off-by: Norio Nomura <norio.nomura@gmail.com> change `grep -iq` to `grep -i` Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
1 parent 43f502a commit 52d0a92

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

hack/test-templates.sh

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ declare -A CHECKS=(
6161
["set-user"]=""
6262
["preserve-env"]="1"
6363
["static-port-forwards"]=""
64+
["ssh-over-vsock"]=""
6465
)
6566

6667
case "$NAME" in
6768
"default")
6869
# CI failure:
6970
# "[hostagent] failed to confirm whether /c/Users/runneradmin [remote] is successfully mounted"
7071
[ "${OS_HOST}" = "Msys" ] && CHECKS["mount-home"]=
72+
[ "${OS_HOST}" = "Darwin" ] && CHECKS["ssh-over-vsock"]="1"
7173
;;
7274
"alpine"*)
7375
WARNING "Alpine does not support systemd"
@@ -341,14 +343,46 @@ if [[ -n ${CHECKS["preserve-env"]} ]]; then
341343
"${scriptdir}"/test-preserve-env.sh "$NAME"
342344
fi
343345

346+
if [[ -n ${CHECKS["ssh-over-vsock"]} ]]; then
347+
if [[ "$(limactl ls "${NAME}" --yq .vmType)" == "vz" ]]; then
348+
INFO "Testing SSH over vsock"
349+
set -x
350+
INFO "Testing LIMA_SSH_OVER_VSOCK=true environment"
351+
limactl stop "${NAME}"
352+
if ! LIMA_SSH_OVER_VSOCK=true limactl start "${NAME}" 2>&1 | grep -i "started vsock forwarder"; then
353+
set +x
354+
diagnose "${NAME}"
355+
ERROR "LIMA_SSH_OVER_VSOCK=true did not enable vsock forwarder"
356+
exit 1
357+
fi
358+
INFO 'Testing LIMA_SSH_OVER_VSOCK="" environment'
359+
limactl stop "${NAME}"
360+
if ! LIMA_SSH_OVER_VSOCK="" limactl start "${NAME}" 2>&1 | grep -i "started vsock forwarder"; then
361+
set +x
362+
diagnose "${NAME}"
363+
ERROR "LIMA_SSH_OVER_VSOCK= did not enable vsock forwarder"
364+
exit 1
365+
fi
366+
INFO "Testing LIMA_SSH_OVER_VSOCK=false environment"
367+
limactl stop "${NAME}"
368+
if ! LIMA_SSH_OVER_VSOCK=false limactl start "${NAME}" 2>&1 | grep -i "skipping detection of SSH server on vsock port"; then
369+
set +x
370+
diagnose "${NAME}"
371+
ERROR "LIMA_SSH_OVER_VSOCK=false did not disable vsock forwarder"
372+
exit 1
373+
fi
374+
set +x
375+
fi
376+
fi
377+
344378
# Use GHCR to avoid hitting Docker Hub rate limit
345379
nginx_image="ghcr.io/stargz-containers/nginx:1.19-alpine-org"
346380
alpine_image="ghcr.io/containerd/alpine:3.14.0"
347381

348382
if [[ -n ${CHECKS["container-engine"]} ]]; then
349383
sudo=""
350384
# Currently WSL2 machines only support privileged engine. This requirement might be lifted in the future.
351-
if [[ "$(limactl ls --json "${NAME}" | jq -r .vmType)" == "wsl2" ]]; then
385+
if [[ "$(limactl ls "${NAME}" --yq .vmType)" == "wsl2" ]]; then
352386
sudo="sudo"
353387
fi
354388
INFO "Run a nginx container with port forwarding 127.0.0.1:8080"
@@ -428,7 +462,7 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
428462
sudo="sudo"
429463
fi
430464
# Currently WSL2 machines only support privileged engine. This requirement might be lifted in the future.
431-
if [[ "$(limactl ls --json "${NAME}" | jq -r .vmType)" == "wsl2" ]]; then
465+
if [[ "$(limactl ls "${NAME}" --yq .vmType)" == "wsl2" ]]; then
432466
sudo="sudo"
433467
fi
434468
limactl shell "$NAME" $sudo $CONTAINER_ENGINE info
@@ -613,7 +647,7 @@ if [[ -n ${CHECKS["clone"]} ]]; then
613647
limactl start "$NAME"
614648
fi
615649

616-
if [[ $NAME == "fedora" && "$(limactl ls --json "$NAME" | jq -r .vmType)" == "vz" ]]; then
650+
if [[ $NAME == "fedora" && "$(limactl ls "${NAME}" --yq .vmType)" == "vz" ]]; then
617651
"${scriptdir}"/test-selinux.sh "$NAME"
618652
fi
619653

0 commit comments

Comments
 (0)