96 lines
3.3 KiB
Markdown
96 lines
3.3 KiB
Markdown
# COBOL → Java/Spark 迁移验证平台 v3
|
||
|
||
自动解析 COBOL 源码,生成覆盖全分支路径的测试数据,分别运行 COBOL 和 Java/Spark 两个版本,逐字段比对输出,判定迁移正确性。
|
||
|
||
支持 **非 DB**(flat file I-O)和 **DB**(EXEC SQL → gixsql + SQLite)两条平行管道。
|
||
|
||
## 快速开始
|
||
|
||
```bash
|
||
# 安装依赖
|
||
pip install lark pathlib pyyaml
|
||
|
||
# 运行非 DB 回归测试
|
||
python test-data/s15_coverage_verification.py
|
||
|
||
# 运行 DB 端到端测试(需设置环境变量,见 SETUP.md)
|
||
python test-data/s30_db_e2e.py
|
||
|
||
# 单程序运行(自动路由:含 EXEC SQL → DB 管道,否则非 DB)
|
||
python -m cobol_testgen ../cobol-tna-system/src/KIN01INP.cbl
|
||
```
|
||
|
||
## 全流程数据生成(run.py)
|
||
|
||
先跑白盒 `cobol_testgen`(静态分析 + 测试数据),成功后跑黑盒 `black-box-data-create`(DeepSeek LLM 生成 JSON/SQL):
|
||
|
||
```bash
|
||
python run.py \
|
||
--design "D:\cobol-tna-system\詳細設計書\詳細設計書_ZAN04MAT.md" \
|
||
--source "D:\cobol-tna-system\src\ZAN04MAT.cbl" \
|
||
--file-db-md "D:\cobol-tna-system\詳細設計書\COPY句定義書.md" \
|
||
--cpy "D:\cobol-tna-system\cpy" \
|
||
--db-md "D:\cobol-tna-system\詳細設計書\DB定義書.md" \
|
||
--output "D:\output"
|
||
|
||
# 只查看将执行的命令,不真正运行
|
||
python run.py --design ... --output ... --dry-run
|
||
```
|
||
|
||
- 参数 `--design / --source / --file-db-md / --cpy / --db-md / --output` 为必需项,`--api-key / --model / --rules / --max-tokens` 可选透传给黑盒。
|
||
- 两步输出到同一 `--output` 根目录:白盒写 `output/<程序ID>/main/...`,黑盒写 `output/<程序ID>/g{N}/...`。
|
||
- 任一步失败即停止并返回该步退出码。
|
||
|
||
## 架构
|
||
|
||
```
|
||
CLI → orchestrator / orchestrator_db
|
||
│
|
||
┌─────┼──────┬──────────┬──────────┐
|
||
▼ ▼ ▼ ▼ ▼
|
||
cobol_testgen runners comparator agents
|
||
(数据生成) (编译运行) (比对验证) (LLM)
|
||
```
|
||
|
||
两条管道自动路由:
|
||
- **非 DB**:`cobc` 编译 → flat file 二进制比对
|
||
- **DB**:`gixpp` ESQL 预处理 → `cobc -l gixsql` 编译 → SQLite 表比对
|
||
|
||
## 文档索引
|
||
|
||
| 文档 | 说明 |
|
||
|------|------|
|
||
| `SETUP.md` | 环境搭建、运行指南、检查清单(含 DB 管道) |
|
||
| `docs/v3-理解文档.md` | 系统架构、组件说明、数据流(中文,457 行) |
|
||
| `docs/changelog-v1-to-v3.md` | V1→V3 演进记录 |
|
||
| `docs/module-interfaces.md` | 模块接口定义 |
|
||
| `DESIGN.md` | Web UI 设计规范 |
|
||
| `CONTRIBUTING.md` | 贡献指南 |
|
||
|
||
## 核心命令
|
||
|
||
```bash
|
||
# 非 DB 全量覆盖率报告
|
||
python test-data/s25_per_program_report.py
|
||
|
||
# DB 端到端测试
|
||
python test-data/s30_db_e2e.py
|
||
|
||
# 带 gcov 覆盖率的单程序运行
|
||
python -m cobol_testgen --gcov <cobol_src> runtime/
|
||
|
||
# 诊断脚本
|
||
python diagnose_db2.py # DB 全流程
|
||
python diagnose_kind8dbrun.py # DB 编译运行
|
||
|
||
# 黑盒数据生成
|
||
python black-box-data-create/main.py --design "D:\xxxx\詳細設計書_xxxx.md" --source "D:\xxxx\xxxx.cbl" --file-db-md "D:\xxxx\COPY句定義書.md" --cpy "D:\cobol-tna-system\cpy" --db-md "D:\xxxx\DB定義書.md" --output "D:\xxxx\output"
|
||
|
||
```
|
||
|
||
## 依赖
|
||
|
||
- **Python 3.12+** + `lark`, `pyyaml`
|
||
- **GnuCOBOL 3.2.0** (GC32-BDB-SP1,含 DB2/SQLite 支持)
|
||
- **gixsql** (已 vendored 在 `gixsql/` 目录)
|