4e21ca937a
Deploy Documentation / deploy (push) Has been cancelled
Canary / Prepare Version (push) Has been cancelled
Canary / build-cli (push) Has been cancelled
Canary / Upload Install Script (push) Has been cancelled
Canary / bundle-desktop (push) Has been cancelled
Canary / bundle-desktop-intel (push) Has been cancelled
Canary / bundle-desktop-linux (push) Has been cancelled
Canary / bundle-desktop-windows (push) Has been cancelled
Canary / bundle-desktop-windows-cuda (push) Has been cancelled
Canary / Release (push) Has been cancelled
Unused Dependencies / machete (push) Has been cancelled
CI / changes (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / H5 Plaza Tests and Build (push) Has been cancelled
Live Provider Tests / check-fork (push) Has been cancelled
Live Provider Tests / changes (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
Live Provider Tests / goose server HTTP integration tests (push) Has been cancelled
Publish Ask AI Bot Docker Image / docker (push) Has been cancelled
Publish Docker Image / docker (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fork goose with custom MCP widgets, platform extensions (aider, git, web, search), MindSpace H5 backend/frontend, Plaza/Ops UIs, and deploy scripts for tkmind.cn. Co-authored-by: Cursor <cursoragent@cursor.com>
273 lines
5.9 KiB
Markdown
273 lines
5.9 KiB
Markdown
---
|
||
sidebar_position: 12
|
||
title: Testing, Acceptance, and Operations
|
||
sidebar_label: Testing and Operations
|
||
description: MindSpace test matrix, release gates, deployment, backup, monitoring, and incident response
|
||
---
|
||
|
||
# 测试、验收、部署与运维
|
||
|
||
## 测试层次
|
||
|
||
### 单元测试
|
||
|
||
- 状态机转换。
|
||
- slug 和文件名规范化。
|
||
- 配额计算。
|
||
- 套餐规则。
|
||
- PII 掩码。
|
||
- HTML sanitizer。
|
||
- 发布访问策略。
|
||
- Agent 权限策略。
|
||
|
||
### repository 测试
|
||
|
||
- 用户隔离。
|
||
- 唯一约束。
|
||
- 乐观锁。
|
||
- 配额原子更新。
|
||
- 软删除和引用检查。
|
||
- cursor 分页。
|
||
|
||
### API 集成测试
|
||
|
||
- 认证和会话。
|
||
- 上传完整生命周期。
|
||
- 资产移动和删除。
|
||
- 聊天保存页面。
|
||
- 发布、重新发布和下线。
|
||
- 分享访问。
|
||
- 安全扫描和脱敏。
|
||
- Agent job 回调。
|
||
|
||
### 端到端测试
|
||
|
||
- 注册到公开发布。
|
||
- 上传 Excel 到报告页面。
|
||
- 私人文件到脱敏副本。
|
||
- 聊天消息到主页卡片。
|
||
- 编辑草稿但线上版本不变。
|
||
- 移动端上传和发布。
|
||
|
||
## 必测权限矩阵
|
||
|
||
对每个资源执行:
|
||
|
||
- owner 成功。
|
||
- 其他用户读取失败。
|
||
- 其他用户修改失败。
|
||
- 其他用户删除失败。
|
||
- 未登录失败。
|
||
- 管理员按后台规则成功并有审计。
|
||
- Agent 只在 job 授权内成功。
|
||
|
||
资源:
|
||
|
||
- Space。
|
||
- Category。
|
||
- Asset。
|
||
- AssetVersion。
|
||
- Page。
|
||
- PageVersion。
|
||
- Publication。
|
||
- SecurityScan。
|
||
- AgentJob。
|
||
- AuditLog。
|
||
|
||
## 上传测试
|
||
|
||
- 0 字节文件。
|
||
- 正好达到大小上限。
|
||
- 超过大小上限。
|
||
- MIME 与扩展名不一致。
|
||
- 同名文件。
|
||
- checksum 不匹配。
|
||
- 上传中断和重试。
|
||
- 取消释放配额。
|
||
- 并发上传超过剩余配额。
|
||
- 压缩炸弹和恶意宏。
|
||
- 文件名含路径分隔、Unicode 和控制字符。
|
||
|
||
## 页面和发布测试
|
||
|
||
- slug 冲突。
|
||
- 重复发布幂等。
|
||
- 两个客户端同时编辑。
|
||
- 发布构建失败时旧版本在线。
|
||
- 私有资源引用。
|
||
- 跨用户资源引用。
|
||
- XSS、脚本、iframe、外链和跳转。
|
||
- 下线后缓存失效。
|
||
- 过期时间到达后不可访问。
|
||
- 删除 Page 前自动下线或拒绝。
|
||
|
||
## 脱敏测试
|
||
|
||
- 手机、邮箱、身份证、银行卡和地址。
|
||
- 同一值多次出现。
|
||
- 跨段落和表格。
|
||
- 图片 OCR 结果。
|
||
- 误报确认。
|
||
- 高风险阻断。
|
||
- 输出二次扫描。
|
||
- 原资产不被修改。
|
||
- finding 不保存完整敏感原文。
|
||
|
||
## Agent 测试
|
||
|
||
- 读取允许资产。
|
||
- 读取未授权资产。
|
||
- 写入错误分类。
|
||
- 任务取消。
|
||
- token 过期。
|
||
- Worker 崩溃和重试。
|
||
- heartbeat 丢失。
|
||
- 文档 prompt injection。
|
||
- 网络和 shell 被拒绝。
|
||
- 输出超限和恶意 HTML。
|
||
- 重试不重复生成。
|
||
|
||
## 性能基线
|
||
|
||
MVP 目标可按环境调整:
|
||
|
||
- 空间首页 P95 小于 500 ms,不含首次冷启动。
|
||
- 资产列表 P95 小于 500 ms。
|
||
- 公开静态页面 P95 小于 300 ms。
|
||
- 上传接口流式处理,不将完整文件读入内存。
|
||
- 公开页面可水平扩展。
|
||
- 大型文档解析全部异步。
|
||
|
||
## 发布前验收
|
||
|
||
### 功能
|
||
|
||
- 10 个核心页面流程可用。
|
||
- 桌面和移动端可完成主流程。
|
||
- 空状态和失败恢复完整。
|
||
|
||
### 安全
|
||
|
||
- 越权测试通过。
|
||
- 路径穿越测试通过。
|
||
- XSS 和私有引用测试通过。
|
||
- 分享和登录限流生效。
|
||
- 日志无敏感值。
|
||
|
||
### 数据
|
||
|
||
- 配额对账一致。
|
||
- 发布版本可追溯。
|
||
- 审计记录完整。
|
||
- 备份和恢复演练成功。
|
||
|
||
### 工程
|
||
|
||
- `cargo fmt`。
|
||
- 仅在用户明确要求构建或测试时,按仓库规则运行相关 `cargo build`、目标测试和 clippy。
|
||
- 服务端 schema 变化后生成 OpenAPI。
|
||
- 前端生成类型已同步。
|
||
|
||
## 部署拓扑
|
||
|
||
MVP:
|
||
|
||
```text
|
||
Nginx/Proxy
|
||
-> H5 static
|
||
-> goose-server / MindSpace API
|
||
-> Agent worker
|
||
-> SQL database
|
||
-> local storage or object storage
|
||
```
|
||
|
||
生产增强:
|
||
|
||
- API 多实例。
|
||
- 独立 worker 池。
|
||
- 对象存储。
|
||
- Redis/queue。
|
||
- 公开页面静态服务或 CDN。
|
||
- 独立页面域。
|
||
|
||
## 部署步骤
|
||
|
||
1. 备份数据库。
|
||
2. 执行兼容性迁移。
|
||
3. 部署后端。
|
||
4. 启动 worker。
|
||
5. 部署前端。
|
||
6. 更新代理和安全响应头。
|
||
7. 执行 smoke test。
|
||
8. 开启功能开关。
|
||
9. 观察错误、队列和发布指标。
|
||
|
||
## 回滚
|
||
|
||
- 应用回滚不能依赖删除新字段。
|
||
- 发布 bundle 是不可变的,可切回旧版本。
|
||
- 数据迁移优先向后兼容。
|
||
- 功能开关可停止新上传、新 Agent job 或新发布。
|
||
- 紧急情况下保持管理端可下线页面和撤销链接。
|
||
|
||
## 备份与恢复
|
||
|
||
- 数据库定期全量和增量备份。
|
||
- 对象存储开启版本或生命周期策略。
|
||
- 备份包含数据库与存储的一致时间点说明。
|
||
- 定期抽样恢复用户 Space、Page 和 Publication。
|
||
- 恢复后重新对账 checksum、配额和发布 manifest。
|
||
|
||
## 监控与告警
|
||
|
||
告警:
|
||
|
||
- 5xx 激增。
|
||
- 数据库连接耗尽。
|
||
- 上传失败率。
|
||
- Agent 队列积压。
|
||
- 安全扫描失败或 critical 命中。
|
||
- 发布构建失败率。
|
||
- 对象存储错误。
|
||
- 配额对账异常。
|
||
- 越权请求异常增长。
|
||
- 公开页面无法访问。
|
||
|
||
## 定时任务
|
||
|
||
- 清理过期 upload session。
|
||
- 清理 Agent 临时目录。
|
||
- 下线过期 Publication。
|
||
- 聚合访问统计。
|
||
- 配额对账。
|
||
- 检查孤儿对象。
|
||
- 重试可恢复任务。
|
||
- 清理超期审计和访问事件,遵循保留策略。
|
||
|
||
## 事故响应
|
||
|
||
### 私人内容误发布
|
||
|
||
1. 立即下线并失效缓存。
|
||
2. 撤销分享 token。
|
||
3. 保留审计和版本证据。
|
||
4. 确认访问范围。
|
||
5. 通知用户和安全负责人。
|
||
6. 修复规则并重扫相关内容。
|
||
|
||
### 跨用户访问漏洞
|
||
|
||
1. 暂停相关接口或功能开关。
|
||
2. 撤销会话和 Agent token。
|
||
3. 查询审计确定影响范围。
|
||
4. 修复和补充回归测试。
|
||
5. 按合规要求通知。
|
||
|
||
### 存储损坏
|
||
|
||
1. 切换只读或停止写入。
|
||
2. 根据 checksum 确定损坏对象。
|
||
3. 从备份恢复。
|
||
4. 对账资产版本和配额。
|
||
|