Files
Nexus/docs/project/local-integration-test.md
2026-07-08 22:31:31 +08:00

88 lines
2.0 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.
# 本地代码验证(Ubuntu / Linux
> **只做一件事**:在本机确认代码能启动、单测通过、关键 HTTP 行为正确。
> **不做**:生产部署清单、浏览器手测、Agent 全量 E2E。
环境:Ubuntu 原生 + DockerMySQL + Redis+ Python 3.12 + 项目根 `.env`
---
## 一键(推荐)
```bash
cd "$NEXUS_ROOT" # 例:~/桌面/Nexus
bash scripts/local_verify.sh
```
顺序:启动 Docker MySQL/Redis → uvicorn → smoke → `test_api.py` → ruff。
---
## 分步
**首次 — 依赖**
```bash
bash scripts/ensure_venv.sh
python3 docker/generate_env.py # 若无 docker/.env
python3 docker/sync_root_env.py # 生成根 .env
```
**启动**
```bash
bash scripts/start-dev.sh
```
**验证**
```bash
bash scripts/local_integration_smoke.sh
.venv/bin/python tests/test_api.py
```
| 项 | 预期 |
|----|------|
| `tests/test_security_unit.py` + retry | 全部 passed |
| `GET /health` | 200 |
| `GET /api/servers/` | 401JWT |
| `tests/test_api.py` | 26/26 passed |
---
## Docker 权限
`docker` 报 permission denied,脚本会自动 `sg docker`。或:
```bash
sudo usermod -aG docker "$USER" # 重新登录后免 sg
```
Redis 检测:优先 `redis-cli`;未安装时用 `docker exec nexus-redis-1 redis-cli ping`(无需 apt 装 redis-tools)。
---
## 无 `.env`
`bash scripts/start-dev.sh`,浏览器打开 `http://127.0.0.1:8600/app/install.html` 完成向导,或:
```bash
NEXUS_TEST_ADMIN_PASSWORD='你的密码' python3 scripts/seed_local_admin.py
```
---
## 脚本索引
| 脚本 | 作用 |
|------|------|
| `scripts/start-dev.sh` | Docker mysql+redis + uvicorn |
| `scripts/local_verify.sh` | 一键启动 + 全量本地验证 |
| `scripts/local_integration_smoke.sh` | smoke(不启动服务) |
| `scripts/ensure_venv.sh` | 创建 `.venv` |
| `scripts/check_mysql.py` | MySQL 连通与表检查 |
上线验收见 [`production-verification-checklist.md`](production-verification-checklist.md)。
路径 SSOT[`linux-dev-paths.md`](linux-dev-paths.md)