feat(#86): 端到端联调用例编写(数据流 + 问答流 + 跨链路闭环)
新增 tests/e2e/ 端到端联调测试套件,覆盖四个 iAOP-Core 内核模块的全链路协作: 数据流(PRD 5.1→5.2): - edge-gateway 只读采集(模拟驱动)→ spool 断点续传 → data-bus 批量写入 - 验证不丢不重(幂等去重)、样本字段完整、健康度满足 SLA 问答流(PRD 5.4): - rag-kb 模板化知识库检索(命中片段+来源)→ llm-gateway 混合网关 - 验证敏感度路由、DLP 拦截、幻觉溯源校验、审计可追溯 跨链路:采集→落库→知识沉淀→安全问答业务闭环 共 14 个用例,全部基于可注入接口运行,零外部依赖(CI 可直接执行)。 运行:python -m unittest discover -s tests/e2e -v
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# iAOP 端到端联调用例(Issue #86)
|
||||
|
||||
对应 PRD 第 8 章「端到端联调」与 EPIC #14(M4)子任务 #86。
|
||||
跨四个 iAOP-Core 内核模块的全链路联调测试,覆盖「数据流」与「问答流」两条端到端链路,
|
||||
全部基于各模块的**可注入接口**运行,零外部依赖(不依赖 Kafka / TDengine / PostgreSQL /
|
||||
MinIO / 真实 LLM / 真实设备),可在 CI 中直接执行。
|
||||
|
||||
## 链路覆盖
|
||||
|
||||
### 数据流(PRD 5.1 → 5.2)
|
||||
`edge-gateway` 只读采集(模拟驱动)→ `spool` 断点续传缓存 → `data-bus` BatchWriter
|
||||
批量写入(MemorySink,幂等去重,「不丢不重」)→ 健康度上报(P99 / 丢失率 / 可用性)。
|
||||
|
||||
| 用例 | 验证点 |
|
||||
|------|--------|
|
||||
| `test_collect_once_all_points_read_into_spool` | 单轮采集:全部点位读出并落 spool |
|
||||
| `test_collect_multiple_rounds_accumulate` | 多轮采集:spool 累计 = 轮数 × 点位数(不丢) |
|
||||
| `test_spool_drain_into_batchwriter_no_loss_no_dup` | spool → 批量写入:不丢不重 |
|
||||
| `test_batchwriter_idempotent_on_replay` | 断点续传重发:幂等去重 |
|
||||
| `test_sample_fields_preserved_end_to_end` | 样本字段端到端完整 |
|
||||
| `test_health_metrics_reflect_collection` | 健康度随轮次累计,满足 SLA(P99≤1.8s / 丢失率≤0.02% / 可用性≥99.8%) |
|
||||
|
||||
### 问答流(PRD 5.4)
|
||||
`rag-kb` 模板化知识库检索(命中文档片段 + 来源)→ `llm-gateway` 混合网关
|
||||
(敏感度路由 → 生成 → 幻觉/溯源校验 → DLP 出站防线)。
|
||||
|
||||
| 用例 | 验证点 |
|
||||
|------|--------|
|
||||
| `test_kb_retrieval_returns_relevant_chunks_with_source` | RAG 检索命中并带来源 |
|
||||
| `test_kb_category_filter` | 类别过滤(工艺规范 / SOP / 国标) |
|
||||
| `test_normal_question_routes_local_with_rag_context` | 普通问题 → 本地后端 + 来源引用 |
|
||||
| `test_sensitive_query_blocked_by_dlp` | 敏感数据 → DLP 拦截 → block → 转人工 |
|
||||
| `test_generic_question_routes_cloud` | 通用问题 DLP 放行闭环正常 |
|
||||
| `test_high_stakes_low_confidence_to_human` | 高利害 + 低信度 → 转人工复核 |
|
||||
| `test_audit_drain_after_query` | 各组件审计记录可统一导出 |
|
||||
|
||||
### 跨链路集成(业务闭环)
|
||||
采集 → 落库 → 知识沉淀 → 安全问答的完整业务闭环(`test_cross_pipeline.py`)。
|
||||
|
||||
## 运行方式
|
||||
|
||||
```bash
|
||||
# 在仓库根目录执行(需 Python 3.8+,仅标准库依赖)
|
||||
python -m unittest discover -s tests/e2e -v
|
||||
```
|
||||
|
||||
## 设计说明
|
||||
|
||||
- **零外部依赖**:四个内核模块的存储 / 推理 / 协议接入均设计为可注入接口
|
||||
(`StoreSink` / `InferenceBackend` / `Driver`),联调用内存桩替换真实后端,
|
||||
保证 CI 可重复执行且不污染环境。
|
||||
- **模块加载**:四个 core 模块的源码组织方式不一致(edge-gateway 为裸导入,
|
||||
其余为带连字符目录名的包),由 `_bootstrap.py` 统一加载(详见该文件注释)。
|
||||
- **断言对齐 PRD 验收基线**:健康度断言直接引用 PRD 第 9 章 NFR 阈值
|
||||
(P99≤1.8s / 丢失率≤0.02% / 可用性≥99.8%),DLP 断言验证 100% 拦截目标。
|
||||
Reference in New Issue
Block a user