#!/usr/bin/env bash # Smoke test for the sm121 add-on image (specs/tech-architecture/ # ha-addon-recipe-repos.md, step 3): run the entrypoint with a `file://` # recipe repo (mounted) + a token, and assert the dashboard answers on # 3100 (curl /api/state). # # scripts/smoke-addon.sh [image] (default sm121-addon:latest) set -euo pipefail cd "$(dirname "$0")/.." IMG="${1:-sm121-addon:latest}" TOKEN=smoke-test # A minimal `file://` recipe repo, mounted read-only at /repos. It lives # under target/ (gitignored) so it sits on a volume the docker VM shares # — colima only mounts /Volumes here; a $HOME tmpdir would mount empty. REPO="$(pwd)/target/smoke-addon-repo" rm -rf "$REPO"; mkdir -p "$REPO" git init -q "$REPO" mkdir -p "$REPO/recipes/demo" echo 'engine = "vllm"' > "$REPO/recipes/demo/recipe.toml" git -C "$REPO" add -A git -C "$REPO" -c user.email=t@sm121.test -c user.name=sm121-test commit -qm init CID="$(docker run -d \ -p 3100:3100 \ -v "$REPO":/repos:ro \ -e SM121_RECIPE_REPOS='[{"url":"file:///repos"}]' \ -e SM121_SSH_USER=u \ -e SM121_WEB_TOKEN="$TOKEN" \ "$IMG")" trap 'docker rm -f "$CID" >/dev/null 2>&1 || true; rm -rf "$REPO"' EXIT # Wait for the dashboard (up to 30 s — the first sync is a clone). ok="" for _ in $(seq 1 30); do if curl -sf -H "Authorization: Bearer $TOKEN" \ http://127.0.0.1:3100/api/state >/dev/null 2>&1; then ok=1 break fi sleep 1 done echo "--- container log (tail) ---" docker logs "$CID" 2>&1 | tail -5 if [ -n "$ok" ]; then echo "--- /api/state (first 200 chars) ---" curl -sf -H "Authorization: Bearer $TOKEN" http://127.0.0.1:3100/api/state | head -c 200 echo echo "smoke OK: the add-on dashboard answered on 3100" else echo "smoke FAILED: no answer on 3100" >&2 exit 1 fi