diff --git a/scripts/tests/ygg-smoke-runtime.test.sh b/scripts/tests/ygg-smoke-runtime.test.sh index 7f33d60..5ffa329 100644 --- a/scripts/tests/ygg-smoke-runtime.test.sh +++ b/scripts/tests/ygg-smoke-runtime.test.sh @@ -51,7 +51,12 @@ echo "podman loaded=${FAKE_ENGINE_LOADED:-0} $*" >>"$FAKE_CALLS" a="$*" case "$1" in image) [ "$FAKE_NO_IMAGE" = "${3:-}" ] && exit 1; exit 0 ;; - images) echo "localhost/ygg-stack-x:abc" ;; + images) + # The real engine lists every stack image, newest first, and dies of SIGPIPE when the reader has gone. + if [ "${FAKE_MANY_IMAGES:-}" = 1 ]; then + echo "localhost/ygg-stack-${3#reference=localhost/ygg-stack-}:newest"; sleep 0.3 + for i in 1 2 3 4 5 6 7 8; do echo "localhost/ygg-stack-x:old$i" 2>/dev/null || exit 141; done + else echo "localhost/ygg-stack-x:abc"; fi ;; inspect) echo "10.89.0.7" ;; logs) echo "start: weed stopped" ;; run) @@ -147,6 +152,14 @@ check "the key is read as app" bash -c "grep -Eq 'exec --user app smoke-runtime- check "signed requests send the unsigned-payload header" inlog "x-amz-content-sha256: UNSIGNED-PAYLOAD" check "no-route has a positive control that connects" bash -c "grep -Eq 'exec smoke-runtime-product-[0-9]+ timeout 5 bash -c .*/dev/tcp/10.89.0.7/3000' '$T/calls'" +# The stack images found by name: the engine lists several, and the newest is taken (the reader must not close the +# pipe early: under pipefail, podman's SIGPIPE would stop the script before its first line). +: >"$T/calls"; : >"$T/store" +FAKE_MANY_IMAGES=1 run "$SCRIPT" --folder "$D" --yggdrasil "$Y" --image task:img +check "with several stack images and no --api-image, a healthy run exits 0" test "$rc" = 0 +check "... and the api release is built in the newest helheim-go image" inlog "localhost/ygg-stack-helheim-go:newest sh /src/release.sh" +check "... and the web release in the newest midgard-react image" inlog "localhost/ygg-stack-midgard-react:newest sh /src/release.sh" + # One thing broken at a time. FAKE_UNSIGNED_CODE=200 runit; check "an unsigned PUT that is accepted fails" bash -c "[ $rc = 1 ] && grep -q 'FAIL unsigned' '$T/out'" FAKE_PUT_CODE=500 runit; check "a signed PUT that fails, fails" bash -c "[ $rc = 1 ] && grep -q 'FAIL signed' '$T/out'" diff --git a/scripts/ygg-smoke-runtime.sh b/scripts/ygg-smoke-runtime.sh index 8215ab8..da1245a 100755 --- a/scripts/ygg-smoke-runtime.sh +++ b/scripts/ygg-smoke-runtime.sh @@ -57,7 +57,9 @@ if [ "${YGG_ENGINE_CHECK:-1}" = 1 ]; then eval "$engine_env" fi command -v podman >/dev/null 2>&1 || fail "podman is not installed" -stack() { podman images --filter "reference=localhost/ygg-stack-$1" --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | head -n 1; } +# The newest image is the first line. sed reads every line: head would close the pipe early, and podman's SIGPIPE +# would then fail the pipeline (pipefail) and stop the script with 141 and no message. +stack() { podman images --filter "reference=localhost/ygg-stack-$1" --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | sed -n 1p; } [ -n "$api_image" ] || api_image="$(stack helheim-go)" [ -n "$web_image" ] || web_image="$(stack midgard-react)" [ -n "$api_image" ] || fail "no sandbox image of helheim-go; build it with 'ygg sandbox build --realm helheim-go' or pass --api-image"