diff --git a/scripts/test_m5api_phase3.sh b/scripts/test_m5api_phase3.sh new file mode 100755 index 0000000..32fd4da --- /dev/null +++ b/scripts/test_m5api_phase3.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# Phase 3: Process & Pipeline API Test +# Modules: 05_process, 10_pipeline +# Endpoints: 7 + +BASE="https://m5api.momentry.ddns.net" +API_KEY="muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69" +FILE_UUID="a6fb22eebefaef17e62af874997c5944" + +PASS=0 +FAIL=0 +TOTAL=0 + +echo "============================================" +echo " Phase 3: Process & Pipeline 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 "── Jobs ──" +test_api "GET" "/api/v1/jobs?page=1&page_size=3" "" "List jobs" +test_api "GET" "/api/v1/progress/$FILE_UUID" "" "Processing progress" + +echo "" +echo "── Process Triggers ──" +test_api "POST" "/api/v1/file/$FILE_UUID/process" '{"processors":["asr"]}' "Trigger ASR processing" +test_api "POST" "/api/v1/file/$FILE_UUID/process" '{"processors":["cut"]}' "Trigger CUT processing" + +echo "" +echo "── Pipeline Status ──" +test_api "GET" "/api/v1/stats/ingestion-status/$FILE_UUID" "" "Ingestion status" +test_api "GET" "/api/v1/health/detailed" "" "Detailed health" + +echo "" +echo "── Chunking ──" +test_api "GET" "/api/v1/file/$FILE_UUID/chunk/llm_parent_${FILE_UUID}_2099_2105" "" "Get parent chunk" + +echo "" +echo "============================================" +echo " Total: $TOTAL" +echo " Passed: $PASS ✅" +echo " Failed: $FAIL ❌" +echo "============================================" + +if [ $FAIL -gt 0 ]; then + echo "❌ Phase 3 FAILED" + exit 1 +else + echo "✅ Phase 3 PASSED" +fi diff --git a/scripts/test_m5api_phase4.sh b/scripts/test_m5api_phase4.sh new file mode 100755 index 0000000..4030b57 --- /dev/null +++ b/scripts/test_m5api_phase4.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# Phase 4: Search API Test +# Modules: 06_search, 08_identity_agent, 12_agent +# Endpoints: 12 + +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" "{\"file_uuid\":\"$FILE_UUID\",\"required_classes\":[\"person\"]}" "Visual search by class" +test_api "POST" "/api/v1/search/visual/density" "{\"file_uuid\":\"$FILE_UUID\",\"min_avg_confidence\":0.5}" "Visual search by density" +test_api "POST" "/api/v1/search/visual/stats" "{\"file_uuid\":\"$FILE_UUID\"}" "Visual search stats" +test_api "POST" "/api/v1/search/visual/combination" "{\"file_uuid\":\"$FILE_UUID\",\"required_classes\":[\"person\",\"car\"]}" "Visual search combination" + +echo "" +echo "── Identity Text Search ──" +test_api "GET" "/api/v1/search/identity_text?query=Grant" "" "Identity text search" +test_api "GET" "/api/v1/identities/search?query=Grant" "" "Identities search" + +echo "" +echo "── Agent Search ──" +test_api "POST" "/api/v1/agents/translate" '{"text":"Hello world","target_lang":"zh"}' "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 diff --git a/scripts/test_m5api_phase5.sh b/scripts/test_m5api_phase5.sh new file mode 100755 index 0000000..321b67d --- /dev/null +++ b/scripts/test_m5api_phase5.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash +# Phase 5: Identity, Media & TMDb API Test +# Modules: 07_identity, 08_media, 09_tmdb +# Endpoints: 24 + +BASE="https://m5api.momentry.ddns.net" +API_KEY="muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69" +FILE_UUID="a6fb22eebefaef17e62af874997c5944" +IDENTITY_UUID="c1080a3d64914cec921ef7c038f462d1" + +PASS=0 +FAIL=0 +TOTAL=0 + +echo "============================================" +echo " Phase 5: Identity, Media & TMDb API Test" +echo " Base: $BASE" +echo " File: $FILE_UUID" +echo " Identity: $IDENTITY_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 "── Identity List ──" +test_api "GET" "/api/v1/identities?page=1&page_size=3" "" "List identities" +test_api "GET" "/api/v1/identity/$IDENTITY_UUID" "" "Get identity detail" +test_api "GET" "/api/v1/identity/$IDENTITY_UUID/files" "" "Get identity files" +test_api "GET" "/api/v1/identity/$IDENTITY_UUID/chunks" "" "Get identity chunks" +test_api "GET" "/api/v1/identity/$IDENTITY_UUID/faces" "" "Get identity faces" +test_api "GET" "/api/v1/identity/$IDENTITY_UUID/json" "" "Get identity JSON" + +echo "" +echo "── Face Candidates ──" +test_api "GET" "/api/v1/faces/candidates?file_uuid=$FILE_UUID&page=1&page_size=3" "" "List face candidates" + +echo "" +echo "── Identity Binding ──" +test_api "POST" "/api/v1/identity/$IDENTITY_UUID/bind" '{"face_ids":["face_1"]}' "Bind identity" +test_api "POST" "/api/v1/identity/$IDENTITY_UUID/unbind" '{"face_ids":["face_1"]}' "Unbind identity" +test_api "POST" "/api/v1/identity/$IDENTITY_UUID/mergeinto" '{"target_uuid":"'"$IDENTITY_UUID"'"}' "Merge identities" + +echo "" +echo "── TMDb ──" +test_api "GET" "/api/v1/resource/tmdb" "" "TMDb resource status" +test_api "POST" "/api/v1/resource/tmdb/check" "" "TMDb resource check" +test_api "POST" "/api/v1/agents/tmdb/prefetch" "{\"file_uuid\":\"$FILE_UUID\"}" "TMDb prefetch" +test_api "POST" "/api/v1/file/$FILE_UUID/tmdb-probe" "" "TMDb probe" + +echo "" +echo "── Identity Agent ──" +test_api "POST" "/api/v1/agents/identity/match-from-photo" '{"photo_path":"/tmp/test.jpg"}' "Match from photo" +test_api "POST" "/api/v1/agents/identity/match-from-trace" '{"trace_id":1}' "Match from trace" + +echo "" +echo "── 5W1H Agent ──" +test_api "POST" "/api/v1/agents/5w1h/analyze" "{\"file_uuid\":\"$FILE_UUID\"}" "5W1H analyze" +test_api "GET" "/api/v1/agents/5w1h/status?file_uuid=$FILE_UUID" "" "5W1H status" + +echo "" +echo "── Trace ──" +test_api "POST" "/api/v1/file/$FILE_UUID/traces" '{"min_faces":1,"page":1,"page_size":3}' "List traces" +test_api "GET" "/api/v1/file/$FILE_UUID/trace/1/faces" "" "List trace faces" + +echo "" +echo "── Media ──" +test_api "GET" "/api/v1/file/$FILE_UUID/video?start_time=60&end_time=65" "" "Stream video clip" +test_api "GET" "/api/v1/file/$FILE_UUID/thumbnail?frame=1000" "" "Extract thumbnail" +test_api "GET" "/api/v1/file/$FILE_UUID/clip?start_frame=1000&end_frame=1100" "" "Video clip by frame" + +echo "" +echo "============================================" +echo " Total: $TOTAL" +echo " Passed: $PASS ✅" +echo " Failed: $FAIL ❌" +echo "============================================" + +if [ $FAIL -gt 0 ]; then + echo "❌ Phase 5 FAILED" + exit 1 +else + echo "✅ Phase 5 PASSED" +fi