docs: add attachments evidence and report

- re-capture coverage-exclusion evidence on the lab 4 stand: cache,
  auth storage, replay after API recreate, test-persistence,
  attachment-failover (stop, kill), attachment-storage
- green evidence/tests: student_test via LB, test_isolated,
  failure_checks; smoke, slow transfer, test-failover per replica
- bench_rollout label attachments: e1161f7 -> schema with attachments
  under load, no errors, messages = keys
- REPORT.md: attachments architecture, write order, defense answers,
  level 3/4 evidence rows, limitations; PLAN.md stage 2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 01:50:10 +03:00
co-authored by Claude Opus 5.5
parent d56b8928b4
commit 8dc925e8ca
28 changed files with 2641 additions and 112 deletions
+76 -77
View File
@@ -1,33 +1,24 @@
# `make failure_checks` со своим S3
# `make failure_checks` со своим S3 и проверками отказов вложений
- Дата: 2026-10-20, 18:35:12–18:37:20 UTC.
- Commit: `f57635a` (рабочее дерево — только `PLAN.md` вне кода).
- Стенд отказов: проект `mtusi-lab4-failures` (Postgres, Valkey, S3 с
bootstrap, без портов хранилищ), два API на `127.0.0.1`. Рабочий стенд
`mtusi-lab4` в это время запущен. Docker Desktop 29.8.2, Apple M3 Pro.
- Новая проверка change `s3-storage` —
`test_readiness_without_object_storage[stop|pause]`: спек `health`,
«Хранилище объектов недоступно». Вариант `pause` добавлен по находке
verify S3. Проба hook после `unpause` и `start` — та же команда, что
healthcheck `s3`, с регистрацией тома (находка W1).
- Дата: 2026-10-20, 22:41:37–22:43:32 UTC.
- Commit: `d56b892` (код приложения — `116d8d3`, change `attachments`).
- Стенд отказов: проект `mtusi-lab4-failures` (PostgreSQL, Valkey, S3 с
bootstrap, без портов хранилищ), два API на `127.0.0.1`: обычный и
«тесный» (сроки сессии и ключа 2 с, пул 1). Рабочий стенд `mtusi-lab4`
в это время запущен. Docker Desktop 29.8.2, Apple M3 Pro.
- Проверки отказов change `attachments` (спек `attachments`, design
решение 12): «Запись в S3 не удалась»
(`test_upload_with_object_storage_stopped`), «Отклонённая загрузка
ничего не оставляет» (`test_rejected_uploads_leave_nothing`), «S3
остановлен» (`test_object_storage_stopped`), «S3 завис»
(`test_object_storage_paused`). Hook считает вложения по статусам
(`count-attachments`, psql) и объекты вложений в bucket стенда
(`count-objects`, `weed shell fs.ls`).
- Прежняя пересъёмка этого файла (commit `f57635a`, change
`s3-storage`) была красной на 5 проверках из-за схемы `Message` без
`attachment_ids` — ожидаемо до `attachments`; теперь все зелёные.
## Итог: код 2, пять красных — ожидаемо до change `attachments`
Красны 5 проверок из уточнённого списка в шапке `tasks.md` change
`s3-storage`, у всех одна причина:
```
5 E AssertionError: Message schema: /: 'attachment_ids' is a required property
```
Контракт лабы 4 требует поле `attachment_ids` в `Message`, а код лабы 3
его не отдаёт (в `src/` поля нет). Эти тесты проверяют схему ответа на
отправку сообщения. Чинит change `attachments` (ответ пользователя
2026-10-20, `PLAN.md`, `s3-storage`, «Вопросы», п. 2), там этот файл
переснимается зелёным. S3 и стенд отказов здесь ни при чём: остальные
14 проверок, включая оба варианта новой, прошли.
## Вывод (строки оркестратора и pytest)
## Итог: код 0, 23 из 23
```
$ make failure_checks
@@ -40,47 +31,34 @@ s3-bootstrap-1 | s3-bootstrap: bucket messenger created
s3-bootstrap-1 | s3-bootstrap: user api created
s3-bootstrap-1 | s3-bootstrap: checks passed (api key put/get/delete; api key list and bucket create, anonymous get and list denied)
[failure_checks] start api containers
[failure_checks] ready: api=http://127.0.0.1:54756 tight=http://127.0.0.1:54761
[failure_checks] ready: api=http://127.0.0.1:54995 tight=http://127.0.0.1:54999
[failure_checks] pytest -m fault
student-tests/test_failures.py::test_expired_token PASSED [ 5%]
student-tests/test_failures.py::test_use_does_not_extend_session PASSED [ 10%]
student-tests/test_failures.py::test_token_while_database_stopped PASSED [ 15%]
student-tests/test_failures.py::test_members_failure_rolls_back_chat PASSED [ 21%]
student-tests/test_failures.py::test_database_stopped_and_back FAILED [ 26%]
student-tests/test_failures.py::test_pool_exhausted PASSED [ 31%]
student-tests/test_failures.py::test_connection_limit_reached PASSED [ 36%]
student-tests/test_failures.py::test_pool_keeps_connections PASSED [ 42%]
student-tests/test_failures.py::test_readiness_without_database PASSED [ 47%]
student-tests/test_failures.py::test_readiness_without_cache PASSED [ 52%]
student-tests/test_failures.py::test_readiness_without_object_storage[stop] PASSED [ 57%]
student-tests/test_failures.py::test_readiness_without_object_storage[pause] PASSED [ 63%]
student-tests/test_failures.py::test_flush_cache PASSED [ 68%]
student-tests/test_failures.py::test_valkey_stopped FAILED [ 73%]
student-tests/test_failures.py::test_valkey_paused PASSED [ 78%]
student-tests/test_failures.py::test_valkey_back PASSED [ 84%]
student-tests/test_failures.py::test_message_failure_keeps_key_free FAILED [ 89%]
student-tests/test_failures.py::test_database_outage_keeps_key_free FAILED [ 94%]
student-tests/test_failures.py::test_key_free_after_ttl FAILED [100%]
=========== 5 failed, 14 passed, 142 deselected in 69.63s (0:01:09) ============
[failure_checks] postgres log: 381 lines, crash markers 0; "too many clients" 26, "administrator command" 129
[failure_checks] last 50 lines of mtusi-lab4-failures-api
[failure_checks] last 50 lines of mtusi-lab4-failures-api-tight
student-tests/test_failures.py::test_expired_token PASSED [ 4%]
student-tests/test_failures.py::test_use_does_not_extend_session PASSED [ 8%]
student-tests/test_failures.py::test_token_while_database_stopped PASSED [ 13%]
student-tests/test_failures.py::test_members_failure_rolls_back_chat PASSED [ 17%]
student-tests/test_failures.py::test_database_stopped_and_back PASSED [ 21%]
student-tests/test_failures.py::test_pool_exhausted PASSED [ 26%]
student-tests/test_failures.py::test_connection_limit_reached PASSED [ 30%]
student-tests/test_failures.py::test_pool_keeps_connections PASSED [ 34%]
student-tests/test_failures.py::test_readiness_without_database PASSED [ 39%]
student-tests/test_failures.py::test_readiness_without_cache PASSED [ 43%]
student-tests/test_failures.py::test_readiness_without_object_storage[stop] PASSED [ 47%]
student-tests/test_failures.py::test_readiness_without_object_storage[pause] PASSED [ 52%]
student-tests/test_failures.py::test_flush_cache PASSED [ 56%]
student-tests/test_failures.py::test_valkey_stopped PASSED [ 60%]
student-tests/test_failures.py::test_valkey_paused PASSED [ 65%]
student-tests/test_failures.py::test_valkey_back PASSED [ 69%]
student-tests/test_failures.py::test_message_failure_keeps_key_free PASSED [ 73%]
student-tests/test_failures.py::test_database_outage_keeps_key_free PASSED [ 78%]
student-tests/test_failures.py::test_key_free_after_ttl PASSED [ 82%]
student-tests/test_failures.py::test_upload_with_object_storage_stopped PASSED [ 86%]
student-tests/test_failures.py::test_rejected_uploads_leave_nothing PASSED [ 91%]
student-tests/test_failures.py::test_object_storage_stopped PASSED [ 95%]
student-tests/test_failures.py::test_object_storage_paused PASSED [100%]
================ 23 passed, 196 deselected in 95.64s (0:01:35) =================
[failure_checks] postgres log: 375 lines, crash markers 0; "too many clients" 20, "administrator command" 129
[failure_checks] cleanup
[failure_checks] results: {'fault': 1, 'postgres': 0}
exit=2
```
Журналы API стенда отказов, которые печатает оркестратор, здесь опущены.
## Только проверки S3
```
$ make failure_checks FAULT_ARGS='-k object_storage'
s3-bootstrap-1 | s3-bootstrap: checks passed (api key put/get/delete; api key list and bucket create, anonymous get and list denied)
student-tests/test_failures.py::test_readiness_without_object_storage[stop] PASSED [ 50%]
student-tests/test_failures.py::test_readiness_without_object_storage[pause] PASSED [100%]
====================== 2 passed, 159 deselected in 7.71s =======================
[failure_checks] postgres log: 57 lines, crash markers 0; "too many clients" 0, "administrator command" 0
[failure_checks] results: {'fault': 0, 'postgres': 0}
exit=0
```
@@ -88,20 +66,41 @@ exit=0
## Уборка и рабочий стенд
```
working stand StartedAt unchanged
$ docker inspect -f '{{.Name}} {{.State.StartedAt}}' $(docker compose ps -q) # до
/mtusi-lab4-api-5 2026-10-20T22:35:43.977516884Z
/mtusi-lab4-api-6 2026-10-20T22:36:34.974230921Z
/mtusi-lab4-haproxy-1 2026-10-20T22:32:07.873866047Z
/mtusi-lab4-postgres-1 2026-10-20T22:31:42.768951925Z
/mtusi-lab4-s3-1 2026-10-20T22:31:57.790816751Z
/mtusi-lab4-valkey-1 2026-10-20T22:31:42.807267216Z
$ docker inspect -f '{{.Name}} {{.State.StartedAt}}' $(docker compose ps -q) # после
/mtusi-lab4-api-5 2026-10-20T22:35:43.977516884Z
/mtusi-lab4-api-6 2026-10-20T22:36:34.974230921Z
/mtusi-lab4-haproxy-1 2026-10-20T22:32:07.873866047Z
/mtusi-lab4-postgres-1 2026-10-20T22:31:42.768951925Z
/mtusi-lab4-s3-1 2026-10-20T22:31:57.790816751Z
/mtusi-lab4-valkey-1 2026-10-20T22:31:42.807267216Z
left: containers 0, volumes 0
```
- `StartedAt` всех контейнеров `mtusi-lab4` до и после прогона совпали.
- `StartedAt` всех контейнеров `mtusi-lab4` до и после совпали: рабочий
стенд не тронут.
- У проекта `mtusi-lab4-failures` не осталось ни контейнеров, ни
volumes, включая volume S3.
## Новая проверка
## Что проверяют проверки вложений
`test_readiness_without_object_storage[stop|pause]`: hook останавливает
(`stop_grace_period: 2s`) или замораживает (`docker pause`) `s3` стенда
отказов. `GET /health/ready` и `GET /health/live` отвечают 200
`{"status": "ok"}` быстрее 1 с, затем `s3` возвращается (`start` или
`unpause` с пробой healthcheck). При `pause` соединение с S3 есть, а
ответа нет: проверка, которая всё же ходила бы в S3, ждала бы срока
вызова (5 с), а не отказа соединения.
- «Запись в S3 не удалась»: S3 остановлен → загрузка 503 `unavailable`
быстрее срока вызова S3 (5 с) с запасом; в БД на одну строку
`pending` больше, `ready` — столько же; текстовое сообщение — 201; после
`start` та же загрузка — 201.
- «Отклонённая загрузка ничего не оставляет»: 404 постороннему, 413 по
`Content-Length`, 413 по счётчику (частями), 413 по пикселям, 415 по
типу и 415 по целостности — счётчики вложений по статусам и число
объектов в bucket не изменились (перед этим одна настоящая загрузка:
счётчики ненулевые).
- «S3 остановлен»: скачивание 503, метаданные 200 (равны ответу
загрузки), сообщение с этим вложением 201, `/health/ready` 200; после
`start` скачивание — те же байты.
- «S3 завис» (`docker pause`): загрузка и скачивание — 503 не позже
5 с + 0,6 с; после `unpause` скачивание — те же байты.