# Доказывает: на чистом отдельном стенде лабы 5 (свои PostgreSQL, Valkey,
#   S3, RabbitMQ, relay, worker, HAProxy и две реплики, свои секреты)
#   проходят публичный smoke, все свои тесты без отказов (в том числе
#   обработка вложений), отказ одной реплики (make test-failover),
#   вложение после остановки принявшей реплики и make test-persistence.
# Дата: 2026-11-05, 17:40–17:43 UTC.
# Окружение: macOS 26.7.1, Docker 29.9.2 (ВМ Docker Desktop 12 CPU,
#   7,7 ГиБ), Compose 5.6.1, Python хоста 3.11.9, тесты — Python 3.13.15
#   (uv).
# Стенд: проект compose vladimirceva-lab5-isolated (student-tests/stand.py),
#   LB на случайном свободном порту 127.0.0.1; удалён после прогона.
# Код: src_sha256 4c4bb305b2747d154105720b93261ef476675670470bfa7a10b338dd79514da9
# Повторить: make test-isolated
# Вывод сокращён: строки сборки образа и запуска контейнеров compose
#   убраны (пометка ...), строки проверок — как есть.

$ make test-isolated
python3 student-tests/stand.py isolated
[isolated] project=vladimirceva-lab5-isolated
[isolated] build image
...
[isolated] start postgres, valkey, s3 and rabbitmq
[isolated] s3 bootstrap
[isolated] migrations
2026-11-05T17:40:41.475Z INFO    src.migrations [rid=-] migrations started db=postgres:5432/messenger
2026-11-05T17:40:41.540Z INFO    src.migrations [rid=-] migrations finished db=messenger
[isolated] ready: lb=http://127.0.0.1:57074 replicas=2
[isolated] make test
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
[isolated] pytest
collected 174 items / 34 deselected / 140 selected
student-tests/test_attachments.py ...................................... [ 27%]
........                                                                 [ 32%]
student-tests/test_auth.py ......................                        [ 48%]
student-tests/test_balancing.py ...                                      [ 50%]
student-tests/test_cache.py ....                                         [ 53%]
student-tests/test_idempotency.py ...................                    [ 67%]
student-tests/test_processing.py ..........                              [ 74%]
student-tests/test_race.py ....                                          [ 77%]
student-tests/test_request_id.py .............                           [ 86%]
student-tests/test_rubric.py ...................                         [100%]
===================== 140 passed, 34 deselected in 41.67s ======================
[isolated] make test-failover (scripts/stop-one.sh)
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 122, "failed_attempts": 0, "first_recovery_seconds": 1.818}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
[isolated] restore replicas
[isolated] attachment failover (scripts/lab5.py, stop the uploader)
upload: 202 queued X-Instance-Id=8feb43cabae1 size=111817 sha256=99ea7533c441f79c… (fixture 99ea7533c441f79c…)
processed: ready variants=3
message with attachment: 201 attachment_ids=['510268de-e027-4e6c-82a6-016fa3be87e0']
$ TARGET_INSTANCE_ID=8feb43cabae1 STOP_MODE=stop scripts/stop-one.sh
exit 0; STOP_ONE_LOG: 2026-11-05T17:41:54Z TARGET_INSTANCE_ID=8feb43cabae1 container=8feb43cabae12704b917099dfe14031a8c864875c03682666d8f82dedff897f9 mode=stop
download by bob after stop: 200 X-Instance-Id=85b69a89e05f after 0.02s, bytes=111817, sha256 == fixture, content-type=image/png
outsider GET /attachments/{id}: 404
outsider GET /attachments/{id}/content: 404
...
PASS
[isolated] make test-persistence (scripts/restart.sh)
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
[isolated] cleanup
[isolated] results: {'test': 0, 'student-test': 0, 'test-failover': 0, 'attachment-failover': 0, 'test-persistence': 0}

# Итог: все пять проверок — код 0. 140 своих тестов, из них 10 — обработка
#   (test_processing.py: 202 → ready, геометрия thumbnail/crop/optimized
#   декодером, EXIF orientation, прозрачность, failed с invalid_image и 409).
#   Байты вложения отдаёт другая реплика после остановки принявшей:
#   оригинал опубликован в S3, а не лежит у реплики.
