feat: add replicated messenger and reproducible lab3 stand

This commit is contained in:
2026-10-15 13:43:39 +03:00
parent 0ab3a341aa
commit 84dd7fec0a
106 changed files with 17235 additions and 24 deletions
+71
View File
@@ -0,0 +1,71 @@
# Что доказывает (уровни 3 и 4): на отдельном чистом стенде лабы 3 (свои
# PostgreSQL, Valkey и volume, HAProxy и две реплики, свои случайные
# пароли, без .env) одной командой проходят: публичный smoke (make test),
# весь собственный набор через LB с тестами реплик (EXPECT_REPLICAS=2),
# make test-failover (hook scripts/stop-one.sh в проекте стенда), возврат
# реплик и make test-persistence (hook scripts/restart.sh). Миграции на
# пустом volume — сервисом migrate, обе ревизии по порядку. Рабочий стенд
# не затрагивается, отдельный удаляется вместе с volume.
# Дата (UTC): 2026-10-13T22:16:04Z — 2026-10-13T22:16:52Z
# Окружение: macOS 26.6.2, Apple M3 Pro; Docker 29.8.2, Compose 5.5.1;
# python3 хоста 3.11.9 (stand.py, проверки skeleton), pytest на Python
# 3.13.15 (uv)
# Стенд: student-tests/stand.py isolated — проект vladimirceva-lab3-isolated,
# HAProxy на свободном порту 127.0.0.1; код src_sha256 0349e9a270178467.
# Абсолютный путь заменён на <репозиторий>; строки docker compose о
# контейнерах, сети и сборке опущены («...»).
# Как повторить: make test-isolated
$ time make test-isolated
python3 student-tests/stand.py isolated
[isolated] project=vladimirceva-lab3-isolated
[isolated] build image
...
[isolated] start postgres and valkey
...
[isolated] migrations
...
2026-10-13T22:16:09.550Z INFO src.migrations [rid=-] migrations started db=postgres:5432/messenger
2026-10-13T22:16:09.570Z INFO alembic.runtime.migration [rid=-] Context impl PostgresqlImpl.
2026-10-13T22:16:09.570Z INFO alembic.runtime.migration [rid=-] Will assume transactional DDL.
2026-10-13T22:16:09.576Z INFO alembic.runtime.migration [rid=-] Running upgrade -> 0001, messenger schema: users, sessions, chats, chat members, messages
2026-10-13T22:16:09.618Z INFO alembic.runtime.migration [rid=-] Running upgrade 0001 -> 0002, idempotency keys for sending messages
2026-10-13T22:16:09.625Z INFO src.migrations [rid=-] migrations finished db=messenger
...
[isolated] ready: lb=http://127.0.0.1:62916 replicas=2
[isolated] make test
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
[isolated] pytest
============================= test session starts ==============================
platform darwin -- Python 3.13.15, pytest-9.1.1, pluggy-1.6.0
rootdir: <репозиторий>
configfile: pyproject.toml
testpaths: student-tests
plugins: anyio-4.15.1
collected 99 items / 15 deselected / 84 selected
student-tests/test_auth.py ...................... [ 26%]
student-tests/test_balancing.py ... [ 29%]
student-tests/test_cache.py .... [ 34%]
student-tests/test_idempotency.py ................... [ 57%]
student-tests/test_race.py .... [ 61%]
student-tests/test_request_id.py ............. [ 77%]
student-tests/test_rubric.py ................... [100%]
====================== 84 passed, 15 deselected in 12.47s ======================
[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": 116, "failed_attempts": 0, "first_recovery_seconds": 1.729}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
[isolated] restore replicas
...
[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, 'test-persistence': 0}
make test-isolated 3.28s user 0.94s system 8% cpu 47.602 total
# Весь прогон со сборкой (из кэша слоёв), стендом, тестами и уборкой —
# 48 с. 15 deselected — проверки отказов (маркер fault): их выполняет
# make failure-checks (evidence/tests/failure-checks.txt).