e2e-tester
Skill59 starsChanged 2 months agoApache-2.0View on GitHub
Use when you need to run E2E HTTP integration tests against the DatI backend, verify bug fixes, or validate API behavior using test cases defined in e2e-tests/test-cases/
The file
Files
E2E Tester
核心原则
站在用户使用角度审视一切。 用例只是操作指引,不代表完整验收标准。执行每个步骤时主动审视返回内容的合理性:
- 检查所有返回字段是否完整、合理、自洽
- 时间戳是否合理?ID 格式是否规范?关联数据是否一致?
- 发现任何不合理之处,即使用例没写,也要在报告中标出(WARN 级别)
执行模式
模式 A:当前进程(单模块快速验证)
Agent 逐步执行用例,负责服务的完整生命周期:启动 → 执行 → 关闭。服务启停一律用 scripts/service.sh(配置从 test-env.yaml server.* 读取),不要自行拼启动命令。
模式 B:子进程(批量 / CI)
调度器通过封装脚本并行运行多个模块(子进程调度、stdin 重定向等细节已由脚本封装,直接调用即可):
# 全部模块
scripts/run-tests.sh
# 指定模块
scripts/run-tests.sh datasource subject term文件结构
e2e-tests/
test-env.yaml # 环境配置(base_url、启动命令)
test-data.yaml # 公共测试数据(用户、连接信息)
test-cases/<module>.md # 测试用例
BUGS.yaml / BUGS-FIXED.yamlExecution Flow
1. 加载配置
始终加载 e2e-tests/test-env.yaml 和 docs/api/openapi.json。
2. 认证
用例前置包含「已登录」时:
- 使用 test-data.yaml 中的固定用户
qa_user直接登录 - 若用户不存在则注册,若注册返回「already exists」则直接登录,均不视为失败
3. 执行步骤
对每个步骤:理解意图 → 匹配 API(openapi.json)→ 构造 curl 请求 → 语义断言。
构造请求规则:
- 字段名以 openapi.json schema 为准
- body 使用 snake_case
- 分离响应体与状态码:
curl -w "\n__HTTP__%{http_code}"
4. 生成报告
## E2E Test Report
PASS TC-DS-001 创建、查询、删除数据源
✓ 创建成功 → 200
⚠ password 字段在列表响应中明文暴露
FAIL TC-DS-008 删除不存在的数据源
✗ 预期返回 404,实际返回 200
---
Total: 2 executed, 1 passed, 1 failed
Warnings: 15. Bug 跟踪
禁止手改 BUGS.yaml / BUGS-FIXED.yaml。 所有 Bug 生命周期操作必须通过 scripts/bug-tracker.sh 执行,确保 ID 格式和字段结构一致。
**Bug 修复后必须 E2E 验证通过才能标记 FIXED
测试完成后交叉比对 BUGS.yaml:
发现的问题 → 查 BUGS.yaml
├─ 匹配到已有 → 更新 found_at
├─ 匹配到 FIXED → REGRESSION!移回 BUGS.yaml
└─ 未匹配 → 用 bug-tracker.sh add 新增之前 open 的问题本次未复现 → 用 bug-tracker.sh fix 移入 FIXED。
之前 fixed 的问题本次复现 → 用 bug-tracker.sh regress 移回 BUGS.yaml。
脚本工具
| 脚本 | 用途 |
scripts/service.sh | 服务生命周期 |
scripts/run-tests.sh | 一键测试调度器 |
scripts/bug-tracker.sh | Bug 生命周期管理 |
scripts/helpers.sh | 公共辅助函数(source 使用) |
scripts/mcp-verify.sh | MCP endpoint 验收(Inspector CLI + Conformance 2025-11-25),配套 scripts/mcp-conformance-proxy.js(JWT 注入代理,Conformance CLI 不支持自定义 header);目标服务配置从 test-env.yaml mcp: 读取,凭据用 test-data.yaml 固定 API Key(TC-AK-009) |
scripts/api-key-verify.sh | API Key 全生命周期 e2e(TC-AK-001~009,含固定 key 构造供 mcp-verify.sh 复用) |
所有脚本支持 --help 查看详细用法。Agent 直接调用:
scripts/run-tests.sh # 全模块
scripts/run-tests.sh datasource # 单模块
scripts/bug-tracker.sh fix BUG-20260724-001
# MCP endpoint 验收(需已发布服务,用例见 e2e-tests/test-cases/mcp-endpoint.md)
# 服务代码等配置默认从 test-env.yaml 读取,可环境变量覆盖
# 凭据用 test-data.yaml 固定 API Key(TC-AK-009,永不过期,推荐)
MCP_TOKEN=<sk_...> MCP_DS_ID=<dsId> scripts/mcp-verify.sh常见陷阱
字段命名
| 错误 | 正确 |
登录传 username | required 字段是 name、password、type |
DataSource 用 host+port | 用 jdbc_url(完整 JDBC URL) |
type 用小写 | 大写枚举:POSTGRESQL、MYSQL、H2 |
忘传 type: "local" | Login 的 type 是 required |
认证
/v1/**大多需要 token(除/v1/auth/*)test-connection也需要认证
服务
- 服务启停一律用
scripts/service.sh(test-env.yamlserver.*是唯一配置源),不要硬编码端口/路径/启动命令
ES
- 写入后查询 ES 前必须先
es_refresh,否则异步索引延迟会导致误报查不到数据 - 用法:测试会话开头
source scripts/helpers.sh,之后在任何 ES 查询前调用es_refresh
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

