This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
== 03: собственные проверки (student-tests) ==
|
||||
date: 2026-10-11T19:32:33Z (UTC)
|
||||
date: 2026-10-23T19:19:36Z (UTC)
|
||||
host: Windows 10 Pro 19045, Git Bash (MSYS), python3 3.11.9; стенд поднят docker compose
|
||||
|
||||
Что показывает: проверки поверх публичного контракта — пароли и границы их длины,
|
||||
@@ -52,6 +52,10 @@ test_password_length_bounds (test_auth.Registration.test_password_length_bounds)
|
||||
11 и 129 кодовых точек отклоняются; 12 и 128 принимаются. ... ok
|
||||
test_password_may_contain_a_colon (test_auth.Registration.test_password_may_contain_a_colon)
|
||||
Basic разделяет только по первому двоеточию, остальное принадлежит паролю. ... ok
|
||||
test_surrounding_spaces_are_part_of_the_password (test_auth.Registration.test_surrounding_spaces_are_part_of_the_password)
|
||||
Пароль не обрезается: пробелы по краям значат то же, что и любые другие символы. ... ok
|
||||
test_whitespace_only_password_is_refused (test_auth.Registration.test_whitespace_only_password_is_refused)
|
||||
Двенадцать пробелов — пустое значение обязательного поля, а не пароль. ... ok
|
||||
test_a_valid_chat_is_created_whole (test_chat_atomicity.ChatCreation.test_a_valid_chat_is_created_whole) ... ok
|
||||
test_creator_must_be_a_member (test_chat_atomicity.ChatCreation.test_creator_must_be_a_member) ... ok
|
||||
test_duplicate_members_are_refused (test_chat_atomicity.ChatCreation.test_duplicate_members_are_refused) ... ok
|
||||
@@ -62,7 +66,7 @@ test_liveness_stays_green_throughout (test_dependency_outage.DependencyOutage.te
|
||||
Отказ зависимости не должен выглядеть для супервизора смертью процесса. ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
|
||||
test_postgres_outage (test_dependency_outage.DependencyOutage.test_postgres_outage) ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
|
||||
test_valkey_outage (test_dependency_outage.DependencyOutage.test_valkey_outage) ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
|
||||
api пересоздан с SESSION_TTL_SECONDS=3, готов через 3.72s
|
||||
api пересоздан с SESSION_TTL_SECONDS=3, готов через 3.73s
|
||||
test_a_token_issued_before_the_change_still_works (test_expiry.ShortLivedSessions.test_a_token_issued_before_the_change_still_works)
|
||||
Пересоздание API не выдаёт новые сессии и не продлевает старые. ... у токена, выданного до переключения, осталось 3596s из исходных 3600s
|
||||
ok
|
||||
@@ -73,7 +77,7 @@ test_expiry_does_not_need_a_cleanup_job (test_expiry.ShortLivedSessions.test_exp
|
||||
ok
|
||||
test_the_short_ttl_is_the_one_in_force (test_expiry.ShortLivedSessions.test_the_short_ttl_is_the_one_in_force) ... expires_at через 3.00s, ключ в Valkey живёт 3s: сроком владеет хранилище, а не процесс
|
||||
ok
|
||||
api пересоздан с SESSION_TTL_SECONDS=3600, готов через 3.80s
|
||||
api пересоздан с SESSION_TTL_SECONDS=3600, готов через 3.78s
|
||||
test_error_envelope_carries_a_request_id (test_health.Probes.test_error_envelope_carries_a_request_id) ... ok
|
||||
test_every_probe_gets_its_own_request_id (test_health.Probes.test_every_probe_gets_its_own_request_id) ... ok
|
||||
test_liveness (test_health.Probes.test_liveness) ... ok
|
||||
@@ -114,6 +118,8 @@ test_broken_json_is_refused_without_echoing_it (test_validation.RequestBodies.te
|
||||
test_display_name_and_title_limits (test_validation.RequestBodies.test_display_name_and_title_limits) ... ok
|
||||
test_message_text_limits (test_validation.RequestBodies.test_message_text_limits) ... ok
|
||||
test_missing_required_fields (test_validation.RequestBodies.test_missing_required_fields) ... ok
|
||||
test_nul_is_refused_before_it_reaches_the_store (test_validation.RequestBodies.test_nul_is_refused_before_it_reaches_the_store)
|
||||
U+0000 не хранится в `text`: это 400, а не ложная недоступность базы. ... ok
|
||||
test_sender_id_cannot_be_injected (test_validation.RequestBodies.test_sender_id_cannot_be_injected) ... ok
|
||||
test_the_password_never_appears_in_an_error (test_validation.RequestBodies.test_the_password_never_appears_in_an_error) ... ok
|
||||
test_unknown_json_field_is_refused (test_validation.RequestBodies.test_unknown_json_field_is_refused) ... ok
|
||||
@@ -122,6 +128,6 @@ test_unknown_route (test_validation.Routing.test_unknown_route) ... ok
|
||||
test_wrong_method (test_validation.Routing.test_wrong_method) ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 79 tests in 29.377s
|
||||
Ran 82 tests in 30.188s
|
||||
|
||||
OK (skipped=3)
|
||||
|
||||
@@ -564,3 +564,216 @@ $ cd /c/Users/denis/Desktop/HighLoad/mtusi2026lab2 && docker compose start #
|
||||
основной стенд: готов через 2 с
|
||||
|
||||
Копия после прогона удалена: C:/Users/denis/AppData/Local/Temp/lab2-clean-clone
|
||||
|
||||
== 12б: повторный прогон из чистого clone после исправления валидации ==
|
||||
date: 2026-10-23T19:25:46Z (UTC)
|
||||
host: Windows 10 Pro 19045, x64, Git Bash; Docker 28.0.1 (Docker Desktop, WSL2)
|
||||
|
||||
Зачем: после транскрипта выше добавлены три регрессионных теста — пароль только из
|
||||
пробельных символов и U+0000 в сохраняемых строках дают 400 invalid_request, — а
|
||||
503 unavailable сужен до отказов соединения и пула. Ниже тот же сценарий целиком
|
||||
на итоговом дереве: снова копия без игнорируемых Git файлов, сборка без кэша,
|
||||
пустой том и все проверки. Инфраструктура и последовательность команд не менялись.
|
||||
|
||||
$ docker compose stop # в основном репозитории: освобождаем порт 8080 и имя проекта
|
||||
Container mtusi2026lab2-api-1 Stopping
|
||||
Container mtusi2026lab2-api-1 Stopped
|
||||
Container mtusi2026lab2-migrate-1 Stopping
|
||||
Container mtusi2026lab2-valkey-1 Stopping
|
||||
Container mtusi2026lab2-migrate-1 Stopped
|
||||
Container mtusi2026lab2-postgres-1 Stopping
|
||||
Container mtusi2026lab2-postgres-1 Stopped
|
||||
Container mtusi2026lab2-valkey-1 Stopped
|
||||
|
||||
$ mkdir -p /c/Users/denis/AppData/Local/Temp/lab2-clean-clone && tar -c --exclude=.git --exclude=.venv --exclude=secrets \
|
||||
--exclude=.env --exclude=__pycache__ --exclude="*.pyc" . | tar -x -C /c/Users/denis/AppData/Local/Temp/lab2-clean-clone
|
||||
скопировано: 98 файлов
|
||||
|
||||
$ cd /c/Users/denis/AppData/Local/Temp/lab2-clean-clone
|
||||
$ cp .env.example .env && sh scripts/bootstrap-secrets.sh
|
||||
create secrets/postgres_password
|
||||
create secrets/cursor_secret
|
||||
create secrets/cache_url
|
||||
create secrets/database_url
|
||||
done: /c/Users/denis/AppData/Local/Temp/lab2-clean-clone/secrets
|
||||
next: docker compose up -d --build
|
||||
|
||||
$ docker compose --env-file .env config --quiet # валидность до сборки
|
||||
config: OK
|
||||
|
||||
$ time docker compose --env-file .env build --no-cache
|
||||
#27 [api] resolving provenance for metadata file
|
||||
#27 DONE 0.0s
|
||||
api Built
|
||||
migrate Built
|
||||
|
||||
real 2m49.033s
|
||||
user 0m0.030s
|
||||
sys 0m0.076s
|
||||
|
||||
$ time docker compose --env-file .env up -d
|
||||
$ time docker compose --env-file .env up -d
|
||||
Network lab2-clean-clone_backend Creating
|
||||
Network lab2-clean-clone_backend Created
|
||||
Volume "lab2-clean-clone_pgdata" Creating
|
||||
Volume "lab2-clean-clone_pgdata" Created
|
||||
Volume "lab2-clean-clone_valkeydata" Creating
|
||||
Volume "lab2-clean-clone_valkeydata" Created
|
||||
Container lab2-clean-clone-postgres-1 Creating
|
||||
Container lab2-clean-clone-valkey-1 Creating
|
||||
Container lab2-clean-clone-postgres-1 Created
|
||||
Container lab2-clean-clone-migrate-1 Creating
|
||||
Container lab2-clean-clone-valkey-1 Created
|
||||
Container lab2-clean-clone-migrate-1 Created
|
||||
Container lab2-clean-clone-api-1 Creating
|
||||
Container lab2-clean-clone-api-1 Created
|
||||
Container lab2-clean-clone-postgres-1 Starting
|
||||
Container lab2-clean-clone-valkey-1 Starting
|
||||
Container lab2-clean-clone-valkey-1 Started
|
||||
Container lab2-clean-clone-postgres-1 Started
|
||||
Container lab2-clean-clone-postgres-1 Waiting
|
||||
Container lab2-clean-clone-postgres-1 Healthy
|
||||
Container lab2-clean-clone-migrate-1 Starting
|
||||
Container lab2-clean-clone-migrate-1 Started
|
||||
Container lab2-clean-clone-valkey-1 Waiting
|
||||
Container lab2-clean-clone-migrate-1 Waiting
|
||||
Container lab2-clean-clone-postgres-1 Waiting
|
||||
Container lab2-clean-clone-valkey-1 Healthy
|
||||
Container lab2-clean-clone-postgres-1 Healthy
|
||||
Container lab2-clean-clone-migrate-1 Exited
|
||||
Container lab2-clean-clone-api-1 Starting
|
||||
Container lab2-clean-clone-api-1 Started
|
||||
|
||||
real 0m7.912s
|
||||
user 0m0.000s
|
||||
sys 0m0.106s
|
||||
|
||||
Ожидание готовности: опрос GET /health/ready раз в секунду
|
||||
готов через 1 с
|
||||
$ curl -s http://127.0.0.1:8080/health/ready
|
||||
{"status":"ok"}
|
||||
|
||||
$ docker compose --env-file .env ps --all
|
||||
lab2-clean-clone-api-1 mtusi-messenger-lab2:2.0.0 "python -m messenger" api 8 seconds ago Up 1 second (health: starting) 127.0.0.1:8080->8080/tcp
|
||||
lab2-clean-clone-migrate-1 mtusi-messenger-lab2:2.0.0 "alembic upgrade head" migrate 8 seconds ago Exited (0) 1 second ago
|
||||
lab2-clean-clone-postgres-1 postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4 "docker-entrypoint.s…" postgres 9 seconds ago Up 8 seconds (healthy) 5432/tcp
|
||||
lab2-clean-clone-valkey-1 valkey/valkey:8.0.11-trixie@sha256:4436c94fc34ce4af0354b9379d433a1f258998fb955f995c89822f98c14a8cab "tini -- docker-entr…" valkey 9 seconds ago Up 8 seconds (healthy) 6379/tcp
|
||||
|
||||
$ python3 -m venv .venv && .venv/Scripts/python.exe -m pip install --quiet -r requirements-dev.txt
|
||||
sys 0m0.015s
|
||||
Python 3.11.9
|
||||
|
||||
$ make check
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
|
||||
$ make validate PYTHON=.venv/Scripts/python.exe
|
||||
.venv/Scripts/python.exe scripts/validate_openapi.py
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
|
||||
$ make test BASE_URL=http://127.0.0.1:8080
|
||||
python3 tests/smoke.py --base-url "http://127.0.0.1:8080"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
$ make test-persistence ACTION_SCRIPT=scripts/restart.cmd BASE_URL=http://127.0.0.1:8080
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.cmd" --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.
|
||||
|
||||
$ sh scripts/restart.sh # тот же хук из POSIX-оболочки
|
||||
lab2-clean-clone-api-1 mtusi-messenger-lab2:2.0.0 "python -m messenger" api 59 seconds ago Up Less than a second (health: starting) 127.0.0.1:8080->8080/tcp
|
||||
lab2-clean-clone-postgres-1 postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4 "docker-entrypoint.s…" postgres About a minute ago Up Less than a second (health: starting) 5432/tcp
|
||||
lab2-clean-clone-valkey-1 valkey/valkey:8.0.11-trixie@sha256:4436c94fc34ce4af0354b9379d433a1f258998fb955f995c89822f98c14a8cab "tini -- docker-entr…" valkey About a minute ago Up Less than a second (health: starting) 6379/tcp
|
||||
running services: api postgres valkey
|
||||
restart complete
|
||||
|
||||
$ time make student-test BASE_URL=http://127.0.0.1:8080 PYTHON="python3 -X utf8"
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 82 tests in 30.852s
|
||||
|
||||
OK (skipped=3)
|
||||
|
||||
real 0m31.300s
|
||||
user 0m0.015s
|
||||
sys 0m0.000s
|
||||
|
||||
Полный построчный вывод этих же 82 тестов — в доказательстве 03 (тот же запуск
|
||||
на итоговом дереве; здесь только итог, чтобы не дублировать 130 строк).
|
||||
|
||||
$ docker compose --env-file .env stop # безопасная остановка: тома остаются
|
||||
Container lab2-clean-clone-valkey-1 Stopping
|
||||
Container lab2-clean-clone-migrate-1 Stopping
|
||||
Container lab2-clean-clone-migrate-1 Stopped
|
||||
Container lab2-clean-clone-postgres-1 Stopping
|
||||
Container lab2-clean-clone-postgres-1 Stopped
|
||||
Container lab2-clean-clone-valkey-1 Stopped
|
||||
|
||||
$ docker volume ls --filter name=lab2-clean-clone --format "{{.Name}}"
|
||||
lab2-clean-clone_pgdata
|
||||
lab2-clean-clone_valkeydata
|
||||
|
||||
$ docker compose --env-file .env start # данные на месте, стенд снова жив
|
||||
$ docker compose --env-file .env start
|
||||
Container lab2-clean-clone-valkey-1 Starting
|
||||
Container lab2-clean-clone-postgres-1 Starting
|
||||
Container lab2-clean-clone-valkey-1 Started
|
||||
Container lab2-clean-clone-postgres-1 Started
|
||||
Container lab2-clean-clone-postgres-1 Waiting
|
||||
Container lab2-clean-clone-postgres-1 Healthy
|
||||
Container lab2-clean-clone-migrate-1 Starting
|
||||
Container lab2-clean-clone-migrate-1 Started
|
||||
Container lab2-clean-clone-migrate-1 Waiting
|
||||
Container lab2-clean-clone-postgres-1 Waiting
|
||||
Container lab2-clean-clone-valkey-1 Waiting
|
||||
Container lab2-clean-clone-valkey-1 Healthy
|
||||
Container lab2-clean-clone-postgres-1 Healthy
|
||||
Container lab2-clean-clone-migrate-1 Exited
|
||||
Container lab2-clean-clone-api-1 Starting
|
||||
Container lab2-clean-clone-api-1 Started
|
||||
|
||||
$ docker compose --env-file .env ps --all
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
lab2-clean-clone-api-1 mtusi-messenger-lab2:2.0.0 "python -m messenger" api 27 seconds ago Up Less than a second (health: starting) 127.0.0.1:8080->8080/tcp
|
||||
lab2-clean-clone-migrate-1 mtusi-messenger-lab2:2.0.0 "alembic upgrade head" migrate About a minute ago Exited (0) Less than a second ago
|
||||
lab2-clean-clone-postgres-1 postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4 "docker-entrypoint.s…" postgres About a minute ago Up 7 seconds (healthy) 5432/tcp
|
||||
lab2-clean-clone-valkey-1 valkey/valkey:8.0.11-trixie@sha256:4436c94fc34ce4af0354b9379d433a1f258998fb955f995c89822f98c14a8cab "tini -- docker-entr…" valkey About a minute ago Up 7 seconds (healthy) 6379/tcp
|
||||
|
||||
$ docker compose --env-file .env down # удаляет контейнеры, но не тома
|
||||
$ docker compose --env-file .env down
|
||||
Container lab2-clean-clone-api-1 Stopping
|
||||
Container lab2-clean-clone-api-1 Stopped
|
||||
Container lab2-clean-clone-api-1 Removing
|
||||
Container lab2-clean-clone-api-1 Removed
|
||||
Container lab2-clean-clone-valkey-1 Stopping
|
||||
Container lab2-clean-clone-migrate-1 Stopping
|
||||
Container lab2-clean-clone-migrate-1 Stopped
|
||||
Container lab2-clean-clone-migrate-1 Removing
|
||||
Container lab2-clean-clone-migrate-1 Removed
|
||||
Container lab2-clean-clone-postgres-1 Stopping
|
||||
Container lab2-clean-clone-valkey-1 Stopped
|
||||
Container lab2-clean-clone-valkey-1 Removing
|
||||
Container lab2-clean-clone-postgres-1 Stopped
|
||||
Container lab2-clean-clone-postgres-1 Removing
|
||||
Container lab2-clean-clone-valkey-1 Removed
|
||||
Container lab2-clean-clone-postgres-1 Removed
|
||||
Network lab2-clean-clone_backend Removing
|
||||
Network lab2-clean-clone_backend Removed
|
||||
|
||||
$ docker compose --env-file .env down -v # намеренное удаление учебных данных
|
||||
$ docker compose --env-file .env down -v
|
||||
Volume lab2-clean-clone_valkeydata Removing
|
||||
Volume lab2-clean-clone_pgdata Removing
|
||||
Volume lab2-clean-clone_valkeydata Removed
|
||||
Volume lab2-clean-clone_pgdata Removed
|
||||
|
||||
$ docker volume ls --filter name=lab2-clean-clone --format "{{.Name}}"
|
||||
(пусто)
|
||||
|
||||
$ cd /c/Users/denis/Desktop/HighLoad/mtusi2026lab2 && docker compose start # возвращаем основной стенд
|
||||
$ docker compose ps --format "{{.Service}} {{.State}} {{.Health}}"
|
||||
api running healthy
|
||||
postgres running healthy
|
||||
valkey running healthy
|
||||
$ curl -s http://127.0.0.1:8080/health/ready
|
||||
{"status":"ok"}
|
||||
|
||||
Reference in New Issue
Block a user