Files
mtusi2026lab2/evidence/tests/failure-checks.txt
T

81 lines
5.4 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.
# Что доказывает (уровень 4: автоматические проверки отказов): одной
# командой на отдельном стенде проверяются
# - истечение сессии при SESSION_TTL_SECONDS=2 и то, что запросы её не
# продлевают (test_expired_token_is_401, test_requests_do_not_extend_session);
# - запрос с токеном при остановленной БД — 503 без вызова аутентификации,
# после возврата тот же токен работает (test_token_while_database_stopped_is_503);
# - откат составной операции: сбой вставки участников (триггер на стенде)
# — 500, нет ни чата, ни участников (test_members_failure_rolls_back_chat);
# - остановленная БД: 503 быстро, без деталей; запись во время отказа не
# появилась (test_database_stopped_and_back);
# - замёрзшая БД и исчерпанный пул: 503 за срок операции + закрытие
# соединения, второй запрос — за срок ожидания пула
# (test_frozen_database_and_exhausted_pool);
# - readiness без БД — 503 за 2 с, live 200; без Valkey — ready 200;
# - Valkey остановлен, заморожен, очищен и вернулся: те же ответы, не
# дольше срока команды 0,2 с, кэш снова в работе без рестарта API.
# Дата (UTC): 2026-10-01T23:18:43Z — 2026-10-01T23:19:26Z
# Окружение: macOS 26.6.2, Apple M3 Pro; Docker 29.8.1, Compose 5.5.1;
# python3 хоста 3.11.9 (stand.py, fault_hook.py), pytest на Python 3.13.15
# Стенд: student-tests/stand.py failures — проект vladimirceva-lab2-failures:
# обычный API (настройки по умолчанию) и «тесный» (SESSION_TTL_SECONDS=2,
# DB_POOL_SIZE=1, DB_POOL_OVERFLOW=0, DB_POOL_TIMEOUT=1,
# DB_OPERATION_TIMEOUT=2); хранилища — только через hook
# student-tests/fault_hook.py; стенд удалён после прогона. Код src_sha256
# 8a7e256c540af433. Абсолютный путь заменён на <репозиторий>.
# Как повторить: make failure-checks FAULT_ARGS=-rP
$ time make failure-checks FAULT_ARGS=-rP
python3 student-tests/stand.py failures -rP
[failures] project=vladimirceva-lab2-failures
[failures] build image
...
[failures] start postgres and valkey
...
[failures] migrations
...
2026-10-01T23:18:46.148Z INFO alembic.runtime.migration [rid=-] Running upgrade -> 0001, messenger schema: users, sessions, chats, chat members, messages
2026-10-01T23:18:46.157Z INFO src.migrations [rid=-] migrations finished db=messenger
[failures] ready: api=http://127.0.0.1:53338 tight=http://127.0.0.1:53347
[failures] pytest -m fault
============================= 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 66 items / 54 deselected / 12 selected
student-tests/test_failures.py ............ [100%]
==================================== PASSES ====================================
________________________ test_database_stopped_and_back ________________________
----------------------------- Captured stdout call -----------------------------
postgres stopped: POST message -> 503 in 0.007s
___________________ test_frozen_database_and_exhausted_pool ____________________
----------------------------- Captured stdout call -----------------------------
postgres paused: first request -> 503 in 4.01s, second (pool of 1 busy) -> 503 in 1.01s
_______________________ test_readiness_without_database ________________________
----------------------------- Captured stdout call -----------------------------
postgres stopped: /health/ready -> 503 in 0.009s
_______________________ test_valkey_stopped_is_bypassed ________________________
----------------------------- Captured stdout call -----------------------------
valkey stopped: GET chat -> 200 in 0.017s, POST message -> 201 in 0.011s
_____________________ test_valkey_paused_costs_one_timeout _____________________
----------------------------- Captured stdout call -----------------------------
valkey paused: baseline 0.002s, first read 0.215s, second read 0.007s
====================== 12 passed, 54 deselected in 35.60s ======================
[failures] cleanup
...
[failures] results: {'fault': 0}
real 43.41
user 4.02
sys 1.99
# 12 passed, весь прогон со сборкой и уборкой — 43 с. Замёрзшая БД на
# «тесном» API: 503 через 4,01 с = срок операции 2 с + закрытие 2 с; пока
# единственное соединение пула занято, второй запрос — 503 через 1,01 с
# (срок ожидания пула). Замёрзший Valkey добавил к одному запросу 0,21 с
# (срок команды 0,2 с), следующий — без ожидания (окно пропуска 5 с).
# Тексты остальных проверок — student-tests/test_failures.py.