Files
Nexus/docs/changelog/2026-06-01-test-api-health-prune-followup.md
2026-07-08 22:31:31 +08:00

57 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Changelog — test_api 健康检查与生产 Gate 跟进
**日期**: 2026-06-01
**类型**: 修复 / 运维跟进
## 摘要
- `tests/test_api.py``GET /health` 改为断言纯文本 `ok`(与 `server/api/health.py``PlainTextResponse` 一致),不再 `json.loads`
- 生产 `.env``NEXUS_TEST_ADMIN_PASSWORD` 须与数据库 `admin` 密码一致;原值 `Nexus@2026Test` 导致 Gate 3 登录 401。
## 动机
部署后 `python3 tests/test_api.py` 18/18 失败:健康检查因期望 JSON 解析失败;其余用例因未拿到 JWT 连锁失败。
## 涉及文件
- `tests/test_api.py` — 新增 `test_plain_text()``/health` 用例改用
- 生产 `/www/wwwroot/api.synaglobal.vip/.env``NEXUS_TEST_ADMIN_PASSWORD` 对齐真实管理员密码(运维操作,不入库)
## 前置条件
- `NEXUS_TEST_ADMIN_USER` / `NEXUS_TEST_ADMIN_PASSWORD` 与 MySQL `admins` 表一致
- 后端监听 `NEXUS_TEST_BASE`(默认 `http://127.0.0.1:8600`
## 迁移 / 重启
- 仅改测试脚本:无需重启;改 `.env` 后无需重启(测试进程读环境变量)
- 前端 assets prune:务必先 `python deploy/prune_frontend_assets.py --dry-run`,确认 `would_remove` 合理后再实删
## 验证
```bash
# 服务器
cd /www/wwwroot/api.synaglobal.vip
python3 tests/test_api.py
# 预期:Results: N/N passed, 0 failed
curl -s http://127.0.0.1:8600/health # ok
```
## 回滚
- 还原 `tests/test_api.py` 中 health 用例为旧版(不推荐,与 API 契约不符)
- `.env` 测试密码改回前值仅当故意使用独立测试账号时
## 2026-06-01 晚间追加(前端部署)
- `vite build` + tar/scp 部署至生产 `web/app/`
- **事故**`prune_frontend_assets.py` 正则首字符不允许 `_`,误删 `_plugin-vue_export-helper-*.js` → 全站白屏;已 scp 恢复并修复正则 `[_A-Za-z0-9]...`
- **后端**`RefreshRequest.refresh_token` 改为 Optional,空 body `{}` 不再 422
- **浏览器验证**`#/servers` 勾选 2 台后出现「已选择 2 台服务器」及批量按钮(含 `normalizeServerIds``ServersPage-Vzm34hgn.js`
## 关联
- `docs/changelog/2026-06-01-bug-remediation.md`
- `deploy/prune_frontend_assets.py`(Rolldown 闭包引用扫描;须匹配 `_plugin-vue_export-helper` 等 chunk