The stand was recreated from a4ca9ef (make down, make run_docker) and
all evidence of the change was taken again on it: stand, distribution,
LB errors, test-persistence, test-failover for each replica (stop and
kill), stop-one refusals, make test and student_test through the LB,
test_isolated, failure_checks and bench self-checks.
New evidence closes scenarios verify found without proof: a real git
clone on non-default ports, a hung replica (docker pause: DOWN after
7.7 s, in-flight request 504), PostgreSQL outage behind the LB, replica
tests failing against one process, aborted responses via
driver.py kill-inflight. REPORT.md gets the corrected detection
formula, the measured cost of the 1 CPU limit for Argon2id and the new
rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
5.8 KiB
Markdown
66 lines
5.8 KiB
Markdown
# `make failure_checks`: проверки отказов на новом compose
|
||
|
||
| | |
|
||
|---|---|
|
||
| Спеки | `student-tests` «Проверки отказов на отдельном стенде» — «Успешный прогон»; `idempotency` «Сбой при записи сообщения», «Отказ БД при отправке», «Ключ после срока»; сценарии лабы 2 — таблица ниже |
|
||
| Change | `replicas-lb`, задачи 6.1 и 7.2 (прогон change `instance-id-idempotency` на `af4bca0` и прогон apply на `4e0cc4e` — в истории git этого файла) |
|
||
| Дата | 2026-10-10 15:52:58 UTC, 53 с |
|
||
| Commit | `a4ca9ef`, рабочее дерево чистое |
|
||
| Стенд отказов | проект compose `mtusi-lab3-failures` из того же `docker-compose.yml` с override `student-tests/failures.compose.yml`: свои PostgreSQL и Valkey со своим volume, порты Postgres, Valkey и LB не публикуются, `haproxy` не запускается; обычный 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`) — отдельные контейнеры `docker compose run` на свободных портах `127.0.0.1`, с лимитами сервиса `api` |
|
||
| Рабочий стенд | `make run_docker` запущен (HAProxy на `127.0.0.1:8080`, `api` × 2), во время прогона не трогался: состояние и `StartedAt` всех контейнеров `mtusi-lab3` до и после совпадают (`diff` пуст) |
|
||
| Хост | Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; ноутбук от батареи |
|
||
|
||
На хранилища тесты действуют только через hook
|
||
`student-tests/fault_hook.py` (фикстура `stand`). У 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:54564 tight=http://127.0.0.1:54568
|
||
[failure_checks] pytest -m fault
|
||
collecting ... collected 146 items / 131 deselected / 15 selected
|
||
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, 131 deselected in 44.09s ======================
|
||
[failure_checks] cleanup
|
||
[failure_checks] results: {'fault': 0}
|
||
```
|
||
|
||
После прогона контейнеров и volume проекта `mtusi-lab3-failures` нет
|
||
(`docker ps -aq` / `docker volume ls -q` с меткой проекта — пусто).
|
||
|
||
## Проверки лабы 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):
|
||
по-прежнему проходят на compose с лимитами и окружением по сервисам.
|
||
Тестов реплик среди `fault` нет: остановку реплик проверяют `make
|
||
test-failover` и `scripts/stop-one.sh` (`../failover/`).
|