Files
mtusi2026lab3/evidence/tests/failure-checks.md
T
ricoromaandClaude Opus 5.5 c5840bfaa8 docs: add idempotency and X-Instance-Id evidence to the report
- evidence for replay, conflict, replay through a new API process and
  after restarting API and storages, keys table, key race,
  X-Instance-Id in responses and logs, explicit and invalid
  instance_id and key TTL, test runs
- stand evidence: make wipe_data leaves the lab 2 volume intact, build
  from a fresh git clone passes smoke, bench restore stage sends with
  Idempotency-Key
- REPORT.md: X-Instance-Id, idempotency design, IDEMPOTENCY_TTL_SECONDS
  mapping, limitations and evidence rows
- tasks.md: mark the change tasks done, add follow-ups from verify

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 17:08:47 +03:00

63 lines
5.1 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.
# `make failure_checks`: проверки отказов, с лабы 3 — и ключа идемпотентности
| | |
|---|---|
| Спеки | `student-tests` «Проверки отказов на отдельном стенде» — «Успешный прогон»; `idempotency` «Сбой при записи сообщения», «Отказ БД при отправке», «Ключ после срока»; сценарии лабы 2 — таблица ниже |
| Change | `instance-id-idempotency`, задача 9.1 |
| Дата | 2026-10-08 16:46:24 UTC, 53 с |
| Commit | `af4bca0` |
| Стенд отказов | проект compose `mtusi-lab3-failures`: свои PostgreSQL и Valkey со своим volume, порты не публикуются; обычный API и «тесный» (`AUTH__SESSION_TTL_SECONDS=2`, `IDEMPOTENCY__TTL_SECONDS=2`, `DATABASE__POOL_SIZE=1`, `DATABASE__MAX_OVERFLOW=0`, `DATABASE__POOL_TIMEOUT_SECONDS=1`, `DATABASE__REQUEST_TIMEOUT_SECONDS=2`) на свободных портах `127.0.0.1` |
| Рабочий стенд | `make run_docker` запущен (API на `127.0.0.1:8080`), во время прогона не трогался: `StartedAt` postgres и valkey — 2026-10-08T13:50:04Z до и после |
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; лимиты контейнерам не задавались |
На хранилища тесты действуют только через hook
`student-tests/fault_hook.py` (фикстура `stand`). С лабы 3 у hook есть
`fail-messages <text>` / `clear-fail-messages`: триггер `BEFORE INSERT
ON messages` роняет вставку сообщения с этим текстом — уже после того,
как в той же транзакции вставлен ключ идемпотентности.
## Прогон
```text
$ make failure_checks # exit 0, 53 с
[failure_checks] project=mtusi-lab3-failures (working stand: mtusi-lab3)
[failure_checks] build image
[failure_checks] start postgres and valkey
[failure_checks] migrations
[failure_checks] start api containers
[failure_checks] ready: api=http://127.0.0.1:61881 tight=http://127.0.0.1:61885
[failure_checks] pytest -m fault
student-tests/test_failures.py::test_expired_token PASSED [ 6%]
student-tests/test_failures.py::test_use_does_not_extend_session PASSED [ 13%]
student-tests/test_failures.py::test_token_while_database_stopped PASSED [ 20%]
student-tests/test_failures.py::test_members_failure_rolls_back_chat PASSED [ 26%]
student-tests/test_failures.py::test_database_stopped_and_back PASSED [ 33%]
student-tests/test_failures.py::test_pool_exhausted PASSED [ 40%]
student-tests/test_failures.py::test_readiness_without_database PASSED [ 46%]
student-tests/test_failures.py::test_readiness_without_cache PASSED [ 53%]
student-tests/test_failures.py::test_flush_cache PASSED [ 60%]
student-tests/test_failures.py::test_valkey_stopped PASSED [ 66%]
student-tests/test_failures.py::test_valkey_paused PASSED [ 73%]
student-tests/test_failures.py::test_valkey_back PASSED [ 80%]
student-tests/test_failures.py::test_message_failure_keeps_key_free PASSED [ 86%]
student-tests/test_failures.py::test_database_outage_keeps_key_free PASSED [ 93%]
student-tests/test_failures.py::test_key_free_after_ttl PASSED [100%]
===================== 15 passed, 127 deselected in 42.82s ======================
[failure_checks] cleanup
[failure_checks] results: {'fault': 0}
```
После прогона контейнеров `mtusi-lab3-failures-*` нет, volume стенда
отказов удалён.
## Проверки лабы 3
| Тест | Сценарий | Что проверяет |
|---|---|---|
| `test_message_failure_keeps_key_free` | «Сбой при записи сообщения» | ключ вставлен, вставка сообщения падает на триггере → 500; после снятия триггера повтор с тем же ключом и телом — 201, в истории ровно одно сообщение: ключ откатился вместе с транзакцией |
| `test_database_outage_keeps_key_free` | «Отказ БД при отправке» | Postgres остановлен: отправка с ключом → 503; после возврата повтор с тем же ключом — 201, одно сообщение |
| `test_key_free_after_ttl` | «Ключ после срока» | «тесный» API, срок ключа 2 с: в пределах срока другое тело — 409; через 2,3 с (новая сессия — срок сессии тоже 2 с) тот же ключ с другим телом — 201 и новое сообщение |
Остальные 12 — проверки лабы 2 (сессии, БД, пул, readiness, Valkey):
по-прежнему проходят, отправки сообщений в них идут с ключом.