mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-10 00:40:30 +08:00
e8672a3c7b
Former-commit-id: dc30d42a8c55ed8b2382a41dc2434233fbed9930
85 lines
3.4 KiB
Bash
Executable File
85 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# 完整接口测试:V1/V2 单机冒烟 + 双端对拍 + 套件总览 Markdown。
|
|
# 前置:两 JAR 已分别启动(默认 http://127.0.0.1:18080 为 V1、18081 为 V2),且配置同一数据源/Redis。
|
|
# 用法:在 maven-cw-elevator-application 目录执行 ./scripts/run_full_elevator_api_suite.sh
|
|
#
|
|
# ELEVATOR_SUITE_STRICT=1:冒烟与对拍失败时脚本退出非 0(默认由 run_v1v2_parity_automated.sh 传入)。
|
|
# ELEVATOR_SUITE_STRICT=0:与旧行为一致,冒烟/对拍用「|| true」始终生成总览(便于无服务时只看单元测试)。
|
|
set -euo pipefail
|
|
|
|
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
|
TOOL="${REPO}/tools/elevator_api_parity"
|
|
MARKER="${TOOL}/.suite_run_marker"
|
|
|
|
export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
|
|
export PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
export ELEVATOR_BASE_OLD="${ELEVATOR_BASE_OLD:-http://127.0.0.1:18080}"
|
|
export ELEVATOR_BASE_NEW="${ELEVATOR_BASE_NEW:-http://127.0.0.1:18081}"
|
|
|
|
SUITE_STRICT="${ELEVATOR_SUITE_STRICT:-0}"
|
|
SUITE_FAIL=0
|
|
|
|
_py_maybe_ignore() {
|
|
if [[ "${SUITE_STRICT}" == "1" ]]; then
|
|
python3 -m pytest "$@" && return 0
|
|
return 1
|
|
fi
|
|
python3 -m pytest "$@" || true
|
|
return 0
|
|
}
|
|
|
|
cd "$TOOL"
|
|
python3 -m pip install -q -r requirements.txt 2>/dev/null || true
|
|
|
|
touch "$MARKER"
|
|
|
|
# -rs 在结束时打印 skip 原因;s=skip 通常表示目标端口无服务或 /actuator/health 无 200
|
|
PTF="-q -rs --tb=line"
|
|
|
|
echo "==> 单元(compare 逻辑)"
|
|
python3 -m pytest tests/test_unit_compare.py -q --tb=short
|
|
|
|
echo "==> 冒烟 V1 ($ELEVATOR_BASE_OLD) [需该地址可访问 /actuator/health 等健康端点]"
|
|
_py_maybe_ignore tests/test_smoke_catalog.py -m smoke \
|
|
--smoke-base="$ELEVATOR_BASE_OLD" --smoke-label=v1_legacy $PTF || SUITE_FAIL=1
|
|
|
|
echo "==> 冒烟 V2 ($ELEVATOR_BASE_NEW) [需该地址可访问 /actuator/health 等健康端点]"
|
|
_py_maybe_ignore tests/test_smoke_catalog.py -m smoke \
|
|
--smoke-base="$ELEVATOR_BASE_NEW" --smoke-label=v2_build $PTF || SUITE_FAIL=1
|
|
|
|
echo "==> 横向对拍(两实例均需通过健康探针) [ELEVATOR_SUITE_STRICT=${SUITE_STRICT} ELEVATOR_PARITY_BOUNDARY=${ELEVATOR_PARITY_BOUNDARY:-0}]"
|
|
_py_maybe_ignore tests/test_parity_endpoints.py -m live $PTF \
|
|
--base-old="$ELEVATOR_BASE_OLD" --base-new="$ELEVATOR_BASE_NEW" || SUITE_FAIL=1
|
|
|
|
SUITE_TS="$(date +%Y%m%d-%H%M%S)"
|
|
_pick_newer() {
|
|
local pattern="$1"
|
|
local f=""
|
|
for f in $(ls -t "${TOOL}/report"/${pattern} 2>/dev/null); do
|
|
if [[ -f "$f" && "$f" -nt "$MARKER" ]]; then echo "$f"; return; fi
|
|
done
|
|
}
|
|
SMOKE_V1="$(_pick_newer 'smoke-v1_legacy-*.md')"
|
|
SMOKE_V2="$(_pick_newer 'smoke-v2_build-*.md')"
|
|
PARITY="$(_pick_newer 'parity-*.md')"
|
|
|
|
OUT="${TOOL}/report/SUITE-${SUITE_TS}.md"
|
|
python3 report/generate_suite_summary.py --out "$OUT" \
|
|
--catalog "${TOOL}/api_catalog.json" \
|
|
${PARITY:+--parity "$PARITY"} \
|
|
${SMOKE_V1:+--smoke-v1 "$SMOKE_V1"} \
|
|
${SMOKE_V2:+--smoke-v2 "$SMOKE_V2"}
|
|
|
|
echo "==> 套件总览: $OUT"
|
|
if [[ -z "$SMOKE_V1" && -z "$SMOKE_V2" && -z "$PARITY" ]]; then
|
|
echo "==> 提示: 未生成 smoke/parity 子报告(多为本机未起 JAR 或健康检查未通过)。"
|
|
echo " 先起两进程: java -jar V1.jar --server.port=18080 --spring.config.location=... 与 V2 用 18081"
|
|
echo " 快速探活: curl -s -o /dev/null -w '%{http_code}' $ELEVATOR_BASE_OLD/actuator/health"
|
|
fi
|
|
rm -f "$MARKER"
|
|
|
|
if [[ "${SUITE_FAIL}" -ne 0 ]]; then
|
|
echo "==> 套件步骤存在失败 (ELEVATOR_SUITE_STRICT=${SUITE_STRICT}, exit=${SUITE_FAIL})" >&2
|
|
fi
|
|
exit "${SUITE_FAIL}"
|