Files
mtusi2026lab3/evidence/tests/rolling-update-checks.md
T

105 lines
7.5 KiB
Markdown
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.
# Регрессия change `rolling-update` на итоговом коде
| | |
|---|---|
| Спеки | все основные спеки через `make student_test` и сверку покрытия; `load-balancing` «Отказ одной реплики», «Failover hook», «Поочерёдная замена реплик»; `data-storage` «Данные переживают рестарт»; `db-migrations` «Совместимость миграции с работающей версией»; `load-benchmark` «Фиксированный стенд» — «Одна реплика за балансировщиком», «Образ прежнего commit»; «Профиль отказа реплик» — «Быстрый профиль»; «Профиль поочерёдной замены» — «Быстрый профиль» |
| Change | `rolling-update`, задачи 5.1, 5.2 и 6.3 |
| Дата | 2026-10-10: до коммита кода — 21:47–21:50 UTC; на итоговом коде — 22:05–22:17 UTC |
| Commit | код — `de654a1` (`d2148ac` и исправление шага миграций в скрипте). Самопроверки `bench_failover_quick` и `bench_rollout_quick` записали `dirty: true`: в рабочем дереве были только правки `REPORT.md`, `design.md` и evidence, `git diff de654a1 --stat` кода не содержит |
| Стенд | часть A — рабочий `mtusi-lab3`: HAProxy на `127.0.0.1:8080`, `api` × 2, реплики после `make rolling_update` с `de654a1`; часть B — свои стенды (`test_isolated`, `<рабочий>-failures`, `mtusi-bench`) |
| Хост | Docker Desktop 29.8.2 (Compose 5.5.1), macOS 26.6.2 arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; питание от сети. Самопроверки, не замеры: хост не готовился, рабочий стенд в части B работал |
## Статические проверки (до коммита кода)
```text
$ make lint → All checks passed!
$ make check → PASS: offline skeleton structure, local refs and Python syntax
$ openspec validate rolling-update --strict → Change 'rolling-update' is valid
$ haproxy -c (haproxy:3.4.6, API_PORT=8080) → Configuration file is valid, exit 0
$ dash -n scripts/rolling-update.sh → exit 0
```
Миграция `e656d6bbe1a4` на временной базе `ru_check` (не рабочей):
`upgrade head` → `downgrade -1` → `upgrade head`, затем `alembic check`
— `No new upgrade operations detected.`, колонка `instance_id text`.
## Часть A: рабочий стенд через LB (`de654a1`)
```text
$ make rolling_update (под tests/load.py) → exit 0; load: 19 199 успешных, 0 неуспешных
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
StartedAt до → после:
mtusi-lab3-api-12 22:05:05 -> 22:05:45
mtusi-lab3-api-13 22:05:09 -> 22:05:45
mtusi-lab3-haproxy-1 22:02:53 -> 22:05:45
mtusi-lab3-postgres-1 22:02:18 -> 22:05:41
mtusi-lab3-valkey-1 22:02:17 -> 22:05:41
$ STOP_ONE_LOG=… make test-failover ACTION_SCRIPT=scripts/stop-one.sh
{"observed_instances_before": 2, "successful_writes": 112, "failed_attempts": 0, "first_recovery_seconds": 1.004}
PASS: failover preserved confirmed data and existing session.
$ make replicas; curl …/health/live (сдвиг очереди round-robin)
$ STOP_MODE=kill STOP_ONE_LOG=… make test-failover ACTION_SCRIPT=scripts/stop-one.sh
{"observed_instances_before": 2, "successful_writes": 119, "failed_attempts": 1, "first_recovery_seconds": 0.231}
PASS: failover preserved confirmed data and existing session.
$ cat STOP_ONE_LOG
2026-10-10T22:05:56Z TARGET_INSTANCE_ID=b167830351fc container=b167830351fc4d8f… mode=stop
2026-10-10T22:06:17Z TARGET_INSTANCE_ID=a7126827af39 container=a7126827af39733a… mode=kill
$ make replicas
$ make test
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
$ make student_test
key race through replicas: {'b167830351fc': 5, 'a7126827af39': 5}
===================== 131 passed, 15 deselected in 22.38s ======================
```
Первый прогон `make test-persistence` на `d2148ac` упал: `FAIL: restart
hook failed`. Контейнер `migrate` прежнего образа не знал новой
ревизии. Разбор и исправление — `evidence/rollout/compatibility.md`,
шаг G; выше — повтор на исправленном коде.
## Часть B: свои стенды
```text
$ make test_isolated (до коммита: 21:47; на de654a1: 22:07)
Running upgrade 7652184b7016 -> e656d6bbe1a4, added message instance id # временная база test_<db>
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
=========== 127 passed, 4 skipped, 15 deselected in 64.20s (0:01:04) ===========
[test_isolated] results: {'test': 0, 'student_test': 0}
4 пропуска — тесты реплик против одного процесса («one API process»)
$ make failure_checks (до коммита и на de654a1)
===================== 15 passed, 131 deselected in 45.65s ======================
[failure_checks] results: {'fault': 0}
$ make bench_quick
[00:03:41] complete: 18/18 runs, results in evidence/bench/quick-20261010T220924Z # паспорт: api_replicas 1, лимиты LB
$ make bench_failover_quick
phase 01-stop-r1: LB out 0.97 s (MAINT, bound 2.5 s), errors 0 [], recovery 0 s, back in LB 1.0 s, …, messages 2300 = keys 2300
phase 02-stop-r2: LB out 0.91 s (MAINT, bound 2.5 s), errors 0 [], recovery 0 s, back in LB 1.12 s, …, messages 4600 = keys 4600
phase 03-kill-r1: LB out 0.81 s (MAINT, bound 2.5 s), errors 1 [502:1], recovery 0 s, back in LB 1.08 s, …, messages 6901 = keys 6901
phase 04-kill-r2: LB out 0.66 s (MAINT, bound 2.5 s), errors 1 [502:1], recovery 0 s, back in LB 1.0 s, …, retried 1, messages 9202 = keys 9202
[00:02:00] complete: 4/4 runs
$ make bench_rollout_quick
rollout: 9.92 s, errors before / during / after 0 / 0 [] / 0, min success 1.0, old after drain 0,
revision 7652184b7016 -> e656d6bbe1a4; retried 0, messages 7301 = keys 7301
[00:01:30] complete: 1/1 runs, results in evidence/rollout/quick-rollout-20261010T221508Z
```
Шаги быстрого профиля замены (`replicas.csv`, секунды от начала
замены):
| Шаг | Новая (слот) | Старая (слот) | Старт → `UP`, с | Дренаж, с | Остановка, с | Замена шага, с | Ошибок | Ответов старой после дренажа |
|---|---|---|---|---|---|---|---|---|
| 1 | `8aa240966cd8` (api-3) | `4bc7c31fd4f4` (api-1) | 1,93 | 0,15 | 0,30 | 3,08 | 0 | 0 |
| 2 | `d992e67a19c5` (api-1) | `64133b83844e` (api-2) | 1,93 | 0,15 | 0,41 | 3,18 | 0 | 0 |
`kill` в профиле `failover` по-прежнему даёт 1 ответ 502 на фазу:
запрос в полёте на убитой реплике, LB его не повторяет. Повтор с тем же
ключом закрыл его без дубля — это поведение отказа, не замены.
Каталоги быстрых профилей (`quick-*`) — в `.gitignore`, здесь их
итоговые строки.