Check offline imports in the smoke tests

With the network down, a request that goes through the system proxy cannot
reach 127.0.0.1, which is how a healthy engine looked unreachable. Both smoke
tests now start under a proxy pointed at a black hole, import a TIFF through the
real upload and preview path, and assert the launcher and app window bypass
proxies.
This commit is contained in:
2026-12-01 12:45:04 +00:00
parent 0525e496e0
commit f1f96f1f10
3 changed files with 139 additions and 0 deletions
+72
View File
@@ -256,6 +256,78 @@ else
check '--status reports stopped' 1
fi
say ''
say 'Offline import (proxy unreachable)'
# Every proxy variable points at a black hole, so a request that consults the
# system proxy fails instead of reaching 127.0.0.1. That is the shape of the
# bug where an import with the network unplugged reported that it could not
# reach the engine: the engine was fine, the request was routed through a proxy.
PROXY_VARS=(HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy GLOBAL_AGENT_HTTP_PROXY)
for var in "${PROXY_VARS[@]}"; do export "$var=http://10.255.255.1:9"; done
unset NO_PROXY no_proxy
check 'app window bypasses proxies' "$(grep -q -- '--no-proxy-server' "$BUNDLE/luminary" && echo 0 || echo 1)"
"$BUNDLE/luminary" >"$WORK_DIR/offline-start.txt" 2>&1
offline_start=$?
check 'launcher starts with the proxy unreachable' "$offline_start" "$(head -n 1 "$WORK_DIR/offline-start.txt")"
OFFLINE_URL=""
if [ -f "$LUMINARY_DATA/runtime.json" ]; then
OFFLINE_URL="http://127.0.0.1:$("$NODE" -p "JSON.parse(require('fs').readFileSync('$LUMINARY_DATA/runtime.json','utf8')).port")"
check 'runtime.json written offline' 0
else
check 'runtime.json written offline' 1 "$LUMINARY_DATA/runtime.json"
fi
if [ -n "$OFFLINE_URL" ]; then
code="$(http GET "$OFFLINE_URL/api/health")"
check 'health answers offline' $([ "$code" = "200" ] && echo 0 || echo 1) "HTTP $code"
# An import is an upload, a decode in the bundle and a preview read. TIFF
# takes the same server path as camera raw, so this exercises the real thing
# without shipping a raw fixture in the bundle.
"$NODE" -e '
const path = require("node:path");
const sharp = require(path.join(process.argv[1], "app", "node_modules", "sharp"));
sharp({ create: { width: 8, height: 8, channels: 3, background: { r: 200, g: 100, b: 50 } } })
.tiff()
.toFile(process.argv[2])
.then(() => process.exit(0))
.catch(() => process.exit(1));
' "$BUNDLE" "$WORK_DIR/offline-smoke.tiff"
check 'prepared a TIFF to import' "$?"
upload_status="$("$NODE" -e '
const fs = require("node:fs");
const [url, file, out] = process.argv.slice(-3);
fetch(url, { method: "POST", headers: { "Content-Type": "image/tiff" }, body: fs.readFileSync(file) })
.then(async (r) => { fs.writeFileSync(out, await r.text()); process.stdout.write(String(r.status)); })
.catch(() => process.stdout.write("0"));
' "$OFFLINE_URL/api/photos/smoke-offline/original?name=offline-smoke.tiff&mime=image%2Ftiff" "$WORK_DIR/offline-smoke.tiff" "$BODY")"
# A new upload is created (201); replacing one answers 200.
case "$upload_status" in
200|201) upload_ok=0 ;;
*) upload_ok=1 ;;
esac
check 'import upload accepted offline' "$upload_ok" "HTTP $upload_status"
preview="$(jget previewUrl)"
check 'decoded proxy offered offline' $([ -n "$preview" ] && echo 0 || echo 1) "$preview"
if [ -n "$preview" ]; then
case "$preview" in
http*) preview_url="$preview" ;;
*) preview_url="$OFFLINE_URL$preview" ;;
esac
code="$(http GET "$preview_url")"
check 'preview readable offline' $([ "$code" = "200" ] && echo 0 || echo 1) "HTTP $code"
fi
fi
"$BUNDLE/luminary" --stop >/dev/null 2>&1
check 'stopped the offline run' 0
for var in "${PROXY_VARS[@]}"; do unset "$var"; done
say ''
say 'Window'
skip 'app window opens' 'visual check; the launcher opened nothing during this run'