53 lines
2.3 KiB
Bash
53 lines
2.3 KiB
Bash
#!/bin/bash
|
||||
|
|
# deploy/integration_check.sh —— M2 集成检查(PM 使用,在远端运行)
|
|||
|
|
# 用途:真实 BFF(8090)接真实上游后的端到端冒烟。
|
|||
|
|
# 前置:BFF 已在 8090 运行(deploy/start-dev.sh),远端可直接访问 127.0.0.1。
|
|||
|
|
set -uo pipefail
|
|||
|
|
BFF="http://127.0.0.1:8090"
|
|||
|
|
PASS=0; FAIL=0
|
|||
|
|
ok() { echo " ✅ $1"; PASS=$((PASS+1)); }
|
|||
|
|
bad() { echo " ❌ $1"; FAIL=$((FAIL+1)); }
|
|||
|
|
check() { # $1 名称 $2 实际输出 $3 期望子串
|
|||
|
|
if echo "$2" | grep -q "$3"; then ok "$1"; else bad "$1(输出: $(echo "$2" | head -c 200))"; fi
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo "== 1. 健康 =="
|
|||
|
|
H=$(curl -s --max-time 10 "$BFF/api/health")
|
|||
|
|
check "health 返回 status" "$H" '"status"'
|
|||
|
|
check "qa 上游探测存在" "$H" '"qa"'
|
|||
|
|
check "neo4j 探测存在" "$H" '"neo4j"'
|
|||
|
|
|
|||
|
|
echo "== 2. QA =="
|
|||
|
|
QI=$(curl -s --max-time 10 "$BFF/api/qa/info")
|
|||
|
|
check "qa info 版本" "$QI" '1.1.73'
|
|||
|
|
|
|||
|
|
echo "== 3. 会话 =="
|
|||
|
|
S=$(curl -s -X POST "$BFF/api/sessions" -H 'Content-Type: application/json' -d '{"title":"集成冒烟"}')
|
|||
|
|
SID=$(echo "$S" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null)
|
|||
|
|
[ -n "$SID" ] && ok "创建会话 ($SID)" || bad "创建会话(输出: $S)"
|
|||
|
|
L=$(curl -s "$BFF/api/sessions")
|
|||
|
|
check "会话列表包含新会话" "$L" "$SID"
|
|||
|
|
|
|||
|
|
echo "== 4. 知识图谱(Neo4j 直连)=="
|
|||
|
|
KS=$(curl -s --max-time 10 "$BFF/api/kg/status")
|
|||
|
|
check "kg status schema" "$KS" 'canonical'
|
|||
|
|
E=$(curl -s --max-time 10 "$BFF/api/kg/entities?q=SPL&limit=5")
|
|||
|
|
check "实体搜索" "$E" '"results"'
|
|||
|
|
|
|||
|
|
echo "== 5. 抽取任务 =="
|
|||
|
|
J=$(curl -s --max-time 15 "$BFF/api/extraction/jobs")
|
|||
|
|
check "任务列表" "$J" '"jobs"'
|
|||
|
|
|
|||
|
|
echo "== 6. QA 检索(真实上游,约 90s,可选)=="
|
|||
|
|
if [ "${SKIP_QA:-0}" = "1" ]; then echo " ⏭ 跳过(SKIP_QA=1)"; else
|
|||
|
|
Q=$(curl -s --max-time 200 -X POST "$BFF/api/qa/search" -H 'Content-Type: application/json' \
|
|||
|
|
-d '{"question":"SPL gene family in rice","use_llm":false,"debug":false,"chain_top_k":3,"chain_hops":2,"chain_max_edges":12,"chain_max_nodes":10,"native_chain_enabled":true,"native_chain_max_hops":3,"native_chain_top_k":5}')
|
|||
|
|
check "search 返回 sources" "$Q" '"sources"'
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
[ -n "$SID" ] && curl -s -X DELETE "$BFF/api/sessions/$SID" > /dev/null && ok "清理冒烟会话" || true
|
|||
|
|
|
|||
|
|
echo
|
|||
|
|
echo "结果:$PASS 通过 / $FAIL 失败"
|
|||
|
|
[ "$FAIL" -eq 0 ]
|