Files
sino-mci/docs/superpowers/specs/2026-07-07-compose-consolidation-and-test-plan.md

3.6 KiB
Raw Blame History

sino-mci Docker Compose 整合与测试计划

目标

  1. 整合当前分散的 infrastructure/docker-compose.ymldocker-compose.app.yml,形成一份清晰、可维护的编排配置。
  2. 使用 java/mvnnpmcurl 与 Chrome DevTools 对对外接口和管理后台流程进行系统验证。

当前问题

  • 两个 compose 文件分别管理基础设施与应用服务,启动脚本需要分两次执行。
  • docker-compose.app.yml 曾因 depends_on 跨 compose project 报错,已临时移除,但缺少服务健康检查与启动顺序控制。
  • admin-web 缺少 npm test 脚本,无法通过 npm 运行自动化验证。
  • 没有一份统一的对外接口测试清单与 UI 流程测试清单。

整合方案

采用 单文件 + profiles 方案:

  • 文件:docker-compose.yml 放在项目根目录。
  • 服务:
    • mysqlredisrabbitmqseaweedfs 标记 profile: ["infra"],默认不启动。
    • mci-serveradmin-webchannel-service 标记 profile: ["app"],默认不启动。
  • 启动命令:
    • docker compose --profile infra up -d 启动基础设施。
    • docker compose --profile app up -d 启动应用服务。
    • ./scripts/local-up.sh 内部简化为依次带 profile 启动并等待健康检查。
  • 网络:统一使用 mci-network,脚本负责创建。
  • 健康检查:为 MySQL、RabbitMQ、mci-server 增加 healthcheckdepends_on 使用 condition: service_healthy
  • 删除冗余的 infrastructure/docker-compose.ymldocker-compose.app.yml

测试计划

1. 后端单元测试java / mvn

cd backend/mci-server
JAVA_HOME=/opt/homebrew/opt/openjdk@21 mvn test

预期7 个测试全部通过。

2. Python 渠道服务测试pytest

cd channel-service
source .venv/bin/activate
pytest

预期6 个测试全部通过。

3. 前端构建验证npm

cd admin-web
npm install
npm run build

预期:dist/ 生成成功,无 TypeScript 编译错误。

4. 对外 API 测试curl / 脚本)

使用 scripts/test-external-api.sh 覆盖以下接口:

接口 方法 验证点
/api/v1/account/tenant POST 创建租户成功
/api/v1/channel-subject POST 创建渠道主体成功
/api/v1/channel-account POST 创建渠道账号成功
/api/v1/conversation POST 创建会话成功
/api/v1/conversation/{id}/bind-account POST 绑定发送主号成功
/api/v1/send/test POST 测试发送成功,返回 taskId
/api/v1/send/{task_id}/records GET 查询发送记录成功
/api/v1/inbound/receive POST 入站消息接收成功
/health (channel-service) GET Python 服务健康
/v1/wechat-personal/login/start POST 登录流程返回 QR 码
/v1/wechat-personal/send/text POST 发送文本成功

5. UI 流程测试Chrome DevTools

通过浏览器访问 http://localhost/,执行以下流程

  1. 进入管理后台首页,确认左侧菜单完整加载。
  2. 进入「渠道主体」页面,创建一条渠道主体记录。
  3. 进入「渠道账号」页面,创建一条账号记录。
  4. 进入「会话/群聊」页面,创建一条会话记录。
  5. 进入「发送记录」页面,使用测试发送功能发送一条消息,并查询记录。

成功标准

  • 所有 compose 服务可通过 ./scripts/local-up.sh 一键启动。
  • Java / Python / npm 三层测试全部通过。
  • 对外 API 脚本全部返回 code: 0
  • Chrome DevTools 中 UI 流程无报错,页面元素正确渲染。