73 lines
1.8 KiB
Markdown
73 lines
1.8 KiB
Markdown
|
|
# WSL 代码验证
|
|||
|
|
|
|||
|
|
> **只做一件事**:在 WSL 里确认代码能启动、单测通过、关键 HTTP 行为正确。
|
|||
|
|
> **不做**:密钥/git 核对、生产部署清单、浏览器手测、Agent、CRUD 全量 E2E。
|
|||
|
|
|
|||
|
|
环境:WSL + MySQL + Redis + Python 3.12 + 本地 `.env`(内容由 install 生成即可,WSL 不审 key)。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 三步
|
|||
|
|
|
|||
|
|
**终端 1 — 依赖(首次)**
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd <项目根>
|
|||
|
|
bash scripts/wsl_ensure_venv.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**终端 1 — 启动**
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
bash scripts/wsl_start_dev.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**终端 2 — 验证**
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
bash scripts/wsl_integration_smoke.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
默认即 `--code-only`,检查项:
|
|||
|
|
|
|||
|
|
| 项 | 预期 |
|
|||
|
|
|----|------|
|
|||
|
|
| `tests/test_security_unit.py` | 15 passed |
|
|||
|
|
| `GET /health` | 200,`redis`/`mysql` 为 ok |
|
|||
|
|
| `GET /api/servers/` | 401(JWT 中间件) |
|
|||
|
|
|
|||
|
|
全绿 = **WSL 代码验证通过**。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 环境未就绪时
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
sudo service redis-server start # redis-cli ping → PONG
|
|||
|
|
bash scripts/wsl_ensure_venv.sh # PEP 668 用 .venv
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
无 `.env`:先 `bash scripts/wsl_start_dev.sh`,浏览器走 `http://127.0.0.1:8600/app/install.html` 生成 `.env` 后再跑 smoke。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 启动报错(代码层已修)
|
|||
|
|
|
|||
|
|
| 现象 | 说明 |
|
|||
|
|
|------|------|
|
|||
|
|
| Redis `unexpected keyword argument 'url'` | 需 `BlockingConnectionPool.from_url()` |
|
|||
|
|
| MySQL `ping() missing reconnect` | 需 `engine_compat.patch_aiomysql_do_ping()` + venv 内 SQLAlchemy 2.0.49 |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 脚本
|
|||
|
|
|
|||
|
|
| 脚本 | 作用 |
|
|||
|
|
|------|------|
|
|||
|
|
| `scripts/wsl_ensure_venv.sh` | 创建 `.venv` 并安装依赖 |
|
|||
|
|
| `scripts/wsl_start_dev.sh` | 启动 uvicorn |
|
|||
|
|
| `scripts/wsl_integration_smoke.sh` | 代码验证(默认) |
|
|||
|
|
| `scripts/wsl_integration_smoke.sh --start` | 检查环境后前台启动 |
|
|||
|
|
|
|||
|
|
上线与业务验收见 [`production-verification-checklist.md`](production-verification-checklist.md)(与 WSL 无关)。
|