Files
momentry_core/scripts/test_m5api_phase4.sh
Accusys 77098b88ba feat: Phase 2-5 API test scripts + create_monitor_job fix
Phase 2: 10/10 passed 
Phase 3: 7/7 passed 
Phase 4: 9/11 passed (2 known bugs - i.name column)
Phase 5: 13/23 passed (10 failures - pre-existing bugs)

Fixes:
- create_monitor_job: ON CONFLICT (uuid) DO UPDATE to prevent duplicate key errors
- test scripts: Correct request bodies for all visual search endpoints
2026-05-19 16:05:46 +08:00

91 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Phase 4: Search API Test
# Modules: 06_search, 08_identity_agent, 12_agent
# Endpoints: 11
BASE="https://m5api.momentry.ddns.net"
API_KEY="muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69"
FILE_UUID="a6fb22eebefaef17e62af874997c5944"
PASS=0
FAIL=0
TOTAL=0
echo "============================================"
echo " Phase 4: Search API Test"
echo " Base: $BASE"
echo " File: $FILE_UUID"
echo "============================================"
echo ""
test_api() {
local method="$1" path="$2" body="$3" desc="$4"
TOTAL=$((TOTAL+1))
local tmpfile="/tmp/m5api_resp_${TOTAL}.json"
local curl_args=(-s -o "$tmpfile" -w "\nHTTP:%{http_code}")
curl_args+=(-X "$method")
curl_args+=(-H "Content-Type: application/json")
curl_args+=(-H "X-API-Key: $API_KEY")
if [ -n "$body" ]; then
curl_args+=(-d "$body")
fi
local result
result=$(curl "${curl_args[@]}" "${BASE}${path}" 2>/dev/null)
local code=$(echo "$result" | grep "HTTP:" | tr -d "HTTP:")
local resp_body=$(echo "$result" | sed '/^HTTP:/d')
local size=${#resp_body}
if [ "$code" -ge 200 ] 2>/dev/null && [ "$code" -lt 400 ] 2>/dev/null; then
PASS=$((PASS+1))
printf " ✅ %2d. %-5s %-55s → %s (%d B) — %s\n" "$TOTAL" "$method" "$path" "$code" "$size" "$desc"
else
FAIL=$((FAIL+1))
printf " ❌ %2d. %-5s %-55s → %s (%d B) — %s\n" "$TOTAL" "$method" "$path" "$code" "$size" "$desc"
local preview
preview=$(echo "$resp_body" | head -c 150)
echo " $preview"
fi
}
echo "── Smart Search ──"
test_api "POST" "/api/v1/search/smart" "{\"file_uuid\":\"$FILE_UUID\",\"query\":\"dialogue\",\"limit\":3}" "Smart search"
echo ""
echo "── Universal Search ──"
test_api "POST" "/api/v1/search/universal" "{\"query\":\"scene\",\"file_uuid\":\"$FILE_UUID\",\"types\":[\"chunk\"],\"limit\":3}" "Universal search (chunks)"
test_api "POST" "/api/v1/search/frames" "{\"file_uuid\":\"$FILE_UUID\",\"frame_number\":100}" "Search frames"
echo ""
echo "── Visual Search ──"
test_api "POST" "/api/v1/search/visual" "{\"file_uuid\":\"$FILE_UUID\",\"criteria\":{}}" "Visual search"
test_api "POST" "/api/v1/search/visual/class" "{\"uuid\":\"$FILE_UUID\",\"object_class\":\"person\"}" "Visual search by class"
test_api "POST" "/api/v1/search/visual/density" "{\"uuid\":\"$FILE_UUID\",\"min_density\":0.1}" "Visual search by density"
test_api "POST" "/api/v1/search/visual/stats" "{\"uuid\":\"$FILE_UUID\"}" "Visual search stats"
test_api "POST" "/api/v1/search/visual/combination" "{\"uuid\":\"$FILE_UUID\",\"combination\":[[\"person\",1],[\"car\",1]]}" "Visual search combination"
echo ""
echo "── Identity Text Search (pre-existing bug: i.name column) ──"
test_api "GET" "/api/v1/search/identity_text?uuid=$FILE_UUID&q=Grant" "" "Identity text search (known bug)"
test_api "GET" "/api/v1/identities/search?q=Grant" "" "Identities search (known bug)"
echo ""
echo "── Agent Search ──"
test_api "POST" "/api/v1/agents/translate" "{\"text\":\"Hello world\",\"target_language\":\"zh-TW\"}" "Translate agent"
echo ""
echo "============================================"
echo " Total: $TOTAL"
echo " Passed: $PASS"
echo " Failed: $FAIL"
echo "============================================"
if [ $FAIL -gt 0 ]; then
echo "❌ Phase 4 FAILED"
exit 1
else
echo "✅ Phase 4 PASSED"
fi