118 lines
4.8 KiB
Bash
118 lines
4.8 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
data_dir=/var/lib/supermemory
|
|
sentinel="$data_dir/.smoke-google-gemini-embedding-2-1024.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-google-embedding-2-$(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 'openai' "$plan" || fail 11 embedding-plan-provider
|
|
grep -q 'google/gemini-embedding-2' "$plan" || fail 12 embedding-plan-model
|
|
grep -q '1024' "$plan" || fail 13 embedding-plan-dimensions
|
|
|
|
if ! curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"containerTags\":[\"$container_tag\"],\"limit\":20}" \
|
|
"$base_url/v3/documents/list" >/tmp/documents.json; then
|
|
fail 21 documents-list
|
|
fi
|
|
|
|
if grep -q 'supermemory-poc-google-embedding-2' /tmp/documents.json; then
|
|
if grep -Eq '"status"[[:space:]]*:[[:space:]]*"failed"' /tmp/documents.json; then
|
|
fail 31 document-processing-failed
|
|
fi
|
|
if ! grep -Eq '"status"[[:space:]]*:[[:space:]]*"done"' /tmp/documents.json; then
|
|
if grep -Eq '"status"[[:space:]]*:[[:space:]]*"embedding"' /tmp/documents.json; then
|
|
fail 32 document-stuck-embedding
|
|
fi
|
|
if grep -Eq '"status"[[:space:]]*:[[:space:]]*"chunking"' /tmp/documents.json; then
|
|
fail 33 document-stuck-chunking
|
|
fi
|
|
if grep -Eq '"status"[[:space:]]*:[[:space:]]*"indexing"' /tmp/documents.json; then
|
|
fail 34 document-stuck-indexing
|
|
fi
|
|
fail 35 document-not-done
|
|
fi
|
|
else
|
|
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
|
|
fi
|
|
|
|
found=false
|
|
for _ in $(seq 1 90); do
|
|
curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"q\":\"海棠计划下一步是什么?\",\"containerTag\":\"$container_tag\",\"searchMode\":\"hybrid\",\"limit\":5}" \
|
|
"$base_url/v4/search" >/tmp/search-v4.json || fail 41 search-v4-request
|
|
if grep -q '核对原始报告' /tmp/search-v4.json && grep -q 'poc-smoke' /tmp/search-v4.json; then
|
|
found=true
|
|
break
|
|
fi
|
|
|
|
curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"q\":\"海棠计划下一步是什么?\",\"containerTags\":[\"$container_tag\"],\"searchMode\":\"hybrid\",\"limit\":5}" \
|
|
"$base_url/v4/search" >/tmp/search-v4-tags.json || fail 42 search-v4-tags-request
|
|
if grep -q '核对原始报告' /tmp/search-v4-tags.json && grep -q 'poc-smoke' /tmp/search-v4-tags.json; then
|
|
found=true
|
|
break
|
|
fi
|
|
|
|
curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"q\":\"海棠计划下一步是什么?\",\"containerTag\":\"$container_tag\"}" \
|
|
"$base_url/v3/search" >/tmp/search-v3.json || fail 43 search-v3-request
|
|
if grep -q '核对原始报告' /tmp/search-v3.json && grep -q 'poc-smoke' /tmp/search-v3.json; then
|
|
found=true
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
[ "$found" = true ] || fail 44 search-no-traceable-hit
|
|
|
|
curl --fail --silent --show-error --max-time 60 \
|
|
-H "$auth_header" \
|
|
-H 'Content-Type: application/json' \
|
|
--data "{\"containerTag\":\"$container_tag\",\"q\":\"海棠计划\"}" \
|
|
"$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":"openai/google/gemini-embedding-2/1024","llm":"gemini-3.5-flash-lite","chinese_hybrid_search":"ok","metadata_traceability":"ok","profile":"ok","conversation_ingest":"accepted"}'
|