Files
railwaysystem/scripts/qa/run-core-business-scenario.sh
T

58 lines
2.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# ==============================================================================
# RailwaySystem Core Business Scenario Integration Gate Runner
# 显式 Integration Gate 执行入口,包含前置检查、端到端全场景执行、只读DB断言与报告生成。
# 绝不写入硬编码密码或敏感凭据。
# ==============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
echo "=== 1. 预检 Kingbase 数据库与后端服务 ==="
if ! nc -zv -G 1 127.0.0.1 4321 >/dev/null 2>&1; then
echo "错误: Kingbase 数据库隧道未就绪 (127.0.0.1:4321),请先检查或启动隧道。" >&2
exit 1
fi
echo "Kingbase 端口 (4321) 连接正常。"
# 预检认证凭据(严格禁止硬编码fallback,缺失时立即FAIL FAST)
if [ -f "${HOME}/.railwaysystem-qa.env" ]; then
# shellcheck source=/dev/null
. "${HOME}/.railwaysystem-qa.env"
fi
if [ -z "${QA_ADMIN_USERNAME:-}" ] || [ -z "${QA_ADMIN_PASSWORD:-}" ]; then
echo "错误: 缺少必须的管理端认证环境变量 (QA_ADMIN_USERNAME / QA_ADMIN_PASSWORD),FAIL FAST 终止执行。" >&2
echo "请在安全环境中导出上述变量后再执行。" >&2
exit 1
fi
BACKEND_PORT=""
for p in 8094 8092 8090; do
if curl -s "http://localhost:${p}/captchaImage" >/dev/null 2>&1; then
BACKEND_PORT="${p}"
break
fi
done
if [ -z "${BACKEND_PORT}" ]; then
echo "错误: RailwaySystem 后端服务未在 8094, 8092 或 8090 端口运行,请先启动后端服务。" >&2
exit 1
fi
echo "后端服务 (${BACKEND_PORT}) 正常响应。"
# 自动编译 DbAssertionChecker
KB_JAR="${HOME}/.m2/repository/com/kingbase/kingbase8/8.6.0/kingbase8-8.6.0.jar"
if [ -f "${KB_JAR}" ]; then
javac -cp "${KB_JAR}" -d "${PROJECT_ROOT}" "${SCRIPT_DIR}/DbAssertionChecker.java"
fi
echo ""
echo "=== 2. 执行核心业务场景自动化测试套件 ==="
python3 "${SCRIPT_DIR}/core-business-scenario-runner.py"
echo ""
echo "=== 3. 核心业务场景集成测试执行完毕 ==="