Files
vscode-workbench/PLANNING/PROGRESS_D-02.md
T

34 lines
1.8 KiB
Markdown
Raw 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.
# PROGRESS — D-02 · PG 并发测试环境(激活 4 个 skipped)
- 状态:done
> 日期 2026-09-13 · 范围:只改 `gj/dealerhub` 目录(新建 `backend/docs/pgtest.md` 一文件,零代码变更)
## 现状 vs 差距(接手时)
- 已有:`config/settings/pgtest.py`(PG DSN,环境变量覆盖)+ `scripts/setup_pg.py`(建库+迁移)+
`tests/test_concurrency.py` 4 个 `@pytest.mark.postgres` 真并发用例 +
`conftest.py` 自动跳过守卫 + `pytest.ini` marker 注册。
- 缺口(任务卡验收项):`backend/docs/pgtest.md` 缺失;4 用例需在本机真实跑通贴输出。
## 改动
1. `backend/docs/pgtest.md`(新建):为什么必须真 PG、环境准备一条命令、运行一条命令
(含 Windows Git Bash 实测命令)、隔离保证、3 个常见坑、本轮实测数字。
## 验证(本机 PG 16,127.0.0.1:5433,全部实跑)
```bash
python scripts/setup_pg.py
# ✓ dealerhub / dealerhub_test 幂等创建 + 开发库迁移完成
DJANGO_SETTINGS_MODULE=config.settings.pgtest python -m pytest tests/test_concurrency.py -p no:cacheprovider -m postgres
# 4 passed, 11 deselected in 11.20s
DJANGO_SETTINGS_MODULE=config.settings.pgtest python -m pytest -p no:cacheprovider
# 516 passed in 100.25s(0 skipped)
python -m pytest tests/test_concurrency.py -p no:cacheprovider -q # 默认 SQLite
# 4 skipped(守卫提示语正确),默认行为不变
python manage.py makemigrations --check --dry-run # No changes detected
python manage.py check # 0 issues
```
## 状态
done。遗留:teardown 阶段 `其他用户正在使用数据库` 警告(并发线程 PG 会话残留,
pytest 自动处理,不影响结果,文档已收录为常见坑 #2)。