Files
mtusi2026lab2/evidence/02-persistence-restart.txt
T
kokorindenis 5c193f24f7
Skeleton contracts / contracts (pull_request) Canceled after 0s
lab 2 solution
2026-10-23 17:24:27 +03:00

58 lines
4.6 KiB
Plaintext
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.
== 02: сохранность данных при явном перезапуске api + postgres + valkey ==
date: 2026-10-11T14:23:30Z (UTC)
Хук: scripts/restart.cmd — двойник scripts/restart.sh для Windows: те же вызовы
docker compose и те же гарантии (тома не удаляются, данные не сбрасываются, засев
не повторяется).
Почему двойник: tests/resilience.py запускает хук через Popen([script]) без оболочки,
а Windows через CreateProcess исполняет только .exe/.cmd/.bat; .sh падает с WinError 193.
WSL на этой машине оказался недоступен (Wsl/Service/CreateInstance/CreateVm/HCS/
ERROR_NO_SYSTEM_RESOURCES), поэтому записанный прогон сделан через .cmd. Ниже проверены
оба хука.
$ docker inspect -f '{{.Name}} {{.State.StartedAt}}' api postgres valkey # BEFORE
/mtusi2026lab2-api-1 2026-10-11T14:23:19.3827432Z
/mtusi2026lab2-postgres-1 2026-10-11T14:23:18.9549031Z
/mtusi2026lab2-valkey-1 2026-10-11T14:23:18.9330739Z
$ make test-persistence ACTION_SCRIPT=scripts/restart.cmd
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.cmd" --base-url "http://localhost:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
make exit code: 0
$ docker inspect -f '{{.Name}} {{.State.StartedAt}}' api postgres valkey # AFTER
/mtusi2026lab2-api-1 2026-10-11T14:23:52.4305544Z
/mtusi2026lab2-postgres-1 2026-10-11T14:23:52.1114406Z
/mtusi2026lab2-valkey-1 2026-10-11T14:23:52.0904113Z
StartedAt сменился у всех трёх контейнеров: хук действительно перезапустил стенд. Сам тест
этого показать не может — он об этом и пишет в своей последней строке, — поэтому проверка
внесена сюда.
-- POSIX-хук, запущенный из POSIX-оболочки: sh scripts/restart.sh --
=== services before restart ===
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi2026lab2-api-1 mtusi-messenger-lab2:2.0.0 "python -m messenger" api 16 minutes ago Up 7 seconds (healthy) 127.0.0.1:8080->8080/tcp
mtusi2026lab2-postgres-1 postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4 "docker-entrypoint.s…" postgres 16 minutes ago Up 7 seconds (healthy) 5432/tcp
mtusi2026lab2-valkey-1 valkey/valkey:8.0.11-trixie@sha256:4436c94fc34ce4af0354b9379d433a1f258998fb955f995c89822f98c14a8cab "tini -- docker-entr…" valkey 16 minutes ago Up 7 seconds (healthy) 6379/tcp
=== restart api postgres valkey (grace 10s) ===
Container mtusi2026lab2-postgres-1 Restarting
Container mtusi2026lab2-api-1 Restarting
Container mtusi2026lab2-valkey-1 Restarting
Container mtusi2026lab2-postgres-1 Started
Container mtusi2026lab2-valkey-1 Started
Container mtusi2026lab2-api-1 Started
=== services after restart ===
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi2026lab2-api-1 mtusi-messenger-lab2:2.0.0 "python -m messenger" api 16 minutes ago Up Less than a second (health: starting) 127.0.0.1:8080->8080/tcp
mtusi2026lab2-postgres-1 postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4 "docker-entrypoint.s…" postgres 16 minutes ago Up Less than a second (health: starting) 5432/tcp
mtusi2026lab2-valkey-1 valkey/valkey:8.0.11-trixie@sha256:4436c94fc34ce4af0354b9379d433a1f258998fb955f995c89822f98c14a8cab "tini -- docker-entr…" valkey 16 minutes ago Up Less than a second (health: starting) 6379/tcp
running services: api postgres valkey
restart complete
restart.sh exit code: 0
$ docker compose ps --format '{{.Service}} | {{.Status}}'
api | Up Less than a second (health: starting)
postgres | Up 1 second (health: starting)
valkey | Up 1 second (health: starting)