Files
starRiverProperty/maven-cw-elevator-application/tools/elevator_api_parity/README.md
T
反编译工作区 038f846dad docs+test: 发布包对拍计划、pytest 双端 API 对拍与 run_elevator_parity 脚本
- docs/elevator-api-parity: 计划/报告模板/示例
- tools/elevator_api_parity: 端点目录、fixtures、对拍 client/compare、报告生成
- scripts/run_elevator_parity: JDK8 构建 + 单测/对拍(无服务时跳过对拍用例)

Made-with: Cursor

Former-commit-id: 3d54a40e1a7ae0b1724261d4f18910a6f415f853
2026-04-25 09:50:32 +08:00

1.7 KiB
Raw Blame History

elevator_api_parity — 新旧 JAR 接口对拍

环境

  • Python 3.8+
  • 安装:pip install -r requirements.txt(在本目录下执行)

环境说明

本机若安装过 allure_pytest 等全局 pytest 插件且与 Python 版本冲突,请执行:

export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1run_elevator_parity.sh 已自动设置)后再跑 pytest

快速使用

  1. 构建新 JAR(在 reactor 根目录、JDK8
    mvn -DskipTests clean package
    得到:../cw-elevator-application-starter/target/cw-elevator-application-2.0.0.jar
  2. 将历史 JAR 放到 cw-elevator-application-V1.0.0.20211103/cw-elevator-application-V1.0.0.20211103.jar 或设 ELEVATOR_JAR_LEGACY
  3. 准备与现网相同application.yml(或目录),如 ELEVATOR_SPRING_CONFIG=file:/path/to/application-elevator.yml
  4. 从仓库反编译根或本目录执行:
    ../../scripts/run_elevator_parity.sh(见该脚本内环境变量说明)

或手动启动两实例后:

export ELEVATOR_BASE_OLD=http://127.0.0.1:18080
export ELEVATOR_BASE_NEW=http://127.0.0.1:18081
export ELEVATOR_HEADER_BUSINESSID=...   # 与现网/联调一致
# ...
cd tools/elevator_api_parity
python -m pytest tests/ -v --tb=short

配置

  • api_catalog.json:对拍端点、方法、fixture 文件名、说明。
  • fixtures/*.json:各接口请求体。
  • 归一化忽略键可扩展 parity/compare.pyDEFAULT_STRIP_PATHS(如 data.rows 内动态字段,谨慎)。

报告

  • report/parity-YYYYMMDD-HHMMSS.md:实跑时由 conftest 的 session hook 与 report/generate_report.py 组合生成。
  • JUnit(可选):--junitxml=report/junit.xml