Files
mtusi2026lab2/evidence/pytest.txt
vest1ter ac1317d22e ЛР2 на 5: Redis-кэш сессий, отказоустойчивость, трек 2 (индексы и восстановление)
Уровень 4:
- Redis как кэш сессий (cache-aside, источник истины — PostgreSQL): TTL <= остатка сессии,
  метка revoked при logout + SET NX против гонки, при отказе Redis — работа через базу
  и фоновая проверка доступности
- тесты: гонка регистрации, откат посреди транзакции, недоступность БД и Redis (44 теста)
- EXPLAIN (ANALYZE, BUFFERS) на 22 000 сообщений, history_query общий для API и скрипта
- эксперименты отказа Redis/PostgreSQL под нагрузкой; dns_opt у API, чтобы отказ БД
  давал быстрый 503, а не зависание на поиске имени остановленного контейнера

Уровень 5, трек 2:
- 105 000 сообщений в неравномерных чатах, 4 варианта индекса + OFFSET против keyset,
  стоимость записи (время, WAL), два независимых прогона
- pg_dump -> pg_restore в новый контейнер -> сверка md5 всех таблиц и выборки сообщений,
  RTO 14 с, демонстрация RPO
2026-10-29 15:42:37 +03:00

58 lines
4.4 KiB
Plaintext
Raw Permalink 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.
# 2026-10-29T13:55:35 student tests (PostgreSQL DB messenger_test, Redis DB 15)
$ .venv\Scripts\python.exe -m pytest -v
============================= test session starts =============================
platform win32 -- Python 3.14.3, pytest-9.1.1, pluggy-1.7.0 -- D:\диск С\Документы\unic\VP\lab2\mtusi2026lab2\.venv\Scripts\python.exe
rootdir: D:\диск С\Документы\unic\VP\lab2\mtusi2026lab2
configfile: pytest.ini
testpaths: student-tests
plugins: anyio-4.15.1
collecting ... collected 44 items
student-tests/test_auth_api.py::test_login_returns_session PASSED [ 2%]
student-tests/test_auth_api.py::test_jwt_payload_contains_sub_exp_jti PASSED [ 4%]
student-tests/test_auth_api.py::test_wrong_password_and_unknown_user_give_same_401 PASSED [ 6%]
student-tests/test_auth_api.py::test_malformed_basic_returns_401 PASSED [ 9%]
student-tests/test_auth_api.py::test_login_with_body_returns_400_and_creates_no_session PASSED [ 11%]
student-tests/test_auth_api.py::test_password_with_colon_and_unicode PASSED [ 13%]
student-tests/test_auth_api.py::test_protected_endpoint_requires_bearer PASSED [ 15%]
student-tests/test_auth_api.py::test_x_user_id_does_not_override_token PASSED [ 18%]
student-tests/test_auth_api.py::test_forged_token_is_rejected PASSED [ 20%]
student-tests/test_auth_api.py::test_logout_revokes_only_current_token PASSED [ 22%]
student-tests/test_auth_api.py::test_session_expires PASSED [ 25%]
student-tests/test_chats_api.py::test_unknown_member_returns_400_and_nothing_is_saved PASSED [ 27%]
student-tests/test_chats_api.py::test_created_chat_is_stored_with_members PASSED [ 29%]
student-tests/test_chats_api.py::test_foreign_chat_returns_404 PASSED [ 31%]
student-tests/test_chats_api.py::test_member_sees_chat PASSED [ 34%]
student-tests/test_chats_api.py::test_creator_must_be_member PASSED [ 36%]
student-tests/test_chats_api.py::test_duplicate_members_return_400 PASSED [ 38%]
student-tests/test_failures_api.py::test_parallel_registration_of_same_username_creates_one_user PASSED [ 40%]
student-tests/test_failures_api.py::test_chat_creation_rolls_back_when_member_insert_fails PASSED [ 43%]
student-tests/test_failures_api.py::test_database_down_gives_limited_503_and_no_anonymous_access PASSED [ 45%]
student-tests/test_failures_api.py::test_database_down_cached_session_still_authenticates PASSED [ 47%]
student-tests/test_messages_api.py::test_empty_message_returns_400 PASSED [ 50%]
student-tests/test_messages_api.py::test_sender_is_taken_from_token PASSED [ 52%]
student-tests/test_messages_api.py::test_pagination_over_several_pages PASSED [ 54%]
student-tests/test_messages_api.py::test_cursor_from_another_chat_returns_400 PASSED [ 56%]
student-tests/test_messages_api.py::test_invalid_limit_returns_400 PASSED [ 59%]
student-tests/test_session_cache.py::test_login_puts_session_into_cache_without_secrets PASSED [ 61%]
student-tests/test_session_cache.py::test_cached_session_is_served_without_database PASSED [ 63%]
student-tests/test_session_cache.py::test_cache_miss_reads_database_once_and_fills_cache PASSED [ 65%]
student-tests/test_session_cache.py::test_logout_revokes_cached_session PASSED [ 68%]
student-tests/test_session_cache.py::test_slow_reader_cannot_resurrect_session_after_logout PASSED [ 70%]
student-tests/test_session_cache.py::test_revoked_token_from_database_is_not_cached PASSED [ 72%]
student-tests/test_session_cache.py::test_redis_down_falls_back_to_database PASSED [ 75%]
student-tests/test_session_cache.py::test_redis_down_does_not_slow_every_request PASSED [ 77%]
student-tests/test_session_cache.py::test_cache_comes_back_after_redis_recovers PASSED [ 79%]
student-tests/test_users_api.py::test_invalid_json_returns_400 PASSED [ 81%]
student-tests/test_users_api.py::test_extra_field_and_wrong_type_return_400 PASSED [ 84%]
student-tests/test_users_api.py::test_duplicate_username_returns_409 PASSED [ 86%]
student-tests/test_users_api.py::test_unicode_display_name_is_kept PASSED [ 88%]
student-tests/test_users_api.py::test_password_is_required_and_length_checked PASSED [ 90%]
student-tests/test_users_api.py::test_password_is_hashed_and_never_returned PASSED [ 93%]
student-tests/test_users_api.py::test_me_returns_current_user PASSED [ 95%]
student-tests/test_users_api.py::test_x_user_id_no_longer_authenticates PASSED [ 97%]
student-tests/test_users_api.py::test_every_response_has_request_id PASSED [100%]
============================= 44 passed in 39.30s =============================
exit=0