Skip to content

Commit 3372ae7

Browse files
committed
hack/test-templates.sh: Add "ssh-over-vsock"
Signed-off-by: Norio Nomura <[email protected]>
1 parent 05fd090 commit 3372ae7

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

hack/test-templates.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ declare -A CHECKS=(
6161
["param-env-variables"]=""
6262
["set-user"]=""
6363
["preserve-env"]="1"
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"
@@ -346,14 +348,40 @@ if [[ -n ${CHECKS["preserve-env"]} ]]; then
346348
"${scriptdir}"/test-preserve-env.sh "$NAME"
347349
fi
348350

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

353381
if [[ -n ${CHECKS["container-engine"]} ]]; then
354382
sudo=""
355383
# Currently WSL2 machines only support privileged engine. This requirement might be lifted in the future.
356-
if [[ "$(limactl ls --json "${NAME}" | jq -r .vmType)" == "wsl2" ]]; then
384+
if [[ "$(limactl ls "${NAME}" --yq .vmType)" == "wsl2" ]]; then
357385
sudo="sudo"
358386
fi
359387
INFO "Run a nginx container with port forwarding 127.0.0.1:8080"
@@ -433,7 +461,7 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
433461
sudo="sudo"
434462
fi
435463
# Currently WSL2 machines only support privileged engine. This requirement might be lifted in the future.
436-
if [[ "$(limactl ls --json "${NAME}" | jq -r .vmType)" == "wsl2" ]]; then
464+
if [[ "$(limactl ls "${NAME}" --yq .vmType)" == "wsl2" ]]; then
437465
sudo="sudo"
438466
fi
439467
limactl shell "$NAME" $sudo $CONTAINER_ENGINE info
@@ -625,7 +653,7 @@ if [[ -n ${CHECKS["clone"]} ]]; then
625653
limactl start "$NAME"
626654
fi
627655

628-
if [[ $NAME == "fedora" && "$(limactl ls --json "$NAME" | jq -r .vmType)" == "vz" ]]; then
656+
if [[ $NAME == "fedora" && "$(limactl ls "${NAME}" --yq .vmType)" == "vz" ]]; then
629657
"${scriptdir}"/test-selinux.sh "$NAME"
630658
fi
631659

0 commit comments

Comments
 (0)