add code for level 4

This commit is contained in:
Матвей
2026-10-08 19:08:55 +03:00
parent b158c88087
commit 13fa322ca2
21 changed files with 390 additions and 27 deletions
+20
View File
@@ -30,6 +30,22 @@ curl -fsS http://localhost:8080/health/ready
make test
chmod +x scripts/restart.sh
make test-persistence ACTION_SCRIPT=scripts/restart.sh
make test-grade4
```
Для проверки короткого TTL временно пересоздайте только API:
```sh
SESSION_TTL_SECONDS=2 docker compose --env-file .env.example up -d --force-recreate api
docker compose --env-file .env.example up -d --wait api
python3 student-tests/session_expiry.py
SESSION_TTL_SECONDS=3600 docker compose --env-file .env.example up -d --force-recreate api
```
План запроса истории создаётся на 10 000 синтетических сообщениях:
```sh
./scripts/explain_history.sh | tee evidence/explain-history-local.txt
```
Обычная остановка сохраняет учебные данные:
@@ -74,6 +90,10 @@ Logout удаляет текущую серверную сессию. Срок
| Согласованность lock-файла | `uv lock --check` | PASS | выполнено |
| Публичный smoke | `make test` | `PASS: lab2 public API scenario` | `evidence/smoke-2026-10-08.txt` |
| Persistence | `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | `PASS: persistence preserved confirmed data and existing session` | `evidence/persistence-2026-10-08.txt` |
| Redis cache | `make test-grade4`; `redis-cli --scan` | read-after-write без stale read; создан ключ `history:first:…` | `evidence/redis-cache-2026-10-08.txt` |
| Гонка и rollback | `make test-grade4` | Ровно одна регистрация успешна; неуспешный чат не виден | `evidence/grade4-checks-2026-10-08.txt` |
| TTL и зависимости | `make test-grade4`; TTL=2 | Expired session → 401; Redis fallback проходит smoke; DB readiness → 503 | `evidence/grade4-checks-2026-10-08.txt` |
| Индекс истории | `./scripts/explain_history.sh` | Index Scan, 50 строк, shared hit=3 | `evidence/explain-history-2026-10-08.txt` |
## Ограничения и следующие шаги