Заполнить отчёт и доказательства проверок

This commit is contained in:
2026-11-16 23:08:18 +00:00
parent 368d7076a7
commit b6750741c4
7 changed files with 246 additions and 16 deletions
+49
View File
@@ -0,0 +1,49 @@
# evidence/local-checks.txt — публичные и собственные проверки ЛР 3
# Среда подготовки (локально, БЕЗ Docker/Compose, БЕЗ HAProxy):
# python = Python 3.13.14
# flask = 3.1.0
# postgres = PostgreSQL 17.12 (Debian 17.12-0+deb13u1)
# DB = lab3db @ 127.0.0.1:5432 (запущен заранее; НЕ пересоздавался)
# LB = временный локальный round-robin на 127.0.0.1:8080 (emulation HAProxy; бинарник haproxy в среде отсутствует)
# реплики = api1:127.0.0.1:8083, api2:127.0.0.1:8084 (каждый со своим X-Instance-Id)
# pg_postmaster_start_time = 2026-11-16 21:35:40.472449+00 (без изменений: БД не перезапускалась)
# PID = api1 33056 / api2 31913 / lb 20527
# captured_utc = 2026-11-16T23:02:16Z
# Все публичные тесты идут через LB 8080. Секреты в evidence не пишутся.
### Round-robin через LB 8080 (X-Instance-Id по 4 запросам)
-> 93acbc9d-c445-4ab6-94ff-ca2292795dd9
-> b10c4e9a-ffd1-4800-ac69-b486be9a0305
-> 93acbc9d-c445-4ab6-94ff-ca2292795dd9
-> b10c4e9a-ffd1-4800-ac69-b486be9a0305
$ /workspace/venv-labs/bin/python -m messenger.migrate
Migrations applied successfully (already applied versions skipped).
$ make check validate PYTHON=/workspace/venv-labs/bin/python
$ /workspace/venv-labs/bin/python scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ /workspace/venv-labs/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
$ make student-test PYTHON=/workspace/venv-labs/bin/python
test_atomic_chat_and_migration_repeat (test_api.ApiTests.test_atomic_chat_and_migration_repeat) ... ok
test_authentication_and_logout (test_api.ApiTests.test_authentication_and_logout) ... ok
test_expiry_and_restart_app (test_api.ApiTests.test_expiry_and_restart_app) ... ok
test_idempotency_expiry_and_errors (test_api.ApiTests.test_idempotency_expiry_and_errors) ... ok
test_pagination_survives_new_app (test_api.ApiTests.test_pagination_survives_new_app) ... ok
test_strict_validation_and_private_chat (test_api.ApiTests.test_strict_validation_and_private_chat) ... ok
----------------------------------------------------------------------
Ran 6 tests in 4.424s
OK
$ make test BASE_URL=http://127.0.0.1:8080 PYTHON=/workspace/venv-labs/bin/python
$ /workspace/venv-labs/bin/python tests/smoke.py --base-url http://127.0.0.1:8080
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
$ make test-idempotency BASE_URL=http://127.0.0.1:8080 PYTHON=/workspace/venv-labs/bin/python
$ /workspace/venv-labs/bin/python scripts/check_idempotency.py --base-url http://127.0.0.1:8080
PASS: 24 concurrent requests / 8 clients / 2 replicas -> one message; conflict, scopes, access and logout verified.
+20
View File
@@ -0,0 +1,20 @@
# evidence/local-restart.txt — test-persistence (both replicas restarted, DB untouched)
# env: local processes (no Docker), replicas on 8083/8084 behind local LB on 8080
=== lab3 persistence — BEFORE (restart both API replicas; DB untouched) ===
captured_utc: 2026-11-16T23:03:00Z
api1 PID=33056 api2 PID=31913 lb PID=20527
api1 X-Instance-Id=93acbc9d-c445-4ab6-94ff-ca2292795dd9
api2 X-Instance-Id=b10c4e9a-ffd1-4800-ac69-b486be9a0305
pg_postmaster_start_time=2026-11-16 21:35:40.472449+00:00
--- make test-persistence ACTION_SCRIPT=/tmp/lab3_restart.sh BASE_URL=http://127.0.0.1:8080 ---
/workspace/venv-labs/bin/python tests/resilience.py --mode persistence --action-script "/tmp/lab3_restart.sh" --base-url "http://127.0.0.1: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.
=== lab3 persistence — AFTER (same data + session still valid) ===
captured_utc: 2026-11-16T23:03:03Z
api1 PID=36498 api2 PID=36499 lb PID=20527
api1 X-Instance-Id=fca1efad-e515-466c-b66d-be4b7c30eca6
api2 X-Instance-Id=3a7c1628-75e2-44c4-af0a-6f674079ebc7
pg_postmaster_start_time=2026-11-16 21:35:40.472449+00:00 (unchanged: DB not restarted)
+20
View File
@@ -0,0 +1,20 @@
# evidence/local-stops.txt — test-failover (one replica stopped, LB routes to survivor)
# env: local processes (no Docker), replicas on 8083/8084 behind local LB on 8080
=== lab3 failover — BEFORE (stop one replica) ===
captured_utc: 2026-11-16T23:03:11Z
api1 PID=36498 [up] instance=fca1efad-e515-466c-b66d-be4b7c30eca6
api2 PID=36499 [up] instance=3a7c1628-75e2-44c4-af0a-6f674079ebc7
distinct instances behind LB 8080: 3a7c1628-75e2-44c4-af0a-6f674079ebc7
--- make test-failover ACTION_SCRIPT=/tmp/lab3_stop_one.sh BASE_URL=http://127.0.0.1:8080 ---
/workspace/venv-labs/bin/python tests/resilience.py --mode failover --action-script "/tmp/lab3_stop_one.sh" --base-url "http://127.0.0.1:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 102, "failed_attempts": 0, "first_recovery_seconds": 0.321}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
=== lab3 failover — AFTER (one replica stopped, LB still serving on surviving one) ===
captured_utc: 2026-11-16T23:03:27Z
api1 [up] instance=fca1efad-e515-466c-b66d-be4b7c30eca6
api2 [DOWN] instance=
LB 8080 ready: 200
LB now routes to: fca1efad-e515-466c-b66d-be4b7c30eca6
+7
View File
@@ -0,0 +1,7 @@
# После перезапуска обеих API (hook /tmp/lab3_restart.sh; БД НЕ трогалась).
# Те же данные и сессия; PID/X-Instance-Id API изменились, pg_postmaster_start_time не изменился.
# Локальные процессы, без Docker/HAProxy.
mtusi2026lab3-db - - running (PostgreSQL 17.12, pg_postmaster_start_time=2026-11-16 21:35:40+00, unchanged)
mtusi2026lab3-api1 36498 fca1efad-e515-466c-b66d-be4b7c30eca6 running
mtusi2026lab3-api2 36499 3a7c1628-75e2-44c4-af0a-6f674079ebc7 running
mtusi2026lab3-lb 20527 - running
+9
View File
@@ -0,0 +1,9 @@
# До перезапуска — локальные процессы (без Docker/HAProxy).
# Формат: имя PID X-Instance-Id status.
# Примечание: в этой среде подготовки Docker/HAProxy отсутствуют, поэтому
# строки docker compose ps -a из reference-стенда заменены реальными локальными
# процессами. БД (PostgreSQL 17.12) запущена заранее и НЕ пересоздавалась.
mtusi2026lab3-db - - running (PostgreSQL 17.12 @127.0.0.1:5432, pg_postmaster_start_time=2026-11-16 21:35:40+00)
mtusi2026lab3-api1 33056 93acbc9d-c445-4ab6-94ff-ca2292795dd9 running
mtusi2026lab3-api2 31913 b10c4e9a-ffd1-4800-ac69-b486be9a0305 running
mtusi2026lab3-lb 20527 - running (local round-robin @127.0.0.1:8080)
+6
View File
@@ -0,0 +1,6 @@
# Отказ одной реплики (failover). Локальные процессы, без Docker/HAProxy.
# Хук /tmp/lab3_stop_one.sh остановил реплику с X-Instance-Id=3a7c1628-75e2-44c4-af0a-6f674079ebc7
# (api2, 8084); LB на 8080 продолжил обслуживать запросы через api1 (fca1efad...).
# Итог сценария: 102 успешные записи, 0 неудач, восстановление 0.321s (см. evidence/local-stops.txt).
mtusi2026lab3-api1 36498 fca1efad-e515-466c-b66d-be4b7c30eca6 running
mtusi2026lab3-api2 - 3a7c1628-75e2-44c4-af0a-6f674079ebc7 exited (8084 недоступен)