docs(test): archive P0 remediation test report
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
# P0 发布阻断整改 测试报告
|
||||
|
||||
## 一、 测试背景 (Background)
|
||||
|
||||
依据 [系统功能缺口审计与整改方案](../2026-09-11-system-functional-gap-audit-and-remediation.md),在不轮换 `.env` 的前提下完成 8 项 P0:统一鉴权与对象授权、关闭前端伪登录、路径/对账收口、goose 统一迁移与启动门禁、生产镜像打包前端、禁止生产静默内存降级。
|
||||
|
||||
## 二、 测试目标 (Test Objectives)
|
||||
|
||||
- 无 token 业务 API → 401;`X-User-ID` 不能提权
|
||||
- 客户端不能指定 `work_dir`;对账需管理员且仅接受 `run_id`
|
||||
- 断网/后端不可用无法本地伪登录;生产 `web/dist` 无默认明文账户字符串
|
||||
- goose 迁移链可执行;DB/schema 不可用且非 Demo 时 health 非 ok
|
||||
- `go test ./internal/server/... -short`、`npm test`、`npm run build` 通过
|
||||
|
||||
## 三、 测试方案与环境 (Test Plan & Environment)
|
||||
|
||||
| 项 | 值 |
|
||||
|---|---|
|
||||
| OS | linux 7.0.0-31-generic |
|
||||
| Go | 1.27.1 |
|
||||
| Node | v26.8.2 / npm 11.19.1 |
|
||||
| 后端 | `AgentBackend=stub`;KB 离线降级 |
|
||||
| DB | dev 实库(5433)经 goose 升级至 00014 |
|
||||
| 层级 | P0 专项单测 + 包级 `-short` 回归 + 前端单测 + 生产构建 |
|
||||
|
||||
## 四、 预期结果 (Expected Results)
|
||||
|
||||
| 用例 | 输入 | 预期 |
|
||||
|------|------|------|
|
||||
| P0-01 匿名 API | 无 Bearer 调 `/api/v1/tasks/runs` | 401 |
|
||||
| P0-01 X-User-ID | 仅 `X-User-ID: 1` | 401 |
|
||||
| P0-08 readiness | `AllowInMemory=false` + 无 DB | health 503 degraded |
|
||||
| P0-04 对账 | body 含 `work_dir` | 400/拒绝 |
|
||||
| P0-02 前端 | `LocalAuthClient.register` 空密码 | 抛出「必填」 |
|
||||
| P0-07 构建 | `npm run build` | 生成 `web/dist`,无默认凭据 grep 命中 |
|
||||
| 路径沙箱 | `../etc/passwd` | resolver 拒绝 |
|
||||
|
||||
## 五、 实际测试结果与判定 (Actual Results & Evaluation)
|
||||
|
||||
### 5.1 P0 专项回归(401/403/health/对账)
|
||||
|
||||
- **测试输入**:`go test ./internal/server/... -short -run TestP0 -v`
|
||||
- **实际输出**:
|
||||
```
|
||||
=== RUN TestP0_AnonymousBusinessAPIReturns401
|
||||
--- PASS: TestP0_AnonymousBusinessAPIReturns401 (0.11s)
|
||||
=== RUN TestP0_XUserIDCannotAuthenticate
|
||||
--- PASS: TestP0_XUserIDCannotAuthenticate (0.11s)
|
||||
=== RUN TestP0_HealthDegradedWhenDBRequiredButUnavailable
|
||||
--- PASS: TestP0_HealthDegradedWhenDBRequiredButUnavailable (0.11s)
|
||||
=== RUN TestP0_ReconcileRejectsClientWorkDir
|
||||
--- PASS: TestP0_ReconcileRejectsClientWorkDir (0.11s)
|
||||
PASS ok chat-agent-system/internal/server 0.457s
|
||||
```
|
||||
- **判定**:PASS
|
||||
- **耗时**:~0.46s
|
||||
|
||||
### 5.2 WorkspaceResolver 路径穿越负例
|
||||
|
||||
- **测试输入**:`go test ./internal/workspace/... -v -run TestResolver`
|
||||
- **实际输出**:`TestResolver_RejectsPathEscape --- PASS`
|
||||
- **判定**:PASS
|
||||
|
||||
### 5.3 服务端全量 short 回归
|
||||
|
||||
- **测试输入**:`go test ./internal/server/... -count=1 -short`
|
||||
- **实际输出**:`ok chat-agent-system/internal/server 4.575s`
|
||||
- **判定**:PASS(含 DocGov 认领 E2E 修复:使用任务返回的 `doc_record.doc_id`)
|
||||
|
||||
### 5.4 goose 迁移链(dev 实库)
|
||||
|
||||
- **测试输入**:`go test ./cmd/bizdev-cli/... -run TestBizdevCLIListTasks -v`(触发 `NewService` migrate-up)
|
||||
- **实际输出**:
|
||||
```
|
||||
2026/09/11 16:00:35 OK 00009_2026-09-11-message-export-policy.sql (8.11ms)
|
||||
2026/09/11 16:00:35 OK 00010_2026-09-11-project-workflows-and-lineage.sql (18.34ms)
|
||||
--- PASS: TestBizdevCLIListTasks (0.17s)
|
||||
```
|
||||
- **判定**:PASS(修复 00009 `StatementBegin/End`;交换 00011/00012 种子顺序)
|
||||
- **备注**:迁移后 `ctxmgr`/`freedoc` DB 集成测试恢复 PASS
|
||||
|
||||
### 5.5 前端鉴权与构建
|
||||
|
||||
- **测试输入**:`npm test` + `npm run build` + `rg admin-secret-password web/dist`
|
||||
- **实际输出**:
|
||||
```
|
||||
Test Files 3 passed (3)
|
||||
Tests 22 passed (22)
|
||||
✓ built in 7.51s
|
||||
no default cred strings in dist
|
||||
```
|
||||
- **判定**:PASS
|
||||
|
||||
### 5.6 生产 bundle 凭据门禁
|
||||
|
||||
- **测试输入**:`rg 'admin-secret-password|seed.*admin' web/dist`
|
||||
- **实际输出**:无匹配(`LocalAuthClient` 仅存在于源码测试路径,未打入 dist)
|
||||
- **判定**:PASS
|
||||
|
||||
## 六、 自动化测试套件汇总 (Test Suite Execution)
|
||||
|
||||
```
|
||||
go vet ./... → PASS
|
||||
go test ./internal/server/... -count=1 -short → PASS (4.58s)
|
||||
go test ./internal/workspace/... -count=1 -short → PASS
|
||||
go test ./cmd/bizdev-cli/... -count=1 -short → PASS (迁移后)
|
||||
go test ./internal/ctxmgr/... -count=1 -short → PASS (迁移后)
|
||||
go test ./internal/freedoc/... -count=1 -short → PASS (迁移后)
|
||||
go test ./... -count=1 -short → 部分 FAIL(见下)
|
||||
npm test → PASS (22/22)
|
||||
npm run build → PASS
|
||||
```
|
||||
|
||||
**全量 `go test ./... -short` 未通过包(与 P0 无直接阻塞关系,待后续迭代)**:
|
||||
|
||||
| 包 | 失败用例 | 原因摘要 |
|
||||
|---|---|---|
|
||||
| `internal/coordinator` | 2 | 回复文案断言与当前模板不一致(预存行为漂移) |
|
||||
| `internal/chat` | 2 | 异步语义索引时序 / 多轮 E2E 断言 |
|
||||
| `internal/bizdev` | 1 | `AdvisorBrief` 未返回(stub 协调器路径) |
|
||||
| `internal/storage` | 1 | 实库 `uq_mem_chunks_hash` 重复(测试数据污染) |
|
||||
|
||||
**真实 Agent 端到端**:本轮未启动 `pi-agent` + MiniMax-M3 容器全链路实测;上线前须按铁律补跑并更新本报告第五节。
|
||||
|
||||
**Docker 镜像冒烟**:本机构建 `deploy/app/Dockerfile` 耗时较长且 buildkit 日志未完整落盘;建议在 CI/`agent-main` compose 环境补验 `/`、`/api/v1/health` 与 SPA 深链接。
|
||||
|
||||
## 七、 测试结论与后续优化建议 (Conclusion & Next Steps)
|
||||
|
||||
- **P0 完成定义项均已 stub/单测层验证通过**,可合并 `dev` 并推进 `test` 分支集成。
|
||||
- goose 迁移链已在 dev 实库演练升级;生产部署前须对 `main` 卷执行 `pg_dump` 备份后再 migrate-up。
|
||||
- 后续:补 Docker 冒烟与真实 Agent E2E;修复 coordinator/chat 文案/时序漂移单测;清理 storage 集成测试重复 hash;将 `handleRunTask` 同步接入 principal(当前仍允许 legacy 测试回退)。
|
||||
Reference in New Issue
Block a user