126 lines
5.1 KiB
Bash
126 lines
5.1 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
data_dir=/var/lib/supermemory
|
|
sentinel="$data_dir/.smoke-gemini-embedding-2-768.ok"
|
|
base_url="${SUPERMEMORY_URL:-http://127.0.0.1:6767}"
|
|
container_tag="${SUPERMEMORY_CONTAINER_TAG:-hermes_supermemory_lab}"
|
|
|
|
if [ -f "$sentinel" ]; then
|
|
printf '%s\n' '{"smoke":"already-passed"}'
|
|
exit 0
|
|
fi
|
|
|
|
api_key=$(cat "$data_dir/api-key")
|
|
auth_header="Authorization: Bearer $api_key"
|
|
marker="supermemory-poc-gemini-native-$(date +%s)"
|
|
|
|
fail() {
|
|
code="$1"
|
|
phase="$2"
|
|
printf '{"smoke":"failed","phase":"%s","exit_code":%s}\n' "$phase" "$code"
|
|
exit "$code"
|
|
}
|
|
|
|
plan="$data_dir/embedding-plan.json"
|
|
for _ in $(seq 1 30); do
|
|
[ -f "$plan" ] && break
|
|
sleep 1
|
|
done
|
|
grep -q 'gemini' "$plan" || fail 11 embedding-plan-provider
|
|
grep -q 'gemini-embedding-2' "$plan" || fail 12 embedding-plan-model
|
|
grep -q '768' "$plan" || fail 13 embedding-plan-dimensions
|
|
|
|
if ! curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"content\":\"$marker:中文跨文档检索测试;海棠计划的下一步是核对原始报告。\",\"containerTag\":\"$container_tag\",\"customId\":\"$marker\",\"metadata\":{\"source\":\"poc-smoke\",\"status\":\"temporary\"}}" \
|
|
"$base_url/v3/documents" >/tmp/add.json; then
|
|
fail 22 document-add
|
|
fi
|
|
|
|
document_id=$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' /tmp/add.json | head -n 1)
|
|
[ -n "$document_id" ] || fail 23 document-id-missing
|
|
|
|
document_status=
|
|
for _ in $(seq 1 120); do
|
|
if ! curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
"$base_url/v3/documents/$document_id" >/tmp/document.json; then
|
|
fail 24 document-get
|
|
fi
|
|
if grep -Eq '"status"[[:space:]]*:[[:space:]]*"failed"' /tmp/document.json; then
|
|
fail 31 document-processing-failed
|
|
fi
|
|
if grep -Eq '"status"[[:space:]]*:[[:space:]]*"done"' /tmp/document.json; then
|
|
document_status=done
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
[ "$document_status" = done ] || fail 35 document-not-done
|
|
|
|
if ! curl --fail --silent --show-error --max-time 15 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"q\":\"$marker\",\"containerTag\":\"$container_tag\"}" \
|
|
"$base_url/v3/search" >/tmp/search-v3.json; then
|
|
fail 41 search-v3-request
|
|
fi
|
|
v3_hit=false
|
|
if grep -Eq '"total"[[:space:]]*:[[:space:]]*[1-9][0-9]*' /tmp/search-v3.json; then
|
|
v3_hit=true
|
|
fi
|
|
|
|
curl --fail --silent --show-error --max-time 15 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"q\":\"$marker\",\"containerTag\":\"$container_tag\",\"searchMode\":\"documents\",\"limit\":5}" \
|
|
"$base_url/v4/search" >/tmp/search-documents.json || fail 42 search-documents-request
|
|
documents_hit=false
|
|
documents_metadata=false
|
|
if grep -Eq '"total"[[:space:]]*:[[:space:]]*[1-9][0-9]*' /tmp/search-documents.json && grep -q "$marker" /tmp/search-documents.json; then
|
|
documents_hit=true
|
|
fi
|
|
if grep -q 'poc-smoke' /tmp/search-documents.json; then
|
|
documents_metadata=true
|
|
fi
|
|
|
|
curl --fail --silent --show-error --max-time 15 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"q\":\"海棠计划下一步是什么?\",\"containerTag\":\"$container_tag\",\"searchMode\":\"hybrid\",\"limit\":5}" \
|
|
"$base_url/v4/search" >/tmp/search-hybrid.json || fail 47 search-hybrid-request
|
|
hybrid_hit=false
|
|
hybrid_metadata=false
|
|
if grep -Eq '"total"[[:space:]]*:[[:space:]]*[1-9][0-9]*' /tmp/search-hybrid.json && grep -q '核对原始报告' /tmp/search-hybrid.json; then
|
|
hybrid_hit=true
|
|
fi
|
|
if grep -q 'poc-smoke' /tmp/search-hybrid.json; then
|
|
hybrid_metadata=true
|
|
fi
|
|
|
|
printf '{"smoke":"search-diagnostic","v3":%s,"v4_documents":%s,"v4_documents_metadata":%s,"v4_hybrid":%s,"v4_hybrid_metadata":%s}\n' \
|
|
"$v3_hit" "$documents_hit" "$documents_metadata" "$hybrid_hit" "$hybrid_metadata"
|
|
[ "$v3_hit" = true ] || fail 44 search-v3-no-hit
|
|
[ "$documents_hit" = true ] || fail 45 search-documents-no-hit
|
|
[ "$documents_metadata" = true ] || fail 46 search-documents-metadata-missing
|
|
[ "$hybrid_hit" = true ] || fail 48 search-hybrid-no-hit
|
|
[ "$hybrid_metadata" = true ] || fail 49 search-hybrid-metadata-missing
|
|
|
|
curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"containerTag\":\"$container_tag\",\"q\":\"$marker\"}" \
|
|
"$base_url/v4/profile" >/tmp/profile.json || fail 51 profile-request
|
|
grep -q '"profile"' /tmp/profile.json || fail 52 profile-shape
|
|
|
|
curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"conversationId\":\"$marker\",\"containerTags\":[\"$container_tag\"],\"messages\":[{\"role\":\"user\",\"content\":\"这只是隔离测试。\"},{\"role\":\"assistant\",\"content\":\"不会作为正式事实。\"}],\"metadata\":{\"source\":\"poc-smoke\",\"status\":\"temporary\"}}" \
|
|
"$base_url/v4/conversations" >/tmp/conversation.json || fail 61 conversation-ingest
|
|
|
|
touch "$sentinel"
|
|
printf '%s\n' '{"embedding_plan":"gemini/gemini-embedding-2/768","llm":"gemini-native-default","v3_search":"ok","v4_documents_search":"ok","chinese_hybrid_search":"ok","metadata_traceability":"ok","profile":"ok","conversation_ingest":"accepted"}'
|