Sanad_Package_3/test_p3.sh

37 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke-test Sanad Package 3. Usage: ./test_p3.sh [host:port] (default 127.0.0.1:8013)
H="${1:-127.0.0.1:8013}"; B="http://$H"; pass=0; fail=0
chk(){ local code
if [ "$1" = GET ]; then code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 8 "$B$2")
else code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 8 -X "$1" "$B$2"); fi
if [ "$code" = "$3" ]; then printf " PASS [%s] %-34s %s\n" "$code" "$1 $2" "$4"; pass=$((pass+1))
else printf " FAIL [%s≠%s] %-30s %s\n" "$code" "$3" "$1 $2" "$4"; fail=$((fail+1)); fi
}
echo "== Sanad P3 smoke test @ $B =="
chk GET /api/health 200 "health"
chk GET /api/package 200 "manifest + license + features"
chk GET /api/p3/api-key 200 "key status (masked)"
chk GET /api/p3/settings 200 "combined settings"
chk GET /api/recognition/state 200 "recognition state"
chk GET /api/zones/ 200 "places / zones list"
chk GET /api/mask/status 200 "LED mask status"
chk GET /api/memory/ 200 "visitor memory list"
chk GET /api/memory/status 200 "memory store status"
chk GET /api/memory/primer 200 "greeting primer"
chk GET /api/live-subprocess/status 200 "conversation status"
chk GET /api/system/info 200 "system info"
chk GET /api/logs/ 200 "logs list"
echo "== $pass passed, $fail failed =="
echo "-- manifest --"
curl -s --max-time 6 "$B/api/package" | python3 -c '
import sys, json
d = json.load(sys.stdin); lic = d.get("license") or {}
print(" package :", d.get("package"))
print(" license :", lic.get("valid"), " packages:", lic.get("packages"))
print(" features:", d.get("features"))
' 2>/dev/null || true
echo "-- memory roundtrip (create -> list -> delete) --"
id=$(curl -s --max-time 6 -X POST "$B/api/memory/" -H 'Content-Type: application/json' -d '{"name":"Test VIP","attributes":{"vip":true},"notes":"smoke"}' | python3 -c "import sys,json;print(json.load(sys.stdin).get('profile',{}).get('id',''))" 2>/dev/null)
echo " created id: ${id:-<none>}"
[ -n "$id" ] && curl -s --max-time 6 -X DELETE "$B/api/memory/$id" >/dev/null && echo " deleted ok"