forked from mtusi2026/mtusi2026lab3
solution
This commit is contained in:
+5
-4
@@ -1,5 +1,6 @@
|
||||
# Доказательства
|
||||
# Evidence
|
||||
|
||||
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
|
||||
|
||||
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
|
||||
`local/` — реальные проверки текущей подготовки с точными командами и кодами.
|
||||
`lab2-history/` — исходные результаты предыдущей лабораторной, не доказательство lab3.
|
||||
`lab3/` создаётся командой `make lab3-evidence` на работающем Docker-стенде.
|
||||
Методика, значения метрик и ограничения: [EVIDENCE.md](../EVIDENCE.md).
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:04
|
||||
# Commit: 65003b6
|
||||
# Команда: python3 scripts/check_contract.py
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.06 с
|
||||
@@ -0,0 +1,9 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:05
|
||||
# Commit: 65003b6
|
||||
# Команда: make test
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
python3 tests/smoke.py --base-url "http://localhost:8080"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.58 с
|
||||
@@ -0,0 +1,11 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:05
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env ps
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
messenger-api mtusi-messenger:lab2 "python -m app" api 24 seconds ago Up 18 seconds (healthy) 127.0.0.1:8080->8080/tcp
|
||||
messenger-db postgres:16.6-bookworm "docker-entrypoint.s…" db 24 seconds ago Up 23 seconds (healthy) 127.0.0.1:5433->5432/tcp
|
||||
messenger-redis redis:7.4.1-bookworm "docker-entrypoint.s…" redis 24 seconds ago Up 23 seconds (healthy) 6379/tcp
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.07 с
|
||||
@@ -0,0 +1,8 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:05
|
||||
# Commit: 65003b6
|
||||
# Команда: docker volume inspect mtusi-messenger_pgdata --format {{.Name}} created={{.CreatedAt}}
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
mtusi-messenger_pgdata created=2026-10-23T13:16:41+03:00
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.01 с
|
||||
@@ -0,0 +1,10 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:14
|
||||
# Commit: 65003b6
|
||||
# Команда: make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost: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.
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 9.13 с
|
||||
@@ -0,0 +1,11 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:14
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env ps
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
messenger-api mtusi-messenger:lab2 "python -m app" api 33 seconds ago Up 1 second (health: starting) 127.0.0.1:8080->8080/tcp
|
||||
messenger-db postgres:16.6-bookworm "docker-entrypoint.s…" db 33 seconds ago Up 7 seconds (healthy) 127.0.0.1:5433->5432/tcp
|
||||
messenger-redis redis:7.4.1-bookworm "docker-entrypoint.s…" redis 33 seconds ago Up 7 seconds (healthy) 6379/tcp
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.07 с
|
||||
@@ -0,0 +1,8 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:14
|
||||
# Commit: 65003b6
|
||||
# Команда: docker volume inspect mtusi-messenger_pgdata --format {{.Name}} created={{.CreatedAt}}
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
mtusi-messenger_pgdata created=2026-10-23T13:16:41+03:00
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.01 с
|
||||
@@ -0,0 +1,83 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:15
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env exec -T db psql -U messenger -d messenger -c \d users -c \d chats -c \d chat_members -c \d messages -c \d sessions
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
Table "public.users"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
---------------+--------------------------+-----------+----------+-------------------
|
||||
id | uuid | | not null |
|
||||
username | text | | not null |
|
||||
display_name | text | | not null |
|
||||
password_hash | text | | not null |
|
||||
created_at | timestamp with time zone | | not null | clock_timestamp()
|
||||
Indexes:
|
||||
"users_pkey" PRIMARY KEY, btree (id)
|
||||
"users_username_key" UNIQUE CONSTRAINT, btree (username)
|
||||
Check constraints:
|
||||
"users_display_name_check" CHECK (char_length(display_name) >= 1 AND char_length(display_name) <= 100)
|
||||
"users_username_check" CHECK (username ~ '^[a-z0-9_]{3,32}$'::text)
|
||||
Referenced by:
|
||||
TABLE "chat_members" CONSTRAINT "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
TABLE "messages" CONSTRAINT "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id)
|
||||
TABLE "sessions" CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
|
||||
Table "public.chats"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
------------+--------------------------+-----------+----------+-------------------
|
||||
id | uuid | | not null |
|
||||
title | text | | not null |
|
||||
created_at | timestamp with time zone | | not null | clock_timestamp()
|
||||
Indexes:
|
||||
"chats_pkey" PRIMARY KEY, btree (id)
|
||||
"chats_created_idx" btree (created_at, id)
|
||||
Check constraints:
|
||||
"chats_title_check" CHECK (char_length(title) >= 1 AND char_length(title) <= 100)
|
||||
Referenced by:
|
||||
TABLE "chat_members" CONSTRAINT "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
|
||||
TABLE "messages" CONSTRAINT "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
|
||||
|
||||
Table "public.chat_members"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
---------+------+-----------+----------+---------
|
||||
chat_id | uuid | | not null |
|
||||
user_id | uuid | | not null |
|
||||
Indexes:
|
||||
"chat_members_pkey" PRIMARY KEY, btree (chat_id, user_id)
|
||||
"chat_members_user_idx" btree (user_id, chat_id)
|
||||
Foreign-key constraints:
|
||||
"chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
|
||||
"chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
|
||||
Table "public.messages"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
------------+--------------------------+-----------+----------+-------------------
|
||||
id | uuid | | not null |
|
||||
chat_id | uuid | | not null |
|
||||
sender_id | uuid | | not null |
|
||||
text | text | | not null |
|
||||
created_at | timestamp with time zone | | not null | clock_timestamp()
|
||||
Indexes:
|
||||
"messages_pkey" PRIMARY KEY, btree (id)
|
||||
"messages_chat_created_idx" btree (chat_id, created_at, id)
|
||||
Check constraints:
|
||||
"messages_text_check" CHECK (char_length(text) >= 1 AND char_length(text) <= 4000)
|
||||
Foreign-key constraints:
|
||||
"messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
|
||||
"messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id)
|
||||
|
||||
Table "public.sessions"
|
||||
Column | Type | Collation | Nullable | Default
|
||||
------------+--------------------------+-----------+----------+-------------------
|
||||
token_hash | text | | not null |
|
||||
user_id | uuid | | not null |
|
||||
created_at | timestamp with time zone | | not null | clock_timestamp()
|
||||
expires_at | timestamp with time zone | | not null |
|
||||
Indexes:
|
||||
"sessions_pkey" PRIMARY KEY, btree (token_hash)
|
||||
"sessions_expires_idx" btree (expires_at)
|
||||
"sessions_user_idx" btree (user_id)
|
||||
Foreign-key constraints:
|
||||
"sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.16 с
|
||||
@@ -0,0 +1,8 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:16
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env exec -T api python -m app.migrate
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
Применено: ничего нового
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.98 с
|
||||
@@ -0,0 +1,16 @@
|
||||
# Дата (UTC): 2026-10-23 10:16:49
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env logs api
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
messenger-api | 2026-10-23T10:16:48+0000 INFO listen host=0.0.0.0 port=8080
|
||||
messenger-api | INFO: Started server process [1]
|
||||
messenger-api | INFO: Waiting for application startup.
|
||||
messenger-api | 2026-10-23T10:16:48+0000 INFO config env=lab pool=5+5 ttl=3600s store=postgres cache=redis
|
||||
messenger-api | 2026-10-23T10:16:48+0000 INFO migrations: 0001_init.sql
|
||||
messenger-api | 2026-10-23T10:16:48+0000 INFO startup: приложение готово
|
||||
messenger-api | INFO: Application startup complete.
|
||||
messenger-api | INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
|
||||
messenger-api | 2026-10-23T10:16:49+0000 INFO request request_id=4933db77a1c84e3197e740dc2e11d0f1 method=GET path=/health/ready status=200 duration_ms=14.7
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.07 с
|
||||
@@ -0,0 +1,11 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:16
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env exec -T db psql -U messenger -d messenger -c SELECT * FROM schema_migrations
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
version | applied_at
|
||||
---------------+-------------------------------
|
||||
0001_init.sql | 2026-10-23 10:16:48.774351+00
|
||||
(1 row)
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.13 с
|
||||
@@ -0,0 +1,20 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:16
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env exec -T db psql -U messenger -d messenger -c SELECT username, left(password_hash, 7) AS password_prefix, length(password_hash) AS len FROM users WHERE password_hash LIKE 'scrypt$%' LIMIT 3 -c SELECT length(token_hash) AS token_hash_len, expires_at FROM sessions LIMIT 3
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
username | password_prefix | len
|
||||
----------------------+-----------------+-----
|
||||
u_alice_cbe058671fcd | scrypt$ | 86
|
||||
u_bob_b1685b095bab | scrypt$ | 86
|
||||
u_eve_1f0c444128f3 | scrypt$ | 86
|
||||
(3 rows)
|
||||
|
||||
token_hash_len | expires_at
|
||||
----------------+-------------------------------
|
||||
64 | 2026-10-23 11:17:05.128109+00
|
||||
64 | 2026-10-23 11:17:05.223716+00
|
||||
64 | 2026-10-23 11:17:05.789433+00
|
||||
(3 rows)
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.13 с
|
||||
@@ -0,0 +1,64 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:28
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env --profile test run --rm tests python -m pytest -v --no-header -p no:cacheprovider student-tests/test_auth.py student-tests/test_session_expiry.py
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
============================= test session starts ==============================
|
||||
collecting ... collected 38 items
|
||||
|
||||
student-tests/test_auth.py::test_register_returns_user_without_secrets PASSED [ 2%]
|
||||
student-tests/test_auth.py::test_register_password_rules[None] PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_register_password_rules[] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_register_password_rules[short] PASSED [ 10%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaa] PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 15%]
|
||||
student-tests/test_auth.py::test_register_password_rules[123456789012] PASSED [ 18%]
|
||||
student-tests/test_auth.py::test_register_password_rules[\u043f\u0430\u0440\u043e\u043b\u044c] PASSED [ 21%]
|
||||
student-tests/test_auth.py::test_register_password_border_lengths PASSED [ 23%]
|
||||
student-tests/test_auth.py::test_login_success_shape PASSED [ 26%]
|
||||
student-tests/test_auth.py::test_each_login_gives_new_token PASSED [ 28%]
|
||||
student-tests/test_auth.py::test_wrong_password_and_unknown_user_look_the_same PASSED [ 31%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic] PASSED [ 34%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic !!!not-base64!!!] PASSED [ 36%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic bm9jb2xvbg==] PASSED [ 39%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic 0LjQvNGPOnBhc3N3b3JkLTEyMzQ1Ng==] PASSED [ 42%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic dXNlcjr//i1iYWQtdXRmOA==] PASSED [ 44%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Bearer abc] PASSED [ 47%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[] PASSED [ 50%]
|
||||
student-tests/test_auth.py::test_login_without_header_is_401 PASSED [ 52%]
|
||||
student-tests/test_auth.py::test_password_with_colon_and_unicode_works PASSED [ 55%]
|
||||
student-tests/test_auth.py::test_bearer_token_gives_access PASSED [ 57%]
|
||||
student-tests/test_auth.py::test_business_endpoint_rejects_basic PASSED [ 60%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[] PASSED [ 63%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer] PASSED [ 65%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer short] PASSED [ 68%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 71%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Token abc] PASSED [ 73%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[bearer] PASSED [ 76%]
|
||||
student-tests/test_auth.py::test_x_user_id_alone_gives_no_access PASSED [ 78%]
|
||||
student-tests/test_auth.py::test_x_user_id_does_not_change_owner_of_session PASSED [ 81%]
|
||||
student-tests/test_auth.py::test_logout_revokes_token_and_repeat_is_401 PASSED [ 84%]
|
||||
student-tests/test_auth.py::test_logout_without_token_is_401 PASSED [ 86%]
|
||||
student-tests/test_auth.py::test_logout_revokes_only_current_session PASSED [ 89%]
|
||||
student-tests/test_auth.py::test_session_lives_longer_than_300_seconds PASSED [ 92%]
|
||||
student-tests/test_session_expiry.py::test_session_expires_after_ttl PASSED [ 94%]
|
||||
student-tests/test_session_expiry.py::test_expired_sessions_are_cleaned_on_next_login PASSED [ 97%]
|
||||
student-tests/test_session_expiry.py::test_short_ttl_from_environment_variable PASSED [100%]
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
======================== 38 passed, 1 warning in 8.97s =========================
|
||||
Container messenger-db Running
|
||||
Container messenger-redis Running
|
||||
Container messenger-db Waiting
|
||||
Container messenger-redis Waiting
|
||||
Container messenger-redis Healthy
|
||||
Container messenger-db Healthy
|
||||
Container mtusi-messenger-tests-run-5a33a2ea2bbb Creating
|
||||
Container mtusi-messenger-tests-run-5a33a2ea2bbb Created
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 12.15 с
|
||||
@@ -0,0 +1,45 @@
|
||||
# Дата (UTC): 2026-10-23 10:17:35
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env --profile test run --rm tests python -m pytest -v --no-header -p no:cacheprovider student-tests/test_database.py student-tests/test_db_failure.py student-tests/test_transactions.py student-tests/test_duplicate_username.py
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
============================= test session starts ==============================
|
||||
collecting ... collected 19 items
|
||||
|
||||
student-tests/test_database.py::test_password_is_stored_as_scrypt_hash_not_plaintext PASSED [ 5%]
|
||||
student-tests/test_database.py::test_same_password_gives_different_hashes PASSED [ 10%]
|
||||
student-tests/test_database.py::test_session_table_keeps_token_hash_not_token PASSED [ 15%]
|
||||
student-tests/test_database.py::test_message_is_really_in_the_database PASSED [ 21%]
|
||||
student-tests/test_database.py::test_migrations_can_run_again_without_duplicating_anything PASSED [ 26%]
|
||||
student-tests/test_database.py::test_expected_tables_and_indexes_exist PASSED [ 31%]
|
||||
student-tests/test_database.py::test_primary_and_foreign_keys_are_declared PASSED [ 36%]
|
||||
student-tests/test_database.py::test_database_itself_rejects_bad_rows PASSED [ 42%]
|
||||
student-tests/test_database.py::test_chat_creation_is_atomic PASSED [ 47%]
|
||||
student-tests/test_database.py::test_successful_chat_has_all_members_in_database PASSED [ 52%]
|
||||
student-tests/test_db_failure.py::test_database_down_gives_503_and_never_trusts_anyone PASSED [ 57%]
|
||||
student-tests/test_db_failure.py::test_database_down_with_cache_up_still_needs_database_for_data PASSED [ 63%]
|
||||
student-tests/test_transactions.py::test_failure_after_chat_insert_rolls_back_whole_operation PASSED [ 68%]
|
||||
student-tests/test_transactions.py::test_pool_is_bounded_by_settings PASSED [ 73%]
|
||||
student-tests/test_transactions.py::test_exhausted_pool_gives_fast_503 PASSED [ 78%]
|
||||
student-tests/test_duplicate_username.py::test_second_registration_with_same_username_is_409 PASSED [ 84%]
|
||||
student-tests/test_duplicate_username.py::test_duplicate_does_not_replace_original_user PASSED [ 89%]
|
||||
student-tests/test_duplicate_username.py::test_username_is_case_sensitive_lowercase_only PASSED [ 94%]
|
||||
student-tests/test_duplicate_username.py::test_parallel_registration_of_same_username_creates_exactly_one PASSED [100%]
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
======================== 19 passed, 1 warning in 3.91s =========================
|
||||
Container messenger-redis Running
|
||||
Container messenger-db Running
|
||||
Container messenger-db Waiting
|
||||
Container messenger-redis Waiting
|
||||
Container messenger-db Healthy
|
||||
Container messenger-redis Healthy
|
||||
Container mtusi-messenger-tests-run-28da14e927b9 Creating
|
||||
Container mtusi-messenger-tests-run-28da14e927b9 Created
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 7.04 с
|
||||
@@ -0,0 +1,179 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:12
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env --profile test run --rm tests
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
============================= test session starts ==============================
|
||||
collecting ... collected 153 items
|
||||
|
||||
student-tests/test_auth.py::test_register_returns_user_without_secrets PASSED [ 0%]
|
||||
student-tests/test_auth.py::test_register_password_rules[None] PASSED [ 1%]
|
||||
student-tests/test_auth.py::test_register_password_rules[] PASSED [ 1%]
|
||||
student-tests/test_auth.py::test_register_password_rules[short] PASSED [ 2%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaa] PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_register_password_rules[123456789012] PASSED [ 4%]
|
||||
student-tests/test_auth.py::test_register_password_rules[\u043f\u0430\u0440\u043e\u043b\u044c] PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_register_password_border_lengths PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_login_success_shape PASSED [ 6%]
|
||||
student-tests/test_auth.py::test_each_login_gives_new_token PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_wrong_password_and_unknown_user_look_the_same PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic] PASSED [ 8%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic !!!not-base64!!!] PASSED [ 9%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic bm9jb2xvbg==] PASSED [ 9%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic 0LjQvNGPOnBhc3N3b3JkLTEyMzQ1Ng==] PASSED [ 10%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic dXNlcjr//i1iYWQtdXRmOA==] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Bearer abc] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[] PASSED [ 12%]
|
||||
student-tests/test_auth.py::test_login_without_header_is_401 PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_password_with_colon_and_unicode_works PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_bearer_token_gives_access PASSED [ 14%]
|
||||
student-tests/test_auth.py::test_business_endpoint_rejects_basic PASSED [ 15%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[] PASSED [ 15%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer] PASSED [ 16%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer short] PASSED [ 16%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 17%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Token abc] PASSED [ 18%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[bearer] PASSED [ 18%]
|
||||
student-tests/test_auth.py::test_x_user_id_alone_gives_no_access PASSED [ 19%]
|
||||
student-tests/test_auth.py::test_x_user_id_does_not_change_owner_of_session PASSED [ 20%]
|
||||
student-tests/test_auth.py::test_logout_revokes_token_and_repeat_is_401 PASSED [ 20%]
|
||||
student-tests/test_auth.py::test_logout_without_token_is_401 PASSED [ 21%]
|
||||
student-tests/test_auth.py::test_logout_revokes_only_current_session PASSED [ 22%]
|
||||
student-tests/test_auth.py::test_session_lives_longer_than_300_seconds PASSED [ 22%]
|
||||
student-tests/test_cache.py::test_token_check_is_served_from_cache_with_bounded_ttl PASSED [ 23%]
|
||||
student-tests/test_cache.py::test_cache_never_stores_raw_tokens_or_passwords PASSED [ 24%]
|
||||
student-tests/test_cache.py::test_logout_revokes_cached_session PASSED [ 24%]
|
||||
student-tests/test_cache.py::test_late_cache_fill_cannot_resurrect_revoked_session PASSED [ 25%]
|
||||
student-tests/test_cache.py::test_flushed_cache_loses_nothing PASSED [ 26%]
|
||||
student-tests/test_cache.py::test_cache_does_not_extend_short_session PASSED [ 26%]
|
||||
student-tests/test_cache.py::test_staleness_after_out_of_band_delete_is_bounded_by_cache_ttl PASSED [ 27%]
|
||||
student-tests/test_cache.py::test_redis_down_requests_bypass_cache_and_stay_fast PASSED [ 28%]
|
||||
student-tests/test_cache.py::test_redis_down_never_trusts_anonymous_or_unknown_tokens PASSED [ 28%]
|
||||
student-tests/test_cache.py::test_revocation_lost_while_redis_down_is_flushed_on_recovery PASSED [ 29%]
|
||||
student-tests/test_cache.py::test_without_cache_url_cache_is_off PASSED [ 30%]
|
||||
student-tests/test_concurrency.py::test_100_messages_from_10_clients_in_parallel PASSED [ 30%]
|
||||
student-tests/test_concurrency.py::test_parallel_chat_creation_and_reading PASSED [ 31%]
|
||||
student-tests/test_contract_basics.py::test_health_endpoints PASSED [ 32%]
|
||||
student-tests/test_contract_basics.py::test_every_response_has_unique_request_id PASSED [ 32%]
|
||||
student-tests/test_contract_basics.py::test_unknown_path_is_404_in_common_format PASSED [ 33%]
|
||||
student-tests/test_contract_basics.py::test_trailing_slash_is_not_redirected PASSED [ 33%]
|
||||
student-tests/test_contract_basics.py::test_wrong_method_is_405_in_common_format PASSED [ 34%]
|
||||
student-tests/test_contract_basics.py::test_two_users_one_chat_two_messages PASSED [ 35%]
|
||||
student-tests/test_contract_basics.py::test_chat_response_shape PASSED [ 35%]
|
||||
student-tests/test_contract_basics.py::test_unexpected_exception_gives_500_without_details PASSED [ 36%]
|
||||
student-tests/test_contract_basics.py::test_logs_have_requests_but_no_secrets PASSED [ 37%]
|
||||
student-tests/test_database.py::test_password_is_stored_as_scrypt_hash_not_plaintext PASSED [ 37%]
|
||||
student-tests/test_database.py::test_same_password_gives_different_hashes PASSED [ 38%]
|
||||
student-tests/test_database.py::test_session_table_keeps_token_hash_not_token PASSED [ 39%]
|
||||
student-tests/test_database.py::test_message_is_really_in_the_database PASSED [ 39%]
|
||||
student-tests/test_database.py::test_migrations_can_run_again_without_duplicating_anything PASSED [ 40%]
|
||||
student-tests/test_database.py::test_expected_tables_and_indexes_exist PASSED [ 41%]
|
||||
student-tests/test_database.py::test_primary_and_foreign_keys_are_declared PASSED [ 41%]
|
||||
student-tests/test_database.py::test_database_itself_rejects_bad_rows PASSED [ 42%]
|
||||
student-tests/test_database.py::test_chat_creation_is_atomic PASSED [ 43%]
|
||||
student-tests/test_database.py::test_successful_chat_has_all_members_in_database PASSED [ 43%]
|
||||
student-tests/test_db_failure.py::test_database_down_gives_503_and_never_trusts_anyone PASSED [ 44%]
|
||||
student-tests/test_db_failure.py::test_database_down_with_cache_up_still_needs_database_for_data PASSED [ 45%]
|
||||
student-tests/test_duplicate_username.py::test_second_registration_with_same_username_is_409 PASSED [ 45%]
|
||||
student-tests/test_duplicate_username.py::test_duplicate_does_not_replace_original_user PASSED [ 46%]
|
||||
student-tests/test_duplicate_username.py::test_username_is_case_sensitive_lowercase_only PASSED [ 47%]
|
||||
student-tests/test_duplicate_username.py::test_parallel_registration_of_same_username_creates_exactly_one PASSED [ 47%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[] PASSED [ 48%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ] PASSED [ 49%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ] PASSED [ 49%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\n] PASSED [ 50%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\t \n] PASSED [ 50%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\xa0] PASSED [ 51%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\u2003] PASSED [ 52%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body0] PASSED [ 52%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body1] PASSED [ 53%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body2] PASSED [ 54%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body3] PASSED [ 54%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body4] PASSED [ 55%]
|
||||
student-tests/test_empty_message.py::test_text_length_is_counted_in_characters PASSED [ 56%]
|
||||
student-tests/test_empty_message.py::test_nul_character_is_400_not_500 PASSED [ 56%]
|
||||
student-tests/test_empty_message.py::test_unicode_survives_the_database PASSED [ 57%]
|
||||
student-tests/test_empty_message.py::test_message_has_correct_fields PASSED [ 58%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[0] PASSED [ 58%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[9000] PASSED [ 59%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_chat PASSED [ 60%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_history PASSED [ 60%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_write PASSED [ 61%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_gets_404_even_with_bad_body PASSED [ 62%]
|
||||
student-tests/test_foreign_chat.py::test_unknown_chat_looks_the_same_as_foreign PASSED [ 62%]
|
||||
student-tests/test_foreign_chat.py::test_chat_list_shows_only_own_chats PASSED [ 63%]
|
||||
student-tests/test_foreign_chat.py::test_bad_chat_id_is_400 PASSED [ 64%]
|
||||
student-tests/test_foreign_chat.py::test_no_token_is_401_everywhere PASSED [ 64%]
|
||||
student-tests/test_foreign_chat.py::test_401_comes_before_404 PASSED [ 65%]
|
||||
student-tests/test_foreign_chat.py::test_member_can_read_and_write PASSED [ 66%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{] PASSED [ 66%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[not json at all] PASSED [ 67%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[] PASSED [ 67%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": "abc",}] PASSED [ 68%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[\xff\xfe\x00] PASSED [ 69%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": NaN}] PASSED [ 69%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[["username"]] PASSED [ 70%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json["text"] PASSED [ 71%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[null] PASSED [ 71%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes0] PASSED [ 72%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes1] PASSED [ 73%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes2] PASSED [ 73%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes3] PASSED [ 74%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes4] PASSED [ 75%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes5] PASSED [ 75%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes6] PASSED [ 76%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes7] PASSED [ 77%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes8] PASSED [ 77%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes9] PASSED [ 78%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes10] PASSED [ 79%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes11] PASSED [ 79%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes12] PASSED [ 80%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes13] PASSED [ 81%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes14] PASSED [ 81%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes15] PASSED [ 82%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes16] PASSED [ 83%]
|
||||
student-tests/test_invalid_json.py::test_border_values_are_accepted PASSED [ 83%]
|
||||
student-tests/test_invalid_json.py::test_lone_surrogate_is_400_not_500 PASSED [ 84%]
|
||||
student-tests/test_invalid_json.py::test_wrong_or_missing_content_type_is_415 PASSED [ 84%]
|
||||
student-tests/test_invalid_json.py::test_huge_body_is_413 PASSED [ 85%]
|
||||
student-tests/test_invalid_json.py::test_broken_json_in_message_and_chat PASSED [ 86%]
|
||||
student-tests/test_invalid_json.py::test_sender_id_in_message_is_rejected PASSED [ 86%]
|
||||
student-tests/test_invalid_json.py::test_chat_body_validation PASSED [ 87%]
|
||||
student-tests/test_pagination.py::test_walk_25_messages_by_7 PASSED [ 88%]
|
||||
student-tests/test_pagination.py::test_exact_multiple_has_no_empty_extra_page PASSED [ 88%]
|
||||
student-tests/test_pagination.py::test_limit_one_walks_everything PASSED [ 89%]
|
||||
student-tests/test_pagination.py::test_default_limit_is_50_and_max_is_100 PASSED [ 90%]
|
||||
student-tests/test_pagination.py::test_empty_history PASSED [ 90%]
|
||||
student-tests/test_pagination.py::test_limit_can_change_between_pages PASSED [ 91%]
|
||||
student-tests/test_pagination.py::test_messages_sent_during_walk_appear_at_the_end PASSED [ 92%]
|
||||
student-tests/test_pagination.py::test_created_at_is_increasing_and_utc PASSED [ 92%]
|
||||
student-tests/test_pagination.py::test_bad_limit_values PASSED [ 93%]
|
||||
student-tests/test_pagination.py::test_garbage_cursor_is_400 PASSED [ 94%]
|
||||
student-tests/test_pagination.py::test_cursor_from_another_chat_is_400 PASSED [ 94%]
|
||||
student-tests/test_pagination.py::test_chat_list_pagination PASSED [ 95%]
|
||||
student-tests/test_pagination.py::test_chat_list_cursor_cannot_be_used_for_messages PASSED [ 96%]
|
||||
student-tests/test_session_expiry.py::test_session_expires_after_ttl PASSED [ 96%]
|
||||
student-tests/test_session_expiry.py::test_expired_sessions_are_cleaned_on_next_login PASSED [ 97%]
|
||||
student-tests/test_session_expiry.py::test_short_ttl_from_environment_variable PASSED [ 98%]
|
||||
student-tests/test_transactions.py::test_failure_after_chat_insert_rolls_back_whole_operation PASSED [ 98%]
|
||||
student-tests/test_transactions.py::test_pool_is_bounded_by_settings PASSED [ 99%]
|
||||
student-tests/test_transactions.py::test_exhausted_pool_gives_fast_503 PASSED [100%]
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
======================= 153 passed, 1 warning in 33.55s ========================
|
||||
Container messenger-db Running
|
||||
Container messenger-redis Running
|
||||
Container messenger-redis Waiting
|
||||
Container messenger-db Waiting
|
||||
Container messenger-redis Healthy
|
||||
Container messenger-db Healthy
|
||||
Container mtusi-messenger-tests-run-27b6c4db6282 Creating
|
||||
Container mtusi-messenger-tests-run-27b6c4db6282 Created
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 36.72 с
|
||||
@@ -0,0 +1,10 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:12
|
||||
# Commit: 65003b6
|
||||
# Команда: grep -n -i password\|secret compose.yaml
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
13: DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:?задайте POSTGRES_USER в файле .env}:${POSTGRES_PASSWORD:?задайте POSTGRES_PASSWORD в файле .env}@db:5432/${POSTGRES_DB:?задайте POSTGRES_DB в файле .env}
|
||||
25: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?задайте POSTGRES_PASSWORD в файле .env}
|
||||
102: TEST_DB_PASSWORD: ${POSTGRES_PASSWORD:?задайте POSTGRES_PASSWORD в файле .env}
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.00 с
|
||||
@@ -0,0 +1,113 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:12
|
||||
# Commit: 65003b6
|
||||
# Команда: git ls-files --cached --others --exclude-standard
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
Dockerfile
|
||||
EVIDENCE.md
|
||||
GUIDE.md
|
||||
OPERATIONS.md
|
||||
app/__init__.py
|
||||
app/__main__.py
|
||||
app/auth.py
|
||||
app/cache.py
|
||||
app/config.py
|
||||
app/crud.py
|
||||
app/cursor.py
|
||||
app/db.py
|
||||
app/errors.py
|
||||
app/explain.py
|
||||
app/healthcheck.py
|
||||
app/http_utils.py
|
||||
app/logging_setup.py
|
||||
app/main.py
|
||||
app/middleware.py
|
||||
app/migrate.py
|
||||
app/migrations/0001_init.sql
|
||||
app/models.py
|
||||
app/routes.py
|
||||
app/schemas.py
|
||||
app/security.py
|
||||
app/timeutil.py
|
||||
compose.yaml
|
||||
env.lab2.template
|
||||
evidence/01_check_contract.txt
|
||||
evidence/02_smoke.txt
|
||||
evidence/03_ps_before.txt
|
||||
evidence/03_volume_before.txt
|
||||
evidence/04_persistence.txt
|
||||
evidence/05_ps_after.txt
|
||||
evidence/05_volume_after.txt
|
||||
evidence/06_schema.txt
|
||||
evidence/07_migrations.txt
|
||||
evidence/07_migrations_first.txt
|
||||
evidence/07_migrations_table.txt
|
||||
evidence/08_hashes.txt
|
||||
evidence/09_auth_tests.txt
|
||||
evidence/10_database_tests.txt
|
||||
evidence/11_all_tests.txt
|
||||
evidence/12_compose_no_secrets.txt
|
||||
evidence/12_git_files.txt
|
||||
evidence/12_git_secrets.txt
|
||||
evidence/13_storage.txt
|
||||
evidence/14_dependencies.txt
|
||||
evidence/15_explain.txt
|
||||
evidence/15_explain_tests.txt
|
||||
evidence/16_expiry_live.txt
|
||||
pytest.ini
|
||||
requirements-test.txt
|
||||
requirements.txt
|
||||
scripts/check_expiry.py
|
||||
scripts/collect_evidence.sh
|
||||
scripts/dependency_demo.py
|
||||
scripts/restart.bat
|
||||
scripts/restart.sh
|
||||
scripts/run_and_save.py
|
||||
scripts/storage_demo.py
|
||||
student-tests/conftest.py
|
||||
student-tests/test_auth.py
|
||||
student-tests/test_cache.py
|
||||
student-tests/test_concurrency.py
|
||||
student-tests/test_contract_basics.py
|
||||
student-tests/test_database.py
|
||||
student-tests/test_db_failure.py
|
||||
student-tests/test_duplicate_username.py
|
||||
student-tests/test_empty_message.py
|
||||
student-tests/test_explain.py
|
||||
student-tests/test_foreign_chat.py
|
||||
student-tests/test_invalid_json.py
|
||||
student-tests/test_pagination.py
|
||||
student-tests/test_session_expiry.py
|
||||
student-tests/test_transactions.py
|
||||
.dockerignore
|
||||
.env.example
|
||||
.github/pull_request_template.md
|
||||
.github/workflows/contracts.yml
|
||||
.gitignore
|
||||
CONTRIBUTING.md
|
||||
COURSE.md
|
||||
Dockerfile.example
|
||||
MAINTAINERS.md
|
||||
Makefile
|
||||
README.md
|
||||
REPORT.md
|
||||
compose.example.yaml
|
||||
contracts/README.md
|
||||
contracts/examples.json
|
||||
contracts/infrastructure.json
|
||||
contracts/openapi.json
|
||||
evidence/README.md
|
||||
examples/requests.http
|
||||
infra/README.md
|
||||
lab.json
|
||||
requirements-dev.txt
|
||||
scripts/check_contract.py
|
||||
scripts/restart.example.sh
|
||||
scripts/validate_openapi.py
|
||||
tests/README.md
|
||||
tests/client.py
|
||||
tests/load.py
|
||||
tests/resilience.py
|
||||
tests/smoke.py
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.00 с
|
||||
@@ -0,0 +1,8 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:12
|
||||
# Commit: 65003b6
|
||||
# Команда: git check-ignore -v .env
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
.gitignore:2:.env .env
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 0.00 с
|
||||
@@ -0,0 +1,194 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:23
|
||||
# Commit: 65003b6
|
||||
# Команда: python scripts/storage_demo.py --mode down
|
||||
|
||||
|
||||
==============================================================================
|
||||
1. Как устроено приложение
|
||||
==============================================================================
|
||||
Приложение -- мессенджер: HTTP API (FastAPI), PostgreSQL и Redis (кэш сессий).
|
||||
* Сам API состояния не хранит: пользователи, чаты, участники, сообщения и сессии
|
||||
лежат в PostgreSQL (таблицы users, chats, chat_members, messages, sessions).
|
||||
* Файлы PostgreSQL лежат не в контейнере, а в именованном томе Docker (pgdata).
|
||||
Контейнеры api и db временные, том постоянный.
|
||||
* Пароль хранится как scrypt-хеш, у сессии в БД лежит только SHA-256 токена,
|
||||
срок сессии считает сама БД -- перезапуск его не продлевает и не сбрасывает.
|
||||
* Redis только кэширует проверку токена (без persistence): после перезапуска
|
||||
кэш пуст, и сессии читаются из PostgreSQL.
|
||||
Ожидание: пока том не удалён (команда down -v здесь НЕ используется), после
|
||||
удаления и повторного создания контейнеров (docker compose down, затем up -d)
|
||||
те же пользователи, чат, сообщение и тот же токен продолжают работать.
|
||||
План: (1) создать данные через API, (2) показать их в БД, (3) выключить,
|
||||
(4) включить, (5) проверить, что данные и токены прежние.
|
||||
|
||||
|
||||
==============================================================================
|
||||
2. Состояние до начала
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env ps
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
messenger-api mtusi-messenger:lab2 "python -m app" api About a minute ago Up 59 seconds (healthy) 127.0.0.1:8080->8080/tcp
|
||||
messenger-db postgres:16.6-bookworm "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 127.0.0.1:5433->5432/tcp
|
||||
messenger-redis redis:7.4.1-bookworm "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp
|
||||
$ docker volume ls --filter name=pgdata --format {{.Name}}
|
||||
mtusi-messenger_pgdata
|
||||
$ docker volume inspect mtusi-messenger_pgdata --format "{{.Name}} создан: {{.CreatedAt}}"
|
||||
mtusi-messenger_pgdata создан: 2026-10-23T13:16:41+03:00
|
||||
|
||||
==============================================================================
|
||||
3. Запись данных через API (создаём пользователей, чат, сообщение)
|
||||
==============================================================================
|
||||
$ POST /api/v1/users # регистрация Алисы
|
||||
тело запроса: {"username": "demo_a_7681083c", "display_name": "Алиса", "password": "***"}
|
||||
ответ: 201 {"id": "a0fce947-1cb5-4780-ba66-daddb74fadea", "username": "demo_a_7681083c", "display_name": "Алиса", "created_at": "2026-10-23T10:18:12.849116Z"}
|
||||
$ POST /api/v1/users # регистрация Боба
|
||||
тело запроса: {"username": "demo_b_7681083c", "display_name": "Боб", "password": "***"}
|
||||
ответ: 201 {"id": "2c34c828-f3c2-46ae-8055-bfaa49de3789", "username": "demo_b_7681083c", "display_name": "Боб", "created_at": "2026-10-23T10:18:12.903720Z"}
|
||||
$ POST /api/v1/auth/sessions # вход Алисы (Basic)
|
||||
ответ: 201 {"token": "<скрыт, 43 симв.>", "token_type": "Bearer", "expires_at": "2026-10-23T11:18:12.910850Z", "user": {"id": "a0fce947-1cb5-4780-ba66-daddb74fadea", "username": "demo_a_7681083c", "display_name": "Алиса", "created_at": "2026-10-23T10:18:12.849116Z"}}
|
||||
$ POST /api/v1/auth/sessions # вход Боба (Basic)
|
||||
ответ: 201 {"token": "<скрыт, 43 симв.>", "token_type": "Bearer", "expires_at": "2026-10-23T11:18:12.961660Z", "user": {"id": "2c34c828-f3c2-46ae-8055-bfaa49de3789", "username": "demo_b_7681083c", "display_name": "Боб", "created_at": "2026-10-23T10:18:12.903720Z"}}
|
||||
$ POST /api/v1/chats # чат Алисы и Боба (Bearer)
|
||||
тело запроса: {"title": "Проверка сохранности 7681083c", "member_ids": ["a0fce947-1cb5-4780-ba66-daddb74fadea", "2c34c828-f3c2-46ae-8055-bfaa49de3789"]}
|
||||
ответ: 201 {"id": "051a293a-c75d-45f5-b4ab-7e24ef0833f4", "title": "Проверка сохранности 7681083c", "member_ids": ["2c34c828-f3c2-46ae-8055-bfaa49de3789", "a0fce947-1cb5-4780-ba66-daddb74fadea"], "created_at": "2026-10-23T10:18:13.013118Z"}
|
||||
$ POST /api/v1/chats/051a293a-c75d-45f5-b4ab-7e24ef0833f4/messages # сообщение Алисы
|
||||
тело запроса: {"text": "Это сообщение должно пережить перезапуск 7681083c"}
|
||||
ответ: 201 {"id": "8d7c0e89-8043-413d-b3f0-d6bca0062b3e", "chat_id": "051a293a-c75d-45f5-b4ab-7e24ef0833f4", "sender_id": "a0fce947-1cb5-4780-ba66-daddb74fadea", "text": "Это сообщение должно пережить перезапуск 7681083c", "created_at": "2026-10-23T10:18:13.025076Z"}
|
||||
|
||||
==============================================================================
|
||||
4. Что лежит в PostgreSQL ДО выключения (SELECT внутри контейнера db)
|
||||
==============================================================================
|
||||
-- пользователи (пароль -- только префикс хеша)
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT username, display_name, left(password_hash, 7) AS password_prefix, created_at FROM users WHERE username IN ('demo_a_7681083c', 'demo_b_7681083c') ORDER BY username"
|
||||
username | display_name | password_prefix | created_at
|
||||
-----------------+--------------+-----------------+-------------------------------
|
||||
demo_a_7681083c | Алиса | scrypt$ | 2026-10-23 10:18:12.849116+00
|
||||
demo_b_7681083c | Боб | scrypt$ | 2026-10-23 10:18:12.90372+00
|
||||
(2 rows)
|
||||
-- чат и число участников
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT c.title, count(m.user_id) AS members FROM chats c JOIN chat_members m ON m.chat_id = c.id WHERE c.id = '051a293a-c75d-45f5-b4ab-7e24ef0833f4' GROUP BY c.title"
|
||||
title | members
|
||||
-------------------------------+---------
|
||||
Проверка сохранности 7681083c | 2
|
||||
(1 row)
|
||||
-- сообщение
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT id, sender_id, text, created_at FROM messages WHERE chat_id = '051a293a-c75d-45f5-b4ab-7e24ef0833f4'"
|
||||
id | sender_id | text | created_at
|
||||
--------------------------------------+--------------------------------------+---------------------------------------------------+-------------------------------
|
||||
8d7c0e89-8043-413d-b3f0-d6bca0062b3e | a0fce947-1cb5-4780-ba66-daddb74fadea | Это сообщение должно пережить перезапуск 7681083c | 2026-10-23 10:18:13.025076+00
|
||||
(1 row)
|
||||
-- действующие сессии (токены не показываем)
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT count(*) AS live_sessions FROM sessions s JOIN users u ON u.id = s.user_id WHERE u.username IN ('demo_a_7681083c', 'demo_b_7681083c') AND s.expires_at > now()"
|
||||
live_sessions
|
||||
---------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
==============================================================================
|
||||
5. Выключаем приложение (контейнеры УДАЛЯЮТСЯ, том остаётся)
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env down
|
||||
Container messenger-api Stopping
|
||||
Container messenger-api Stopped
|
||||
Container messenger-api Removing
|
||||
Container messenger-api Removed
|
||||
Container messenger-db Stopping
|
||||
Container messenger-redis Stopping
|
||||
Container messenger-redis Stopped
|
||||
Container messenger-redis Removing
|
||||
Container messenger-redis Removed
|
||||
Container messenger-db Stopped
|
||||
Container messenger-db Removing
|
||||
Container messenger-db Removed
|
||||
Network mtusi-messenger_default Removing
|
||||
Network mtusi-messenger_default Removed
|
||||
$ docker compose --env-file .env ps -a
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
API на http://localhost:8080 не отвечает -- приложение выключено (так и должно быть).
|
||||
-- том с данными на месте:
|
||||
$ docker volume ls --filter name=pgdata
|
||||
DRIVER VOLUME NAME
|
||||
local mtusi-messenger_pgdata
|
||||
|
||||
==============================================================================
|
||||
6. Включаем снова
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env up -d
|
||||
Network mtusi-messenger_default Creating
|
||||
Network mtusi-messenger_default Creating
|
||||
Network mtusi-messenger_default Created
|
||||
Network mtusi-messenger_default Created
|
||||
Container messenger-db Creating
|
||||
Container messenger-redis Creating
|
||||
Container messenger-redis Created
|
||||
Container messenger-db Created
|
||||
Container messenger-api Creating
|
||||
Container messenger-api Created
|
||||
Container messenger-db Starting
|
||||
Container messenger-redis Starting
|
||||
Container messenger-db Started
|
||||
Container messenger-redis Started
|
||||
Container messenger-db Waiting
|
||||
Container messenger-db Healthy
|
||||
Container messenger-api Starting
|
||||
Container messenger-api Started
|
||||
API снова готов (/health/ready = 200) через 2 с.
|
||||
$ docker compose --env-file .env ps
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
messenger-api mtusi-messenger:lab2 "python -m app" api 7 seconds ago Up 2 seconds (health: starting) 127.0.0.1:8080->8080/tcp
|
||||
messenger-db postgres:16.6-bookworm "docker-entrypoint.s…" db 7 seconds ago Up 7 seconds (healthy) 127.0.0.1:5433->5432/tcp
|
||||
messenger-redis redis:7.4.1-bookworm "docker-entrypoint.s…" redis 7 seconds ago Up 7 seconds (healthy) 6379/tcp
|
||||
|
||||
==============================================================================
|
||||
7. Проверка ПОСЛЕ перезапуска: те же данные и те же токены
|
||||
==============================================================================
|
||||
$ GET /api/v1/users/me # старый токен Алисы, повторный вход НЕ делали
|
||||
ответ: 200 {"id": "a0fce947-1cb5-4780-ba66-daddb74fadea", "username": "demo_a_7681083c", "display_name": "Алиса", "created_at": "2026-10-23T10:18:12.849116Z"}
|
||||
OK: тот же пользователь (id, username, created_at совпали).
|
||||
$ GET /api/v1/chats/051a293a-c75d-45f5-b4ab-7e24ef0833f4/messages # старый токен Боба читает историю чата
|
||||
ответ: 200 {"items": [{"id": "8d7c0e89-8043-413d-b3f0-d6bca0062b3e", "chat_id": "051a293a-c75d-45f5-b4ab-7e24ef0833f4", "sender_id": "a0fce947-1cb5-4780-ba66-daddb74fadea", "text": "Это сообщение должно пережить перезапуск 7681083c", "created_at": "2026-10-23T10:18:13.025076Z"}], "next_cursor": null}
|
||||
OK: то же сообщение (id, text, created_at совпали).
|
||||
$ GET /api/v1/chats?limit=100 # список чатов Алисы
|
||||
ответ: 200 {"items": [{"id": "051a293a-c75d-45f5-b4ab-7e24ef0833f4", "title": "Проверка сохранности 7681083c", "member_ids": ["2c34c828-f3c2-46ae-8055-bfaa49de3789", "a0fce947-1cb5-4780-ba66-daddb74fadea"], "created_at": "2026-10-23T10:18:13.013118Z"}], "next_cursor": null}
|
||||
OK: чат в списке.
|
||||
|
||||
Те же SELECT после перезапуска (сравниваем с выводом из пункта 4):
|
||||
-- пользователи (пароль -- только префикс хеша)
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT username, display_name, left(password_hash, 7) AS password_prefix, created_at FROM users WHERE username IN ('demo_a_7681083c', 'demo_b_7681083c') ORDER BY username"
|
||||
username | display_name | password_prefix | created_at
|
||||
-----------------+--------------+-----------------+-------------------------------
|
||||
demo_a_7681083c | Алиса | scrypt$ | 2026-10-23 10:18:12.849116+00
|
||||
demo_b_7681083c | Боб | scrypt$ | 2026-10-23 10:18:12.90372+00
|
||||
(2 rows)
|
||||
OK: вывод идентичен выводу до перезапуска.
|
||||
-- чат и число участников
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT c.title, count(m.user_id) AS members FROM chats c JOIN chat_members m ON m.chat_id = c.id WHERE c.id = '051a293a-c75d-45f5-b4ab-7e24ef0833f4' GROUP BY c.title"
|
||||
title | members
|
||||
-------------------------------+---------
|
||||
Проверка сохранности 7681083c | 2
|
||||
(1 row)
|
||||
OK: вывод идентичен выводу до перезапуска.
|
||||
-- сообщение
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT id, sender_id, text, created_at FROM messages WHERE chat_id = '051a293a-c75d-45f5-b4ab-7e24ef0833f4'"
|
||||
id | sender_id | text | created_at
|
||||
--------------------------------------+--------------------------------------+---------------------------------------------------+-------------------------------
|
||||
8d7c0e89-8043-413d-b3f0-d6bca0062b3e | a0fce947-1cb5-4780-ba66-daddb74fadea | Это сообщение должно пережить перезапуск 7681083c | 2026-10-23 10:18:13.025076+00
|
||||
(1 row)
|
||||
OK: вывод идентичен выводу до перезапуска.
|
||||
-- действующие сессии (токены не показываем)
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c "SELECT count(*) AS live_sessions FROM sessions s JOIN users u ON u.id = s.user_id WHERE u.username IN ('demo_a_7681083c', 'demo_b_7681083c') AND s.expires_at > now()"
|
||||
live_sessions
|
||||
---------------
|
||||
2
|
||||
(1 row)
|
||||
OK: вывод идентичен выводу до перезапуска.
|
||||
|
||||
-- том тот же (дата создания не изменилась):
|
||||
$ docker volume inspect mtusi-messenger_pgdata --format "{{.Name}} создан: {{.CreatedAt}}"
|
||||
mtusi-messenger_pgdata создан: 2026-10-23T13:16:41+03:00
|
||||
OK: том не пересоздавался.
|
||||
|
||||
==============================================================================
|
||||
ИТОГ
|
||||
==============================================================================
|
||||
ИТОГ: PASS -- пользователи, чат, сообщение и действующие сессии сохранились после удаления и повторного создания контейнеров (docker compose down, затем up -d).
|
||||
@@ -0,0 +1,323 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:23
|
||||
# Commit: 65003b6
|
||||
# Команда: python3 scripts/dependency_demo.py
|
||||
|
||||
==============================================================================
|
||||
0. Контейнеры
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env ps
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
messenger-api mtusi-messenger:lab2 "python -m app" api 8 seconds ago Up 2 seconds (health: starting) 127.0.0.1:8080->8080/tcp
|
||||
messenger-db postgres:16.6-bookworm "docker-entrypoint.s…" db 8 seconds ago Up 8 seconds (healthy) 127.0.0.1:5433->5432/tcp
|
||||
messenger-redis redis:7.4.1-bookworm "docker-entrypoint.s…" redis 8 seconds ago Up 8 seconds (healthy) 6379/tcp
|
||||
|
||||
==============================================================================
|
||||
1. Redis: версия и настройки (кэш, persistence выключена намеренно)
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env exec -T redis redis-server --version
|
||||
Redis server v=7.4.1 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=9ce9f16f947e6690
|
||||
$ docker compose --env-file .env exec -T redis redis-cli CONFIG GET save
|
||||
save
|
||||
$ docker compose --env-file .env exec -T redis redis-cli CONFIG GET appendonly
|
||||
appendonly
|
||||
no
|
||||
$ docker compose --env-file .env exec -T redis redis-cli CONFIG GET maxmemory-policy
|
||||
maxmemory-policy
|
||||
noeviction
|
||||
|
||||
==============================================================================
|
||||
2. Роль кэша: проверка Bearer-токена без запроса к PostgreSQL
|
||||
==============================================================================
|
||||
POST /api/v1/users -> 201 (57 мс) # регистрация
|
||||
{"id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "username": "alice_a3a3d232", "display_name": "alice", "created_at": "2026-10-23T10:18:24.048024Z"}
|
||||
POST /api/v1/auth/sessions -> 201 (52 мс) # вход (Basic)
|
||||
{"token": "<скрыт>", "token_type": "Bearer", "expires_at": "2026-10-23T11:18:24.063082Z", "user": {"id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "username": "alice_a3a3d232", "display_name": "alice", "created_at": "2026-10-23T10:18:24.048024Z"}}
|
||||
POST /api/v1/users -> 201 (47 мс) # регистрация
|
||||
{"id": "5430982a-788d-47f8-a794-b135476578df", "username": "bob_e2ebd6fa", "display_name": "bob", "created_at": "2026-10-23T10:18:24.154704Z"}
|
||||
POST /api/v1/auth/sessions -> 201 (48 мс) # вход (Basic)
|
||||
{"token": "<скрыт>", "token_type": "Bearer", "expires_at": "2026-10-23T11:18:24.161175Z", "user": {"id": "5430982a-788d-47f8-a794-b135476578df", "username": "bob_e2ebd6fa", "display_name": "bob", "created_at": "2026-10-23T10:18:24.154704Z"}}
|
||||
$ docker compose --env-file .env exec -T redis redis-cli CONFIG RESETSTAT
|
||||
OK
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -At -c "SELECT idx_scan FROM pg_stat_user_indexes WHERE indexrelname = 'sessions_pkey'"
|
||||
10
|
||||
50 x GET /api/v1/users/me -> 200; первый 4.1 мс, медиана остальных 1.7 мс
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -At -c "SELECT idx_scan FROM pg_stat_user_indexes WHERE indexrelname = 'sessions_pkey'"
|
||||
10
|
||||
Чтений индекса sessions_pkey в PostgreSQL за 50 запросов: 0
|
||||
$ docker compose --env-file .env exec -T redis redis-cli INFO stats
|
||||
# Stats
|
||||
total_connections_received:2
|
||||
total_commands_processed:53
|
||||
instantaneous_ops_per_sec:32
|
||||
total_net_input_bytes:4910
|
||||
total_net_output_bytes:7470
|
||||
total_net_repl_input_bytes:0
|
||||
total_net_repl_output_bytes:0
|
||||
instantaneous_input_kbps:2.96
|
||||
instantaneous_output_kbps:4.53
|
||||
instantaneous_input_repl_kbps:0.00
|
||||
instantaneous_output_repl_kbps:0.00
|
||||
rejected_connections:0
|
||||
sync_full:0
|
||||
sync_partial_ok:0
|
||||
sync_partial_err:0
|
||||
expired_subkeys:0
|
||||
expired_keys:0
|
||||
expired_stale_perc:0.00
|
||||
expired_time_cap_reached_count:0
|
||||
expire_cycle_cpu_milliseconds:0
|
||||
evicted_keys:0
|
||||
evicted_clients:0
|
||||
evicted_scripts:0
|
||||
total_eviction_exceeded_time:0
|
||||
current_eviction_exceeded_time:0
|
||||
keyspace_hits:49
|
||||
keyspace_misses:1
|
||||
pubsub_channels:0
|
||||
pubsub_patterns:0
|
||||
pubsubshard_channels:0
|
||||
latest_fork_usec:0
|
||||
total_forks:0
|
||||
migrate_cached_sockets:0
|
||||
slave_expires_tracked_keys:0
|
||||
active_defrag_hits:0
|
||||
active_defrag_misses:0
|
||||
active_defrag_key_hits:0
|
||||
active_defrag_key_misses:0
|
||||
total_active_defrag_time:0
|
||||
current_active_defrag_time:0
|
||||
tracking_total_keys:0
|
||||
tracking_total_items:0
|
||||
tracking_total_prefixes:0
|
||||
unexpected_error_replies:0
|
||||
total_error_replies:0
|
||||
dump_payload_sanitizations:0
|
||||
total_reads_processed:55
|
||||
total_writes_processed:53
|
||||
io_threaded_reads_processed:0
|
||||
io_threaded_writes_processed:0
|
||||
client_query_buffer_limit_disconnections:0
|
||||
client_output_buffer_limit_disconnections:0
|
||||
reply_buffer_shrinks:0
|
||||
reply_buffer_expands:0
|
||||
eventloop_cycles:81
|
||||
eventloop_duration_sum:14650
|
||||
eventloop_duration_cmd_sum:128
|
||||
instantaneous_eventloop_cycles_per_sec:42
|
||||
instantaneous_eventloop_duration_usec:452
|
||||
acl_access_denied_auth:0
|
||||
acl_access_denied_cmd:0
|
||||
acl_access_denied_key:0
|
||||
acl_access_denied_channel:0
|
||||
Redis: keyspace_hits=49 keyspace_misses=1
|
||||
$ docker compose --env-file .env exec -T redis redis-cli PTTL session:<sha256 токена>
|
||||
58542
|
||||
TTL ключа сессии: 58542 мс (<= CACHE_TTL_SECONDS=60 с и <= остатка сессии)
|
||||
$ docker compose --env-file .env exec -T redis redis-cli GET session:<sha256 токена>
|
||||
{"id":"2454e675-039f-49b3-92f0-e2e492e0cefc","username":"alice_a3a3d232","display_name":"alice","created_at":"2026-10-23T10:18:24.048024+00:00"}
|
||||
|
||||
==============================================================================
|
||||
3. Logout: DELETE в PostgreSQL, затем отметка отзыва в Redis
|
||||
==============================================================================
|
||||
POST /api/v1/users -> 201 (54 мс) # регистрация
|
||||
{"id": "b3b307ec-a474-451c-a347-51450f51fec8", "username": "carol_e6a6b17a", "display_name": "carol", "created_at": "2026-10-23T10:18:27.081509Z"}
|
||||
POST /api/v1/auth/sessions -> 201 (49 мс) # вход (Basic)
|
||||
{"token": "<скрыт>", "token_type": "Bearer", "expires_at": "2026-10-23T11:18:27.095801Z", "user": {"id": "b3b307ec-a474-451c-a347-51450f51fec8", "username": "carol_e6a6b17a", "display_name": "carol", "created_at": "2026-10-23T10:18:27.081509Z"}}
|
||||
GET /api/v1/users/me -> 200 (4 мс) # кладёт сессию в кэш
|
||||
{"id": "b3b307ec-a474-451c-a347-51450f51fec8", "username": "carol_e6a6b17a", "display_name": "carol", "created_at": "2026-10-23T10:18:27.081509Z"}
|
||||
DELETE /api/v1/auth/sessions/current -> 204 (7 мс)
|
||||
(пусто)
|
||||
$ docker compose --env-file .env exec -T redis redis-cli GET session:<sha256 токена>
|
||||
revoked
|
||||
GET /api/v1/users/me -> 401 (2 мс) # отозванный токен
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "5137ca7dc5464437bdaa45e85bb17e84"}}
|
||||
|
||||
==============================================================================
|
||||
4. Рестарт Redis: кэш пуст, сессии живы (источник истины -- PostgreSQL)
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env restart redis
|
||||
Container messenger-redis Restarting
|
||||
Container messenger-redis Started
|
||||
redis healthy через 5.4 с
|
||||
$ docker compose --env-file .env exec -T redis redis-cli DBSIZE
|
||||
0
|
||||
GET /api/v1/users/me -> 200 (5 мс) # тот же токен
|
||||
{"id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "username": "alice_a3a3d232", "display_name": "alice", "created_at": "2026-10-23T10:18:24.048024Z"}
|
||||
$ docker compose --env-file .env exec -T redis redis-cli EXISTS session:<sha256 токена>
|
||||
1
|
||||
GET /api/v1/users/me -> 401 (4 мс) # отозванный токен после потери кэша всё равно 401 (решает PostgreSQL)
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "aed4a94de8cf4ebfb495e3b35ae51bc3"}}
|
||||
|
||||
==============================================================================
|
||||
5. Redis ОСТАНОВЛЕН: API обходит кэш
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env stop redis
|
||||
Container messenger-redis Stopping
|
||||
Container messenger-redis Stopped
|
||||
GET /health/live -> 200 (1 мс)
|
||||
{"status": "ok"}
|
||||
GET /health/ready -> 200 (2 мс) # Redis не критичен для обязательного пути
|
||||
{"status": "ok"}
|
||||
GET /api/v1/users/me -> 200 (307 мс)
|
||||
{"id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "username": "alice_a3a3d232", "display_name": "alice", "created_at": "2026-10-23T10:18:24.048024Z"}
|
||||
POST /api/v1/chats -> 201 (21 мс)
|
||||
{"id": "515465df-f215-49f0-9548-55d81bf82331", "title": "без Redis", "member_ids": ["2454e675-039f-49b3-92f0-e2e492e0cefc", "5430982a-788d-47f8-a794-b135476578df"], "created_at": "2026-10-23T10:18:33.810751Z"}
|
||||
POST /api/v1/chats/515465df-f215-49f0-9548-55d81bf82331/messages -> 201 (10 мс)
|
||||
{"id": "ebd92a19-9f52-41c2-a883-6ecf0fa880b1", "chat_id": "515465df-f215-49f0-9548-55d81bf82331", "sender_id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "text": "сообщение при остановленном Redis", "created_at": "2026-10-23T10:18:33.830951Z"}
|
||||
GET /api/v1/chats/515465df-f215-49f0-9548-55d81bf82331/messages -> 200 (5 мс)
|
||||
{"items": [{"id": "ebd92a19-9f52-41c2-a883-6ecf0fa880b1", "chat_id": "515465df-f215-49f0-9548-55d81bf82331", "sender_id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "text": "сообщение при остановленном Redis", "created_at": "2026-10-23T10:18:33.830951Z"}], "next_cursor": null}
|
||||
GET /api/v1/users/me -> 401 (2 мс) # без токена -- 401, не доверяем
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "9726e3049265430abcbbf1370d866d0e"}}
|
||||
GET /api/v1/users/me -> 401 (4 мс) # чужой токен -- 401
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "f187d7d2bd65451ba37797de881c940f"}}
|
||||
POST /api/v1/users -> 201 (51 мс) # регистрация
|
||||
{"id": "ff7f3a4f-e69f-465b-a2ae-3a38b9571bc8", "username": "dave_3786d2ec", "display_name": "dave", "created_at": "2026-10-23T10:18:33.890145Z"}
|
||||
POST /api/v1/auth/sessions -> 201 (49 мс) # вход (Basic)
|
||||
{"token": "<скрыт>", "token_type": "Bearer", "expires_at": "2026-10-23T11:18:33.898871Z", "user": {"id": "ff7f3a4f-e69f-465b-a2ae-3a38b9571bc8", "username": "dave_3786d2ec", "display_name": "dave", "created_at": "2026-10-23T10:18:33.890145Z"}}
|
||||
GET /api/v1/users/me -> 200 (3 мс)
|
||||
{"id": "ff7f3a4f-e69f-465b-a2ae-3a38b9571bc8", "username": "dave_3786d2ec", "display_name": "dave", "created_at": "2026-10-23T10:18:33.890145Z"}
|
||||
DELETE /api/v1/auth/sessions/current -> 204 (7 мс) # logout при недоступном Redis
|
||||
(пусто)
|
||||
GET /api/v1/users/me -> 401 (3 мс)
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "afc3e9b8832241068e49c15a5f255647"}}
|
||||
Максимальная задержка запросов без Redis: 307 мс
|
||||
$ docker compose --env-file .env start redis
|
||||
Container messenger-redis Starting
|
||||
Container messenger-redis Started
|
||||
redis healthy через 5.4 с
|
||||
GET /api/v1/users/me -> 200 (21 мс) # кэш снова в работе
|
||||
{"id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "username": "alice_a3a3d232", "display_name": "alice", "created_at": "2026-10-23T10:18:24.048024Z"}
|
||||
GET /api/v1/users/me -> 401 (14 мс)
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "9b50d84c22434a8ea61d0e642afb75d7"}}
|
||||
$ docker compose --env-file .env logs --since 2m api
|
||||
messenger-api | 2026-10-23T10:18:21+0000 INFO listen host=0.0.0.0 port=8080
|
||||
messenger-api | INFO: Started server process [1]
|
||||
messenger-api | INFO: Waiting for application startup.
|
||||
messenger-api | 2026-10-23T10:18:21+0000 INFO config env=lab pool=5+5 ttl=3600s store=postgres cache=redis
|
||||
messenger-api | 2026-10-23T10:18:21+0000 INFO migrations: nothing to apply
|
||||
messenger-api | 2026-10-23T10:18:21+0000 INFO startup: приложение готово
|
||||
messenger-api | INFO: Application startup complete.
|
||||
messenger-api | INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
|
||||
messenger-api | 2026-10-23T10:18:22+0000 INFO request request_id=ab0d003663564a1b9dc29362448eba2a method=GET path=/health/ready status=200 duration_ms=7.1
|
||||
messenger-api | 2026-10-23T10:18:22+0000 INFO request request_id=5ef96f93ebaa48f492ed2cc18ae57cef method=GET path=/api/v1/users/me status=200 duration_ms=15.0
|
||||
messenger-api | 2026-10-23T10:18:22+0000 INFO request request_id=3c763fd0b51641a8b6e78e67b93713dc method=GET path=/api/v1/chats/051a293a-c75d-45f5-b4ab-7e24ef0833f4/messages status=200 duration_ms=8.5
|
||||
messenger-api | 2026-10-23T10:18:22+0000 INFO request request_id=028499cc5fea4ab6806c129125221538 method=GET path=/api/v1/chats status=200 duration_ms=5.5
|
||||
messenger-api | 2026-10-23T10:18:23+0000 INFO request request_id=fcded80bfe3747828ad334eb67bf452a method=GET path=/health/ready status=200 duration_ms=2.1
|
||||
messenger-api | 2026-10-23T10:18:23+0000 INFO request request_id=ce4a44fa17fa419385d393eab8eda558 method=GET path=/health/ready status=200 duration_ms=2.0
|
||||
messenger-api | 2026-10-23T10:18:24+0000 INFO request request_id=a327a13994254a5e8695f8065c0052c7 method=POST path=/api/v1/users status=201 duration_ms=55.9
|
||||
messenger-api | 2026-10-23T10:18:24+0000 INFO request request_id=1bac32dcbdc9426981c93b4b1fc2a6a7 method=POST path=/api/v1/auth/sessions status=201 duration_ms=50.6
|
||||
messenger-api | 2026-10-23T10:18:24+0000 INFO request request_id=2ad87a6b1d714522b6ce473c3d03a88e method=POST path=/api/v1/users status=201 duration_ms=46.3
|
||||
messenger-api | 2026-10-23T10:18:24+0000 INFO request request_id=b6f69c04a1894b06966dce197177dc74 method=POST path=/api/v1/auth/sessions status=201 duration_ms=47.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=0939be01468d46149145707bb6a13e4e method=GET path=/api/v1/users/me status=200 duration_ms=3.4
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=68668e6e03c143d8aba1bc765e46594f method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=061a41bf184b4a28ae09a236a100b954 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=3ac82f390f1e4c9ebf62030403c6d5f3 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=b5d7ef2a5af14a17a409261526158e73 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=60d4a26bdac3438fa1169f6e45eed859 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=0a795eda6f1b43cb83c37b5ca3633d2b method=GET path=/api/v1/users/me status=200 duration_ms=0.7
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=d33c6949fe41473c91ded47999a57451 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=3da894a019194c80b4eb470af8067f9b method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=3d45d5bb28e7433c91bd92fdabcf6529 method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=4e6752620fa24ec1803dd970647f372a method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=bad3a45c841e4f619fb6f0d05847f2cb method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=0afb12feb0b34ef8a29835d7a33655be method=GET path=/api/v1/users/me status=200 duration_ms=1.0
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=f10d8b39b9b844c884e91d230ab6ee93 method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=1d69e3356cac44dbb424492f1b666d5f method=GET path=/api/v1/users/me status=200 duration_ms=1.0
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=b52dcff84fe7411eb185807f66a477db method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=1f87f056fcda4b2d87e277424a596a81 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=7b7c2bbf8a8d49d9be2e163d12c2783a method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=e767c61290b240f190b673bbe0cb8320 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=5a9a796e47a343d699a6d42e604c1a32 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=5b8ef3ca395e4efbbd54c1e7fdd91781 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=f786c6bd84f84722886bf6dfd35d1a32 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=dabde023b7784d77b66993f95c3b0666 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=49c5501d17fd46eb916ce33a0ed8b504 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=6b46168eb0a44611a7ddbbe6138cf5a2 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=3dde34ec48e146d7b5f0110f1d2fbdc1 method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=1f122734d4544a9b8b1dc6f12cad4f87 method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=ba06f9dbf16e4b538f68fc5ee1268f0f method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=75b39d4d183e46878ad7ce0e0946d4fe method=GET path=/api/v1/users/me status=200 duration_ms=0.8
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=344a490d3a37460fa08ea554600cf13d method=GET path=/api/v1/users/me status=200 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=d86193959efb469fa70484723c0479f7 method=GET path=/api/v1/users/me status=200 duration_ms=1.0
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=5c7d4a99cf0d42e290c00843c5c5c277 method=GET path=/api/v1/users/me status=200 duration_ms=1.3
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=01eeb99a98c2496eae093957542f779c method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=33cccf79cdcb4b86a66b8db765943207 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=ccfc557d55cf4205b7010790f41f61e1 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=beb012eb4b4344c6ba47b1c229888c24 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=30a106dab9ad4ad9bde5a9c67dfa0fa8 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=2ef1c83fa84141f7ba9125ee2bd32b94 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=eb54e1442e49409dbe3952b1dc472a9d method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=add208ea268245af868c186f2a464580 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=124ca2404be5494696aae09353d139c3 method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=5b3f9c939709426992d41d96c14d32ee method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=d1cbe63bd9a44638abe624657ba0c203 method=GET path=/api/v1/users/me status=200 duration_ms=1.5
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=945013d1534c4a94a924a12eec335baa method=GET path=/api/v1/users/me status=200 duration_ms=1.5
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=464c092f0f164f9db27d86e840466e2a method=GET path=/api/v1/users/me status=200 duration_ms=1.3
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=becf9277028c4408bbab35fbf3e6fad2 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=4481eecaef30407e85ecf86762337d39 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=e1d34ed15b144d3b9907b64025677d39 method=GET path=/api/v1/users/me status=200 duration_ms=1.2
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=3d43e46e55334ddf91274467d331b167 method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=8817c423a2da48529a4519cbb19791e6 method=GET path=/api/v1/users/me status=200 duration_ms=1.1
|
||||
messenger-api | 2026-10-23T10:18:25+0000 INFO request request_id=705142a4330249bd99beaa84bdbc6127 method=GET path=/health/ready status=200 duration_ms=2.0
|
||||
messenger-api | 2026-10-23T10:18:27+0000 INFO request request_id=f4934e6692bd473fad9c59a9927fa304 method=POST path=/api/v1/users status=201 duration_ms=53.4
|
||||
messenger-api | 2026-10-23T10:18:27+0000 INFO request request_id=335a26c51d784946882f57f5668946e5 method=POST path=/api/v1/auth/sessions status=201 duration_ms=47.8
|
||||
messenger-api | 2026-10-23T10:18:27+0000 INFO request request_id=ea1bddbde1d04083966b5b77278a1618 method=GET path=/api/v1/users/me status=200 duration_ms=3.1
|
||||
messenger-api | 2026-10-23T10:18:27+0000 INFO request request_id=a47b63e1b3214a67974a4c506590b905 method=DELETE path=/api/v1/auth/sessions/current status=204 duration_ms=6.2
|
||||
messenger-api | 2026-10-23T10:18:27+0000 INFO request request_id=5137ca7dc5464437bdaa45e85bb17e84 method=GET path=/api/v1/users/me status=401 duration_ms=0.9
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=05218a878a3044d598f8a5c8ccc17ab6 method=GET path=/api/v1/users/me status=200 duration_ms=3.8
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=aed4a94de8cf4ebfb495e3b35ae51bc3 method=GET path=/api/v1/users/me status=401 duration_ms=2.7
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=dc35c7f0f7da44daa96e7f9995fe8ec7 method=GET path=/health/live status=200 duration_ms=0.5
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=742e776579014925b3426c3e5f28ed1a method=GET path=/health/ready status=200 duration_ms=1.5
|
||||
messenger-api | 2026-10-23T10:18:33+0000 WARNING cache_unavailable type=TimeoutError
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=34d82defd3454b18a6b5e3b17fc31fd8 method=GET path=/api/v1/users/me status=200 duration_ms=306.3
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=41c38a52d56042a8b5346d7fb623d2d3 method=POST path=/api/v1/chats status=201 duration_ms=19.7
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=44445527e20f47ae847911b139196fde method=POST path=/api/v1/chats/515465df-f215-49f0-9548-55d81bf82331/messages status=201 duration_ms=8.9
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=97111a005b89485c8f2abac6c18275a1 method=GET path=/api/v1/chats/515465df-f215-49f0-9548-55d81bf82331/messages status=200 duration_ms=4.4
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=9726e3049265430abcbbf1370d866d0e method=GET path=/api/v1/users/me status=401 duration_ms=0.6
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=f187d7d2bd65451ba37797de881c940f method=GET path=/api/v1/users/me status=401 duration_ms=2.6
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=bd141144a65a4644887fe5fb2b511a27 method=POST path=/api/v1/users status=201 duration_ms=50.0
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=e52d5593aa6b459ca4d49cfc2b185b01 method=POST path=/api/v1/auth/sessions status=201 duration_ms=47.7
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=d0dbee871d0a44e3a8a0eb106e955ce0 method=GET path=/api/v1/users/me status=200 duration_ms=2.7
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=f4ce6d2b27f74affbbc32a88b7712765 method=DELETE path=/api/v1/auth/sessions/current status=204 duration_ms=6.4
|
||||
messenger-api | 2026-10-23T10:18:33+0000 INFO request request_id=afc3e9b8832241068e49c15a5f255647 method=GET path=/api/v1/users/me status=401 duration_ms=2.3
|
||||
messenger-api | 2026-10-23T10:18:36+0000 INFO request request_id=d549e191c0974a69bd6f4bf634ee50bb method=GET path=/health/ready status=200 duration_ms=2.0
|
||||
messenger-api | 2026-10-23T10:18:45+0000 WARNING cache: FLUSHDB after a lost revocation
|
||||
messenger-api | 2026-10-23T10:18:45+0000 INFO request request_id=2620a2039cbf4f4e8cf5879087f13ec4 method=GET path=/api/v1/users/me status=200 duration_ms=18.6
|
||||
messenger-api | 2026-10-23T10:18:45+0000 INFO request request_id=9b50d84c22434a8ea61d0e642afb75d7 method=GET path=/api/v1/users/me status=401 duration_ms=9.8
|
||||
|
||||
==============================================================================
|
||||
6. PostgreSQL ОСТАНОВЛЕН: ограниченная ошибка, никого не пускаем без проверки
|
||||
==============================================================================
|
||||
$ docker compose --env-file .env stop db
|
||||
Container messenger-db Stopping
|
||||
Container messenger-db Stopped
|
||||
GET /health/live -> 200 (1 мс) # процесс жив
|
||||
{"status": "ok"}
|
||||
GET /health/ready -> 503 (912 мс) # обязательная зависимость недоступна
|
||||
{"error": {"code": "unavailable", "message": "База данных недоступна", "request_id": "127dd693633743c2ae7c483fec38293f"}}
|
||||
GET /api/v1/chats -> 503 (6 мс) # данные только в БД
|
||||
{"error": {"code": "unavailable", "message": "Сервис временно недоступен", "request_id": "606963e195294eb1ac31c8195b368194"}}
|
||||
POST /api/v1/chats/515465df-f215-49f0-9548-55d81bf82331/messages -> 503 (6 мс)
|
||||
{"error": {"code": "unavailable", "message": "Сервис временно недоступен", "request_id": "27b4b397069446bca210fda788cc5f6d"}}
|
||||
POST /api/v1/users -> 503 (51 мс)
|
||||
{"error": {"code": "unavailable", "message": "Сервис временно недоступен", "request_id": "72a0730aad794645b2f27e12da18c230"}}
|
||||
GET /api/v1/users/me -> 401 (1 мс) # аноним -- 401
|
||||
{"error": {"code": "unauthorized", "message": "Нет действительной аутентификации", "request_id": "2e09c4aa32f044aebadbb9a58101de2c"}}
|
||||
GET /api/v1/users/me -> 503 (5 мс) # неизвестный токен: проверить нельзя -> 503, не 200
|
||||
{"error": {"code": "unavailable", "message": "Сервис временно недоступен", "request_id": "e8f919b332014c4398f452d6e7787f5e"}}
|
||||
$ docker compose --env-file .env start db
|
||||
Container messenger-db Starting
|
||||
Container messenger-db Started
|
||||
API снова готов через 0.5 с после start db
|
||||
GET /api/v1/chats/515465df-f215-49f0-9548-55d81bf82331/messages -> 200 (16 мс) # тот же токен, те же данные
|
||||
{"items": [{"id": "ebd92a19-9f52-41c2-a883-6ecf0fa880b1", "chat_id": "515465df-f215-49f0-9548-55d81bf82331", "sender_id": "2454e675-039f-49b3-92f0-e2e492e0cefc", "text": "сообщение при остановленном Redis", "created_at": "2026-10-23T10:18:33.830951Z"}], "next_cursor": null}
|
||||
$ docker compose --env-file .env ps
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
messenger-api mtusi-messenger:lab2 "python -m app" api 32 seconds ago Up 26 seconds (healthy) 127.0.0.1:8080->8080/tcp
|
||||
messenger-db postgres:16.6-bookworm "docker-entrypoint.s…" db 32 seconds ago Up Less than a second (health: starting) 127.0.0.1:5433->5432/tcp
|
||||
messenger-redis redis:7.4.1-bookworm "docker-entrypoint.s…" redis 32 seconds ago Up 13 seconds (healthy) 6379/tcp
|
||||
|
||||
==============================================================================
|
||||
ИТОГ
|
||||
==============================================================================
|
||||
ИТОГ: PASS -- Redis кэширует проверку сессий; рестарт/остановка Redis не теряют сессий и не пропускают анонимов; остановка PostgreSQL даёт 503 без деталей и восстанавливается.
|
||||
@@ -0,0 +1,89 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:50
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env exec -T api python -m app.explain
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
PostgreSQL: 16.6 (Debian 16.6-1.pgdg120+1)
|
||||
Сообщений всего: 60005
|
||||
Сообщений в большом чате: 20000
|
||||
Размер таблицы messages: 6784 kB
|
||||
Размер индекса messages_chat_created_idx: 5992 kB
|
||||
|
||||
==============================================================================
|
||||
1. Первая страница (без cursor), запрос приложения
|
||||
==============================================================================
|
||||
SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
|
||||
LIMIT $2::INTEGER
|
||||
-- параметры: b21f9b12-3f7c-5896-bc0d-5c48f78f3576, 51
|
||||
Limit (cost=0.41..12.38 rows=51 width=80) (actual time=0.008..0.022 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_chat_created_idx on messages (cost=0.41..4718.99 rows=20106 width=80) (actual time=0.007..0.018 rows=51 loops=1)
|
||||
Index Cond: (chat_id = 'b21f9b12-3f7c-5896-bc0d-5c48f78f3576'::uuid)
|
||||
Buffers: shared hit=6
|
||||
Planning:
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.073 ms
|
||||
Execution Time: 0.032 ms
|
||||
|
||||
==============================================================================
|
||||
2. Глубокая страница: cursor после 15000-го сообщения (keyset)
|
||||
==============================================================================
|
||||
SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
-- параметры: b21f9b12-3f7c-5896-bc0d-5c48f78f3576, 2026-09-23 10:26:18.547526+00:00, c108c4dd-61dd-4321-8b6c-70b26623adf7, 51
|
||||
Limit (cost=0.41..38.34 rows=51 width=80) (actual time=0.009..0.022 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_chat_created_idx on messages (cost=0.41..3712.96 rows=4992 width=80) (actual time=0.008..0.019 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'b21f9b12-3f7c-5896-bc0d-5c48f78f3576'::uuid) AND (ROW(created_at, id) > ROW('2026-09-23 10:26:18.547526+00'::timestamp with time zone, 'c108c4dd-61dd-4321-8b6c-70b26623adf7'::uuid)))
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.052 ms
|
||||
Execution Time: 0.049 ms
|
||||
|
||||
==============================================================================
|
||||
3. Для сравнения: та же страница через OFFSET (так приложение НЕ делает)
|
||||
==============================================================================
|
||||
SELECT * FROM messages WHERE chat_id = $1 ORDER BY created_at, id OFFSET 15000 LIMIT 51
|
||||
-- параметры: b21f9b12-3f7c-5896-bc0d-5c48f78f3576
|
||||
Limit (cost=3072.67..3072.80 rows=51 width=80) (actual time=7.919..7.925 rows=51 loops=1)
|
||||
Buffers: shared hit=848
|
||||
-> Sort (cost=3035.17..3085.44 rows=20106 width=80) (actual time=6.788..7.505 rows=15051 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 3271kB
|
||||
Buffers: shared hit=848
|
||||
-> Seq Scan on messages (cost=0.00..1598.06 rows=20106 width=80) (actual time=0.006..5.029 rows=20000 loops=1)
|
||||
Filter: (chat_id = 'b21f9b12-3f7c-5896-bc0d-5c48f78f3576'::uuid)
|
||||
Rows Removed by Filter: 40005
|
||||
Buffers: shared hit=848
|
||||
Planning Time: 0.035 ms
|
||||
Execution Time: 7.938 ms
|
||||
|
||||
==============================================================================
|
||||
4. Для сравнения: запрос приложения БЕЗ индекса (DROP INDEX в транзакции, затем ROLLBACK)
|
||||
==============================================================================
|
||||
SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
|
||||
FROM messages
|
||||
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3) ORDER BY messages.created_at, messages.id
|
||||
LIMIT $4::INTEGER
|
||||
-- параметры: b21f9b12-3f7c-5896-bc0d-5c48f78f3576, 2026-09-23 10:26:18.547526+00:00, c108c4dd-61dd-4321-8b6c-70b26623adf7, 51
|
||||
Limit (cost=2064.63..2064.76 rows=51 width=80) (actual time=5.644..5.649 rows=51 loops=1)
|
||||
Buffers: shared hit=848
|
||||
-> Sort (cost=2064.63..2077.11 rows=4992 width=80) (actual time=5.643..5.645 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=848
|
||||
-> Seq Scan on messages (cost=0.00..1898.09 rows=4992 width=80) (actual time=3.769..5.197 rows=5000 loops=1)
|
||||
Filter: ((chat_id = 'b21f9b12-3f7c-5896-bc0d-5c48f78f3576'::uuid) AND (ROW(created_at, id) > ROW('2026-09-23 10:26:18.547526+00'::timestamp with time zone, 'c108c4dd-61dd-4321-8b6c-70b26623adf7'::uuid)))
|
||||
Rows Removed by Filter: 55005
|
||||
Buffers: shared hit=848
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.067 ms
|
||||
Execution Time: 5.661 ms
|
||||
|
||||
Индекс messages_chat_created_idx на месте: True
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 2.44 с
|
||||
@@ -0,0 +1,28 @@
|
||||
# Дата (UTC): 2026-10-23 10:18:54
|
||||
# Commit: 65003b6
|
||||
# Команда: docker compose --env-file .env --profile test run --rm tests python -m pytest -v --no-header -p no:cacheprovider student-tests/test_explain.py
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
============================= test session starts ==============================
|
||||
collecting ... collected 2 items
|
||||
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[0] PASSED [ 50%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[9000] PASSED [100%]
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
========================= 2 passed, 1 warning in 0.15s =========================
|
||||
Container messenger-redis Running
|
||||
Container messenger-db Running
|
||||
Container messenger-db Waiting
|
||||
Container messenger-redis Waiting
|
||||
Container messenger-redis Healthy
|
||||
Container messenger-db Healthy
|
||||
Container mtusi-messenger-tests-run-177db5fdb80c Creating
|
||||
Container mtusi-messenger-tests-run-177db5fdb80c Created
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 4.73 с
|
||||
@@ -0,0 +1,19 @@
|
||||
# Дата (UTC): 2026-10-23 10:19:02
|
||||
# Commit: 65003b6
|
||||
# Команда: python3 scripts/check_expiry.py --base-url http://localhost:8081 --ttl 3
|
||||
# ---------------------------------------- вывод ----------------------------------------
|
||||
OK регистрация -> 201
|
||||
OK вход -> 201, expires_at через 2.9 с (TTL=3)
|
||||
OK GET /users/me #1 до истечения -> 200
|
||||
OK GET /users/me #2 до истечения -> 200
|
||||
OK GET /users/me #3 до истечения -> 200
|
||||
OK GET /users/me после TTL+1 с -> 401, WWW-Authenticate: Bearer realm="messenger", code=unauthorized
|
||||
OK новый вход -> 201
|
||||
OK logout -> 204
|
||||
OK GET /users/me после logout -> 401
|
||||
OK повторный logout -> 401
|
||||
OK вход с неверным паролем -> 401, WWW-Authenticate: Basic realm="messenger", charset="UTF-8"
|
||||
PASS: expiry (TTL=3 с), logout и неверный пароль на запущенном API
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Код возврата: 0
|
||||
# Время выполнения: 4.34 с
|
||||
@@ -0,0 +1,44 @@
|
||||
2026-11-01
|
||||
Python 3.12; pinned runtime/test dependencies from requirements files.
|
||||
|
||||
Regression sensitivity: original auth.py and cursor.py, remaining code fixed.
|
||||
FFFFF.FF.....FF...... [100%]
|
||||
=============================== warnings summary ===============================
|
||||
../.venv/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/workspace/scratch/03a740016edf/.venv/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/chats/00000000-0000-0000-0000-000000000002/messages-POST]
|
||||
/workspace/scratch/03a740016edf/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py:63: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
|
||||
await response(scope, receive, sender)
|
||||
Enable tracemalloc to get traceback where the object was allocated.
|
||||
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
=========================== short test summary info ============================
|
||||
FAILED unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/users/me-GET]
|
||||
FAILED unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/chats/00000000-0000-0000-0000-000000000002/messages-POST]
|
||||
FAILED unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/auth/sessions/current-DELETE]
|
||||
FAILED unit-tests/test_mr_regressions.py::test_valid_cache_hit_checks_session_without_loading_user
|
||||
FAILED unit-tests/test_mr_regressions.py::test_database_failure_on_positive_cache_hit_is_503
|
||||
FAILED unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-253402300800000000]
|
||||
FAILED unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1000000000000000000000000000000]
|
||||
FAILED unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-253402300800000000]
|
||||
FAILED unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1000000000000000000000000000000]
|
||||
9 failed, 12 passed, 2 warnings in 0.77s
|
||||
|
||||
Fixed implementation:
|
||||
..................... [100%]
|
||||
=============================== warnings summary ===============================
|
||||
../.venv/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/workspace/scratch/03a740016edf/.venv/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
21 passed, 1 warning in 0.82s
|
||||
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
|
||||
Integration suite NOT RUN: Docker/PostgreSQL/Redis unavailable.
|
||||
New integration cases are in student-tests/test_cache.py and test_pagination.py.
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"at_utc": "2026-11-02T14:27:32.969212+00:00",
|
||||
"platform": "Windows-10-10.0.19045-SP0",
|
||||
"cpu_count": 16,
|
||||
"python": "3.11.9",
|
||||
"duration": 30.0,
|
||||
"workload": "2 closed-loop clients, POST+GET; uncertain POST retried with same key/body"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
$ docker version
|
||||
Client:
|
||||
Version: 26.1.4
|
||||
API version: 1.45
|
||||
Go version: go1.21.11
|
||||
Git commit: 5650f9b
|
||||
Built: Wed Jun 5 11:29:54 2024
|
||||
OS/Arch: windows/amd64
|
||||
Context: desktop-linux
|
||||
|
||||
Server: Docker Desktop 4.31.1 (153621)
|
||||
Engine:
|
||||
Version: 26.1.4
|
||||
API version: 1.45 (minimum version 1.24)
|
||||
Go version: go1.21.11
|
||||
Git commit: de5c9cf
|
||||
Built: Wed Jun 5 11:29:22 2024
|
||||
OS/Arch: linux/amd64
|
||||
Experimental: false
|
||||
containerd:
|
||||
Version: 1.6.33
|
||||
GitCommit: d2d58213f83a351ca8f528a95fbd145f5654e957
|
||||
runc:
|
||||
Version: 1.1.12
|
||||
GitCommit: v1.1.12-0-g51d5e94
|
||||
docker-init:
|
||||
Version: 0.19.0
|
||||
GitCommit: de40ad0
|
||||
|
||||
exit_code=0; elapsed_seconds=0.109
|
||||
@@ -0,0 +1,3 @@
|
||||
$ docker compose --env-file .env config --quiet
|
||||
|
||||
exit_code=0; elapsed_seconds=0.297
|
||||
@@ -0,0 +1,8 @@
|
||||
$ docker inspect --format {{.Name}} cpus={{.HostConfig.NanoCpus}} memory={{.HostConfig.Memory}} ports={{json .HostConfig.PortBindings}} ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235 4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0 765a7b20a31ea3ea8cfd024fe9d4a938c46f4d23d743e4db310b354d357014d8 5675a02e89826f64b25026269d5dc9177a7172ce4922722875c4d986e8423125 1b3ad58c1dd2bec01048e78af86e3c9812172df3c4189eab27352b11a950673d
|
||||
/mtusi-messenger-lab3-api-a-1 cpus=500000000 memory=268435456 ports={}
|
||||
/mtusi-messenger-lab3-api-b-1 cpus=500000000 memory=268435456 ports={}
|
||||
/mtusi-messenger-lab3-db-1 cpus=1000000000 memory=536870912 ports={}
|
||||
/mtusi-messenger-lab3-nginx-1 cpus=250000000 memory=100663296 ports={"8080/tcp":[{"HostIp":"127.0.0.1","HostPort":"8080"}]}
|
||||
/mtusi-messenger-lab3-redis-1 cpus=250000000 memory=134217728 ports={}
|
||||
|
||||
exit_code=0; elapsed_seconds=0.109
|
||||
@@ -0,0 +1,8 @@
|
||||
$ docker compose --env-file .env ps -q
|
||||
ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235
|
||||
4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0
|
||||
765a7b20a31ea3ea8cfd024fe9d4a938c46f4d23d743e4db310b354d357014d8
|
||||
5675a02e89826f64b25026269d5dc9177a7172ce4922722875c4d986e8423125
|
||||
1b3ad58c1dd2bec01048e78af86e3c9812172df3c4189eab27352b11a950673d
|
||||
|
||||
exit_code=0; elapsed_seconds=0.344
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 48570,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.63201658Z",
|
||||
"status": 200,
|
||||
"instance_id": "1b38655b9a21447494973eb99d5ea039"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 48587,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.715403308Z",
|
||||
"status": 200,
|
||||
"instance_id": "128e6b095f444dffa33214cd3cd33184"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
$ C:\Users\ira\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe tests/smoke.py --base-url http://localhost:8080
|
||||
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
exit_code=0; elapsed_seconds=67.125
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"parallel_requests": 12,
|
||||
"unique_message_ids": 1,
|
||||
"history_rows": 1,
|
||||
"instances": [
|
||||
"128e6b095f444dffa33214cd3cd33184",
|
||||
"1b38655b9a21447494973eb99d5ea039"
|
||||
],
|
||||
"conflict_status": 409
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"mode": "stop",
|
||||
"service": "api-a",
|
||||
"target_instance": "1b38655b9a21447494973eb99d5ea039",
|
||||
"observed_with_one_session": [
|
||||
"128e6b095f444dffa33214cd3cd33184",
|
||||
"1b38655b9a21447494973eb99d5ea039"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 48570,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.63201658Z",
|
||||
"status": 200,
|
||||
"instance_id": "1b38655b9a21447494973eb99d5ea039"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 48587,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.715403308Z",
|
||||
"status": 200,
|
||||
"instance_id": "128e6b095f444dffa33214cd3cd33184"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 0,
|
||||
"state": "exited",
|
||||
"started_at": "2026-11-02T14:13:58.63201658Z"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 48587,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.715403308Z",
|
||||
"status": 200,
|
||||
"instance_id": "128e6b095f444dffa33214cd3cd33184"
|
||||
}
|
||||
],
|
||||
"action": "{\"stopped_service\": \"api-a\", \"instance_id\": \"1b38655b9a21447494973eb99d5ea039\"}\n",
|
||||
"action_seconds": 4.125,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 32.953,
|
||||
"attempts": 32,
|
||||
"successes": 32,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.971,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2125.0,
|
||||
"p99": 2141.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 31.953,
|
||||
"attempts": 30,
|
||||
"successes": 30,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.939,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2125.0,
|
||||
"p99": 2141.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 17,
|
||||
"history_messages": 17,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 9.36,
|
||||
"write": {
|
||||
"elapsed_seconds": 32.953,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2047.0,
|
||||
"p95": 2141.0,
|
||||
"p99": 2141.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 7.297,
|
||||
"read": {
|
||||
"elapsed_seconds": 32.953,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2047.0,
|
||||
"p99": 2047.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"mode": "stop",
|
||||
"service": "api-b",
|
||||
"target_instance": "128e6b095f444dffa33214cd3cd33184",
|
||||
"observed_with_one_session": [
|
||||
"128e6b095f444dffa33214cd3cd33184",
|
||||
"816f731929a14492b542719bbfcff984"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 90437,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:30:54.841666808Z",
|
||||
"status": 200,
|
||||
"instance_id": "816f731929a14492b542719bbfcff984"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 48587,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.715403308Z",
|
||||
"status": 200,
|
||||
"instance_id": "128e6b095f444dffa33214cd3cd33184"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 90437,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:30:54.841666808Z",
|
||||
"status": 200,
|
||||
"instance_id": "816f731929a14492b542719bbfcff984"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 0,
|
||||
"state": "exited",
|
||||
"started_at": "2026-11-02T14:13:58.715403308Z"
|
||||
}
|
||||
],
|
||||
"action": "{\"stopped_service\": \"api-b\", \"instance_id\": \"128e6b095f444dffa33214cd3cd33184\"}\n",
|
||||
"action_seconds": 3.985,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 32.907,
|
||||
"attempts": 32,
|
||||
"successes": 32,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.972,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2125.0,
|
||||
"p99": 2125.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 31.907,
|
||||
"attempts": 30,
|
||||
"successes": 30,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.94,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2125.0,
|
||||
"p99": 2125.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 17,
|
||||
"history_messages": 17,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 9.36,
|
||||
"write": {
|
||||
"elapsed_seconds": 32.907,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2047.0,
|
||||
"p95": 2125.0,
|
||||
"p99": 2125.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 7.297,
|
||||
"read": {
|
||||
"elapsed_seconds": 32.907,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2047.0,
|
||||
"p99": 2047.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
$ C:\Users\ira\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url http://localhost:8080
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 7, "failed_attempts": 0, "first_recovery_seconds": 6.328}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
exit_code=0; elapsed_seconds=121.422
|
||||
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"mode": "replace",
|
||||
"service": "api-a",
|
||||
"target_instance": "9f683cfbf70746f898efeb1ef3da5512",
|
||||
"observed_with_one_session": [
|
||||
"9f683cfbf70746f898efeb1ef3da5512",
|
||||
"b7542c30b09c43bf941aaade921e6640"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 98867,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:34:24.451317583Z",
|
||||
"status": 200,
|
||||
"instance_id": "9f683cfbf70746f898efeb1ef3da5512"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 93836,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:32:20.000834613Z",
|
||||
"status": 200,
|
||||
"instance_id": "b7542c30b09c43bf941aaade921e6640"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ea9d5889a8f0c6ff908a726f8fbe787eef209d33c30b1195090f822fb742bdbb",
|
||||
"pid": 1674,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:35:20.182460357Z",
|
||||
"status": 200,
|
||||
"instance_id": "8e1cb6e2bcd143fea7f8b677409738f5"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 93836,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:32:20.000834613Z",
|
||||
"status": 200,
|
||||
"instance_id": "b7542c30b09c43bf941aaade921e6640"
|
||||
}
|
||||
],
|
||||
"action": {
|
||||
"service": "api-a",
|
||||
"before": "9f683cfbf70746f898efeb1ef3da5512",
|
||||
"after": "8e1cb6e2bcd143fea7f8b677409738f5"
|
||||
},
|
||||
"action_seconds": 18.407,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 32.875,
|
||||
"attempts": 32,
|
||||
"successes": 32,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.973,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2093.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 31.875,
|
||||
"attempts": 30,
|
||||
"successes": 30,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.941,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2093.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 17,
|
||||
"history_messages": 17,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 21.547,
|
||||
"write": {
|
||||
"elapsed_seconds": 32.875,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.487,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2046.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 23.578,
|
||||
"read": {
|
||||
"elapsed_seconds": 32.875,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.487,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2093.0,
|
||||
"p99": 2093.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"mode": "replace",
|
||||
"service": "api-b",
|
||||
"target_instance": "b7542c30b09c43bf941aaade921e6640",
|
||||
"observed_with_one_session": [
|
||||
"8e1cb6e2bcd143fea7f8b677409738f5",
|
||||
"b7542c30b09c43bf941aaade921e6640"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ea9d5889a8f0c6ff908a726f8fbe787eef209d33c30b1195090f822fb742bdbb",
|
||||
"pid": 1674,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:35:20.182460357Z",
|
||||
"status": 200,
|
||||
"instance_id": "8e1cb6e2bcd143fea7f8b677409738f5"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 93836,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:32:20.000834613Z",
|
||||
"status": 200,
|
||||
"instance_id": "b7542c30b09c43bf941aaade921e6640"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ea9d5889a8f0c6ff908a726f8fbe787eef209d33c30b1195090f822fb742bdbb",
|
||||
"pid": 1674,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:35:20.182460357Z",
|
||||
"status": 200,
|
||||
"instance_id": "8e1cb6e2bcd143fea7f8b677409738f5"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "08d347efa257b234f70797becec6fa40110201dc05ca6ac4ef27ade4c8af2fec",
|
||||
"pid": 5532,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:36:45.127161791Z",
|
||||
"status": 200,
|
||||
"instance_id": "8cc241fbc3c64938bf061ae1cb6bf86a"
|
||||
}
|
||||
],
|
||||
"action": {
|
||||
"service": "api-b",
|
||||
"before": "b7542c30b09c43bf941aaade921e6640",
|
||||
"after": "8cc241fbc3c64938bf061ae1cb6bf86a"
|
||||
},
|
||||
"action_seconds": 18.453,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 32.906,
|
||||
"attempts": 32,
|
||||
"successes": 32,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.972,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2109.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 31.906,
|
||||
"attempts": 30,
|
||||
"successes": 30,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.94,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2109.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 17,
|
||||
"history_messages": 17,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 21.672,
|
||||
"write": {
|
||||
"elapsed_seconds": 32.906,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 23.688,
|
||||
"read": {
|
||||
"elapsed_seconds": 32.906,
|
||||
"attempts": 16,
|
||||
"successes": 16,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2109.0,
|
||||
"p99": 2109.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
$ C:\Users\ira\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe tests/resilience.py --mode persistence --action-script scripts/restart.sh --base-url http://localhost: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.
|
||||
|
||||
exit_code=0; elapsed_seconds=42.250
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "2fd96ffc2d8d68c26da16bf09245a0172173d8bd94ec6a20cd746efa7b080bda",
|
||||
"pid": 8131,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:37:40.580307643Z",
|
||||
"status": 200,
|
||||
"instance_id": "1fe93f99807c40ad873ed0e55339418a"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "876768b9146eb58906607265215fa30d8e29a58b40b91d701982c0ce0f470d90",
|
||||
"pid": 8121,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:37:40.480238226Z",
|
||||
"status": 200,
|
||||
"instance_id": "2fb27071a2b0448880987581ff45a8bf"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,47 @@
|
||||
$ docker compose --env-file .env exec -T nginx nginx -T -c /opt/lb/nginx.conf
|
||||
# configuration file /opt/lb/nginx.conf:
|
||||
worker_processes 1;
|
||||
pid /tmp/nginx.pid;
|
||||
error_log /dev/stderr warn;
|
||||
worker_shutdown_timeout 5s;
|
||||
events { worker_connections 1024; }
|
||||
http {
|
||||
log_format upstream '$request_method $uri status=$status upstream=$upstream_addr upstream_status=$upstream_status time=$request_time';
|
||||
access_log /dev/stdout upstream;
|
||||
resolver 127.0.0.11 valid=1s ipv6=off;
|
||||
resolver_timeout 1s;
|
||||
include /tmp/backends.conf;
|
||||
server {
|
||||
listen 8080;
|
||||
server_tokens off;
|
||||
client_max_body_size 256k;
|
||||
client_header_timeout 5s;
|
||||
client_body_timeout 5s;
|
||||
keepalive_timeout 2s;
|
||||
location / {
|
||||
proxy_pass http://api_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_read_timeout 8s;
|
||||
proxy_send_timeout 8s;
|
||||
proxy_next_upstream error timeout http_502 http_503 http_504;
|
||||
proxy_next_upstream_tries 2;
|
||||
proxy_next_upstream_timeout 9s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# configuration file /tmp/backends.conf:
|
||||
upstream api_backend {
|
||||
zone api_backend 64k;
|
||||
server api-a:8080 resolve max_fails=1 fail_timeout=2s;
|
||||
server api-b:8080 resolve max_fails=1 fail_timeout=2s;
|
||||
}
|
||||
|
||||
nginx: the configuration file /opt/lb/nginx.conf syntax is ok
|
||||
nginx: configuration file /opt/lb/nginx.conf test is successful
|
||||
|
||||
exit_code=0; elapsed_seconds=0.359
|
||||
@@ -0,0 +1,303 @@
|
||||
$ docker compose --env-file .env --profile test run --rm --build tests
|
||||
#0 building with "desktop-linux" instance using docker driver
|
||||
|
||||
#1 [tests internal] load build definition from Dockerfile
|
||||
#1 transferring dockerfile: 955B done
|
||||
#1 DONE 0.0s
|
||||
|
||||
#2 [tests internal] load metadata for docker.io/library/python:3.12.8-slim-bookworm
|
||||
#2 ...
|
||||
|
||||
#3 [tests auth] library/python:pull token for registry-1.docker.io
|
||||
#3 DONE 0.0s
|
||||
|
||||
#2 [tests internal] load metadata for docker.io/library/python:3.12.8-slim-bookworm
|
||||
#2 DONE 1.4s
|
||||
|
||||
#4 [tests internal] load .dockerignore
|
||||
#4 transferring context: 196B done
|
||||
#4 DONE 0.0s
|
||||
|
||||
#5 [tests base 1/6] FROM docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
|
||||
#5 DONE 0.0s
|
||||
|
||||
#6 [tests internal] load build context
|
||||
#6 transferring context: 2.00kB done
|
||||
#6 DONE 0.0s
|
||||
|
||||
#7 [tests test 3/5] COPY pytest.ini ./
|
||||
#7 CACHED
|
||||
|
||||
#8 [tests test 2/5] RUN pip install -r requirements-test.txt
|
||||
#8 CACHED
|
||||
|
||||
#9 [tests base 2/6] RUN groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --no-create-home --shell /usr/sbin/nologin app
|
||||
#9 CACHED
|
||||
|
||||
#10 [tests base 5/6] RUN pip install -r requirements.txt
|
||||
#10 CACHED
|
||||
|
||||
#11 [tests test 4/5] COPY student-tests ./student-tests
|
||||
#11 CACHED
|
||||
|
||||
#12 [tests base 4/6] COPY requirements.txt ./
|
||||
#12 CACHED
|
||||
|
||||
#13 [tests test 1/5] COPY requirements-test.txt ./
|
||||
#13 CACHED
|
||||
|
||||
#14 [tests base 6/6] COPY app ./app
|
||||
#14 CACHED
|
||||
|
||||
#15 [tests base 3/6] WORKDIR /srv
|
||||
#15 CACHED
|
||||
|
||||
#16 [tests test 5/5] COPY unit-tests ./unit-tests
|
||||
#16 CACHED
|
||||
|
||||
#17 [tests] exporting to image
|
||||
#17 exporting layers done
|
||||
#17 writing image sha256:c4492757aa5070ae7b09009339bfa52d41b2ef1a39beb1d7dde355a0c2fa257e done
|
||||
#17 naming to docker.io/library/mtusi-messenger:lab3-test done
|
||||
#17 DONE 0.0s
|
||||
============================= test session starts ==============================
|
||||
collecting ... collected 226 items
|
||||
|
||||
student-tests/test_auth.py::test_register_returns_user_without_secrets PASSED [ 0%]
|
||||
student-tests/test_auth.py::test_register_password_rules[None] PASSED [ 0%]
|
||||
student-tests/test_auth.py::test_register_password_rules[] PASSED [ 1%]
|
||||
student-tests/test_auth.py::test_register_password_rules[short] PASSED [ 1%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaa] PASSED [ 2%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 2%]
|
||||
student-tests/test_auth.py::test_register_password_rules[123456789012] PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_register_password_rules[\u043f\u0430\u0440\u043e\u043b\u044c] PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_register_password_border_lengths PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_login_success_shape PASSED [ 4%]
|
||||
student-tests/test_auth.py::test_each_login_gives_new_token PASSED [ 4%]
|
||||
student-tests/test_auth.py::test_wrong_password_and_unknown_user_look_the_same PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic] PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic !!!not-base64!!!] PASSED [ 6%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic bm9jb2xvbg==] PASSED [ 6%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic 0LjQvNGPOnBhc3N3b3JkLTEyMzQ1Ng==] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic dXNlcjr//i1iYWQtdXRmOA==] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Bearer abc] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[] PASSED [ 8%]
|
||||
student-tests/test_auth.py::test_login_without_header_is_401 PASSED [ 8%]
|
||||
student-tests/test_auth.py::test_password_with_colon_and_unicode_works PASSED [ 9%]
|
||||
student-tests/test_auth.py::test_bearer_token_gives_access PASSED [ 9%]
|
||||
student-tests/test_auth.py::test_business_endpoint_rejects_basic PASSED [ 10%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[] PASSED [ 10%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer short] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Token abc] PASSED [ 12%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[bearer] PASSED [ 12%]
|
||||
student-tests/test_auth.py::test_x_user_id_alone_gives_no_access PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_x_user_id_does_not_change_owner_of_session PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_logout_revokes_token_and_repeat_is_401 PASSED [ 14%]
|
||||
student-tests/test_auth.py::test_logout_without_token_is_401 PASSED [ 14%]
|
||||
student-tests/test_auth.py::test_logout_revokes_only_current_session PASSED [ 15%]
|
||||
student-tests/test_auth.py::test_session_lives_longer_than_300_seconds PASSED [ 15%]
|
||||
student-tests/test_cache.py::test_user_profile_is_served_from_cache_with_bounded_ttl PASSED [ 15%]
|
||||
student-tests/test_cache.py::test_cache_never_stores_raw_tokens_or_passwords PASSED [ 16%]
|
||||
student-tests/test_cache.py::test_logout_revokes_cached_session PASSED [ 16%]
|
||||
student-tests/test_cache.py::test_late_cache_fill_cannot_resurrect_revoked_session PASSED [ 17%]
|
||||
student-tests/test_cache.py::test_flushed_cache_loses_nothing PASSED [ 17%]
|
||||
student-tests/test_cache.py::test_cache_does_not_extend_short_session PASSED [ 18%]
|
||||
student-tests/test_cache.py::test_staleness_after_out_of_band_delete_is_bounded_by_cache_ttl PASSED [ 18%]
|
||||
student-tests/test_cache.py::test_redis_down_requests_bypass_cache_and_stay_fast PASSED [ 19%]
|
||||
student-tests/test_cache.py::test_redis_down_never_trusts_anonymous_or_unknown_tokens PASSED [ 19%]
|
||||
student-tests/test_cache.py::test_revocation_lost_while_redis_down_is_flushed_on_recovery PASSED [ 19%]
|
||||
student-tests/test_cache.py::test_without_cache_url_cache_is_off PASSED [ 20%]
|
||||
student-tests/test_cache.py::test_lost_revocation_survives_api_restart[False] PASSED [ 20%]
|
||||
student-tests/test_cache.py::test_lost_revocation_survives_api_restart[True] PASSED [ 21%]
|
||||
student-tests/test_cache.py::test_cached_session_deleted_in_database_is_rejected_immediately PASSED [ 21%]
|
||||
student-tests/test_concurrency.py::test_100_messages_from_10_clients_in_parallel PASSED [ 22%]
|
||||
student-tests/test_concurrency.py::test_parallel_chat_creation_and_reading PASSED [ 22%]
|
||||
student-tests/test_contract_basics.py::test_health_endpoints PASSED [ 23%]
|
||||
student-tests/test_contract_basics.py::test_every_response_has_unique_request_id PASSED [ 23%]
|
||||
student-tests/test_contract_basics.py::test_unknown_path_is_404_in_common_format PASSED [ 23%]
|
||||
student-tests/test_contract_basics.py::test_trailing_slash_is_not_redirected PASSED [ 24%]
|
||||
student-tests/test_contract_basics.py::test_wrong_method_is_405_in_common_format PASSED [ 24%]
|
||||
student-tests/test_contract_basics.py::test_two_users_one_chat_two_messages PASSED [ 25%]
|
||||
student-tests/test_contract_basics.py::test_chat_response_shape PASSED [ 25%]
|
||||
student-tests/test_contract_basics.py::test_unexpected_exception_gives_500_without_details PASSED [ 26%]
|
||||
student-tests/test_contract_basics.py::test_logs_have_requests_but_no_secrets PASSED [ 26%]
|
||||
student-tests/test_database.py::test_password_is_stored_as_scrypt_hash_not_plaintext PASSED [ 26%]
|
||||
student-tests/test_database.py::test_same_password_gives_different_hashes PASSED [ 27%]
|
||||
student-tests/test_database.py::test_session_table_keeps_token_hash_not_token PASSED [ 27%]
|
||||
student-tests/test_database.py::test_message_is_really_in_the_database PASSED [ 28%]
|
||||
student-tests/test_database.py::test_migrations_can_run_again_without_duplicating_anything PASSED [ 28%]
|
||||
student-tests/test_database.py::test_expected_tables_and_indexes_exist PASSED [ 29%]
|
||||
student-tests/test_database.py::test_primary_and_foreign_keys_are_declared PASSED [ 29%]
|
||||
student-tests/test_database.py::test_database_itself_rejects_bad_rows PASSED [ 30%]
|
||||
student-tests/test_database.py::test_chat_creation_is_atomic PASSED [ 30%]
|
||||
student-tests/test_database.py::test_successful_chat_has_all_members_in_database PASSED [ 30%]
|
||||
student-tests/test_db_failure.py::test_database_down_gives_503_and_never_trusts_anyone PASSED [ 31%]
|
||||
student-tests/test_db_failure.py::test_database_down_with_cache_up_still_needs_database_for_data PASSED [ 31%]
|
||||
student-tests/test_duplicate_username.py::test_second_registration_with_same_username_is_409 PASSED [ 32%]
|
||||
student-tests/test_duplicate_username.py::test_duplicate_does_not_replace_original_user PASSED [ 32%]
|
||||
student-tests/test_duplicate_username.py::test_username_is_case_sensitive_lowercase_only PASSED [ 33%]
|
||||
student-tests/test_duplicate_username.py::test_parallel_registration_of_same_username_creates_exactly_one PASSED [ 33%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[] PASSED [ 34%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ] PASSED [ 34%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ] PASSED [ 34%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\n] PASSED [ 35%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\t \n] PASSED [ 35%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\xa0] PASSED [ 36%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\u2003] PASSED [ 36%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body0] PASSED [ 37%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body1] PASSED [ 37%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body2] PASSED [ 38%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body3] PASSED [ 38%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body4] PASSED [ 38%]
|
||||
student-tests/test_empty_message.py::test_text_length_is_counted_in_characters PASSED [ 39%]
|
||||
student-tests/test_empty_message.py::test_nul_character_is_400_not_500 PASSED [ 39%]
|
||||
student-tests/test_empty_message.py::test_unicode_survives_the_database PASSED [ 40%]
|
||||
student-tests/test_empty_message.py::test_message_has_correct_fields PASSED [ 40%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[0] PASSED [ 41%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[9000] PASSED [ 41%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_chat PASSED [ 42%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_history PASSED [ 42%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_write PASSED [ 42%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_gets_404_even_with_bad_body PASSED [ 43%]
|
||||
student-tests/test_foreign_chat.py::test_unknown_chat_looks_the_same_as_foreign PASSED [ 43%]
|
||||
student-tests/test_foreign_chat.py::test_chat_list_shows_only_own_chats PASSED [ 44%]
|
||||
student-tests/test_foreign_chat.py::test_bad_chat_id_is_400 PASSED [ 44%]
|
||||
student-tests/test_foreign_chat.py::test_no_token_is_401_everywhere PASSED [ 45%]
|
||||
student-tests/test_foreign_chat.py::test_401_comes_before_404 PASSED [ 45%]
|
||||
student-tests/test_foreign_chat.py::test_member_can_read_and_write PASSED [ 46%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[None] PASSED [ 46%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[] PASSED [ 46%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a b] PASSED [ 47%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a?b] PASSED [ 47%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 48%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a,b] PASSED [ 48%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a/b] PASSED [ 49%]
|
||||
student-tests/test_idempotency.py::test_duplicate_headers_are_invalid PASSED [ 49%]
|
||||
student-tests/test_idempotency.py::test_replay_and_conflict_preserve_original_result PASSED [ 50%]
|
||||
student-tests/test_idempotency.py::test_parallel_same_key_across_two_applications PASSED [ 50%]
|
||||
student-tests/test_idempotency.py::test_key_scope_includes_user_and_chat PASSED [ 50%]
|
||||
student-tests/test_idempotency.py::test_expired_result_allows_new_message PASSED [ 51%]
|
||||
student-tests/test_idempotency.py::test_failure_between_message_and_result_rolls_back PASSED [ 51%]
|
||||
student-tests/test_idempotency.py::test_committed_but_lost_response_is_safe_to_retry PASSED [ 52%]
|
||||
student-tests/test_idempotency.py::test_replay_rechecks_session_and_chat_access PASSED [ 52%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{] PASSED [ 53%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[not json at all] PASSED [ 53%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[] PASSED [ 53%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": "abc",}] PASSED [ 54%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[\xff\xfe\x00] PASSED [ 54%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": NaN}] PASSED [ 55%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[["username"]] PASSED [ 55%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json["text"] PASSED [ 56%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[null] PASSED [ 56%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes0] PASSED [ 57%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes1] PASSED [ 57%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes2] PASSED [ 57%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes3] PASSED [ 58%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes4] PASSED [ 58%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes5] PASSED [ 59%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes6] PASSED [ 59%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes7] PASSED [ 60%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes8] PASSED [ 60%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes9] PASSED [ 61%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes10] PASSED [ 61%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes11] PASSED [ 61%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes12] PASSED [ 62%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes13] PASSED [ 62%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes14] PASSED [ 63%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes15] PASSED [ 63%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes16] PASSED [ 64%]
|
||||
student-tests/test_invalid_json.py::test_border_values_are_accepted PASSED [ 64%]
|
||||
student-tests/test_invalid_json.py::test_lone_surrogate_is_400_not_500 PASSED [ 65%]
|
||||
student-tests/test_invalid_json.py::test_wrong_or_missing_content_type_is_415 PASSED [ 65%]
|
||||
student-tests/test_invalid_json.py::test_huge_body_is_413 PASSED [ 65%]
|
||||
student-tests/test_invalid_json.py::test_broken_json_in_message_and_chat PASSED [ 66%]
|
||||
student-tests/test_invalid_json.py::test_sender_id_in_message_is_rejected PASSED [ 66%]
|
||||
student-tests/test_invalid_json.py::test_chat_body_validation PASSED [ 67%]
|
||||
student-tests/test_pagination.py::test_walk_25_messages_by_7 PASSED [ 67%]
|
||||
student-tests/test_pagination.py::test_exact_multiple_has_no_empty_extra_page PASSED [ 68%]
|
||||
student-tests/test_pagination.py::test_limit_one_walks_everything PASSED [ 68%]
|
||||
student-tests/test_pagination.py::test_default_limit_is_50_and_max_is_100 PASSED [ 69%]
|
||||
student-tests/test_pagination.py::test_empty_history PASSED [ 69%]
|
||||
student-tests/test_pagination.py::test_limit_can_change_between_pages PASSED [ 69%]
|
||||
student-tests/test_pagination.py::test_messages_sent_during_walk_appear_at_the_end PASSED [ 70%]
|
||||
student-tests/test_pagination.py::test_created_at_is_increasing_and_utc PASSED [ 70%]
|
||||
student-tests/test_pagination.py::test_bad_limit_values PASSED [ 71%]
|
||||
student-tests/test_pagination.py::test_garbage_cursor_is_400 PASSED [ 71%]
|
||||
student-tests/test_pagination.py::test_cursor_from_another_chat_is_400 PASSED [ 72%]
|
||||
student-tests/test_pagination.py::test_chat_list_pagination PASSED [ 72%]
|
||||
student-tests/test_pagination.py::test_chat_list_cursor_cannot_be_used_for_messages PASSED [ 73%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages--1] PASSED [ 73%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1000000000000000000000000000000] PASSED [ 73%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-253402300800000000] PASSED [ 74%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-True] PASSED [ 74%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1.5] PASSED [ 75%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1] PASSED [ 75%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-None] PASSED [ 76%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats--1] PASSED [ 76%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1000000000000000000000000000000] PASSED [ 76%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-253402300800000000] PASSED [ 77%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-True] PASSED [ 77%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1.5] PASSED [ 78%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1] PASSED [ 78%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-None] PASSED [ 79%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[messages-0] PASSED [ 79%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[messages-253402300799999999] PASSED [ 80%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[chats-0] PASSED [ 80%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[chats-253402300799999999] PASSED [ 80%]
|
||||
student-tests/test_session_expiry.py::test_session_expires_after_ttl PASSED [ 81%]
|
||||
student-tests/test_session_expiry.py::test_expired_sessions_are_cleaned_on_next_login PASSED [ 81%]
|
||||
student-tests/test_session_expiry.py::test_short_ttl_from_environment_variable PASSED [ 82%]
|
||||
student-tests/test_transactions.py::test_failure_after_chat_insert_rolls_back_whole_operation PASSED [ 82%]
|
||||
student-tests/test_transactions.py::test_pool_is_bounded_by_settings PASSED [ 83%]
|
||||
student-tests/test_transactions.py::test_exhausted_pool_gives_fast_503 PASSED [ 83%]
|
||||
unit-tests/test_message_transaction.py::test_conflicting_replay_rolls_back_without_commit PASSED [ 84%]
|
||||
unit-tests/test_message_transaction.py::test_result_insert_failure_never_commits_message PASSED [ 84%]
|
||||
unit-tests/test_message_transaction.py::test_replay_returns_original_message_and_releases_transaction PASSED [ 84%]
|
||||
unit-tests/test_message_transaction.py::test_failed_commit_rolls_back_and_propagates_error PASSED [ 85%]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/users/me-GET] PASSED [ 85%]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/chats/00000000-0000-0000-0000-000000000002/messages-POST] PASSED [ 86%]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/auth/sessions/current-DELETE] PASSED [ 86%]
|
||||
unit-tests/test_mr_regressions.py::test_valid_cache_hit_checks_session_without_loading_user PASSED [ 87%]
|
||||
unit-tests/test_mr_regressions.py::test_database_failure_on_positive_cache_hit_is_503 PASSED [ 87%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages--1] PASSED [ 88%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-253402300800000000] PASSED [ 88%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1000000000000000000000000000000] PASSED [ 88%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-True] PASSED [ 89%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1.5] PASSED [ 89%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1] PASSED [ 90%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-None] PASSED [ 90%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats--1] PASSED [ 91%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-253402300800000000] PASSED [ 91%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1000000000000000000000000000000] PASSED [ 92%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-True] PASSED [ 92%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1.5] PASSED [ 92%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1] PASSED [ 93%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-None] PASSED [ 93%]
|
||||
unit-tests/test_mr_regressions.py::test_timestamp_boundaries_roundtrip[0] PASSED [ 94%]
|
||||
unit-tests/test_mr_regressions.py::test_timestamp_boundaries_roundtrip[253402300799999999] PASSED [ 94%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[None] PASSED [ 95%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[] PASSED [ 95%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[bad key] PASSED [ 96%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 96%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[a?b] PASSED [ 96%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[a,b] PASSED [ 97%]
|
||||
unit-tests/test_mr_regressions.py::test_message_normalization_and_conflict PASSED [ 97%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/health/live] PASSED [ 98%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/missing] PASSED [ 98%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/api/v1/users/me] PASSED [ 99%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_alias_changes_between_applications PASSED [ 99%]
|
||||
unit-tests/test_mr_regressions.py::test_sigterm_drops_readiness_and_requests_graceful_exit PASSED [100%]
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
======================= 226 passed, 1 warning in 46.61s ========================
|
||||
Container mtusi-messenger-lab3-db-1 Running
|
||||
Container mtusi-messenger-lab3-redis-1 Running
|
||||
|
||||
exit_code=0; elapsed_seconds=52.328
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"status": "PASS",
|
||||
"at_utc": "2026-11-02T14:38:48.559702+00:00"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"at_utc": "2026-11-02T14:04:52.232537+00:00",
|
||||
"platform": "Windows-10-10.0.19045-SP0",
|
||||
"cpu_count": 16,
|
||||
"python": "3.11.9",
|
||||
"duration": 20,
|
||||
"workload": "2 closed-loop clients, POST+GET; uncertain POST retried with same key/body"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
$ docker version
|
||||
Client:
|
||||
Version: 26.1.4
|
||||
API version: 1.45
|
||||
Go version: go1.21.11
|
||||
Git commit: 5650f9b
|
||||
Built: Wed Jun 5 11:29:54 2024
|
||||
OS/Arch: windows/amd64
|
||||
Context: desktop-linux
|
||||
|
||||
Server: Docker Desktop 4.31.1 (153621)
|
||||
Engine:
|
||||
Version: 26.1.4
|
||||
API version: 1.45 (minimum version 1.24)
|
||||
Go version: go1.21.11
|
||||
Git commit: de5c9cf
|
||||
Built: Wed Jun 5 11:29:22 2024
|
||||
OS/Arch: linux/amd64
|
||||
Experimental: false
|
||||
containerd:
|
||||
Version: 1.6.33
|
||||
GitCommit: d2d58213f83a351ca8f528a95fbd145f5654e957
|
||||
runc:
|
||||
Version: 1.1.12
|
||||
GitCommit: v1.1.12-0-g51d5e94
|
||||
docker-init:
|
||||
Version: 0.19.0
|
||||
GitCommit: de40ad0
|
||||
|
||||
exit_code=0; elapsed_seconds=0.094
|
||||
@@ -0,0 +1,3 @@
|
||||
$ docker compose --env-file .env config --quiet
|
||||
|
||||
exit_code=0; elapsed_seconds=0.297
|
||||
@@ -0,0 +1,8 @@
|
||||
$ docker inspect --format {{.Name}} cpus={{.HostConfig.NanoCpus}} memory={{.HostConfig.Memory}} ports={{json .HostConfig.PortBindings}} b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8 3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a 765a7b20a31ea3ea8cfd024fe9d4a938c46f4d23d743e4db310b354d357014d8 5675a02e89826f64b25026269d5dc9177a7172ce4922722875c4d986e8423125 1b3ad58c1dd2bec01048e78af86e3c9812172df3c4189eab27352b11a950673d
|
||||
/mtusi-messenger-lab3-api-a-1 cpus=500000000 memory=268435456 ports={}
|
||||
/mtusi-messenger-lab3-api-b-1 cpus=500000000 memory=268435456 ports={}
|
||||
/mtusi-messenger-lab3-db-1 cpus=1000000000 memory=536870912 ports={}
|
||||
/mtusi-messenger-lab3-nginx-1 cpus=250000000 memory=100663296 ports={"8080/tcp":[{"HostIp":"127.0.0.1","HostPort":"8080"}]}
|
||||
/mtusi-messenger-lab3-redis-1 cpus=250000000 memory=134217728 ports={}
|
||||
|
||||
exit_code=0; elapsed_seconds=0.062
|
||||
@@ -0,0 +1,8 @@
|
||||
$ docker compose --env-file .env ps -q
|
||||
b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8
|
||||
3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a
|
||||
765a7b20a31ea3ea8cfd024fe9d4a938c46f4d23d743e4db310b354d357014d8
|
||||
5675a02e89826f64b25026269d5dc9177a7172ce4922722875c4d986e8423125
|
||||
1b3ad58c1dd2bec01048e78af86e3c9812172df3c4189eab27352b11a950673d
|
||||
|
||||
exit_code=0; elapsed_seconds=0.407
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8",
|
||||
"pid": 494,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T13:54:44.930052336Z",
|
||||
"status": 200,
|
||||
"instance_id": "a9caf7e09cdc4d63bf6c0a51f92d38f3"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 496,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T13:54:44.929946678Z",
|
||||
"status": 200,
|
||||
"instance_id": "f8a853f11dcd42be9d37227923a8b62a"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
$ C:\Users\ira\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe tests/smoke.py --base-url http://localhost:8080
|
||||
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
exit_code=0; elapsed_seconds=67.235
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"parallel_requests": 12,
|
||||
"unique_message_ids": 1,
|
||||
"history_rows": 1,
|
||||
"instances": [
|
||||
"a9caf7e09cdc4d63bf6c0a51f92d38f3",
|
||||
"f8a853f11dcd42be9d37227923a8b62a"
|
||||
],
|
||||
"conflict_status": 409
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"mode": "stop",
|
||||
"service": "api-a",
|
||||
"target_instance": "a9caf7e09cdc4d63bf6c0a51f92d38f3",
|
||||
"observed_with_one_session": [
|
||||
"a9caf7e09cdc4d63bf6c0a51f92d38f3",
|
||||
"f8a853f11dcd42be9d37227923a8b62a"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8",
|
||||
"pid": 494,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T13:54:44.930052336Z",
|
||||
"status": 200,
|
||||
"instance_id": "a9caf7e09cdc4d63bf6c0a51f92d38f3"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 496,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T13:54:44.929946678Z",
|
||||
"status": 200,
|
||||
"instance_id": "f8a853f11dcd42be9d37227923a8b62a"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8",
|
||||
"pid": 0,
|
||||
"state": "exited",
|
||||
"started_at": "2026-11-02T13:54:44.930052336Z"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 496,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T13:54:44.929946678Z",
|
||||
"status": 200,
|
||||
"instance_id": "f8a853f11dcd42be9d37227923a8b62a"
|
||||
}
|
||||
],
|
||||
"action": "{\"stopped_service\": \"api-a\", \"instance_id\": \"a9caf7e09cdc4d63bf6c0a51f92d38f3\"}\n",
|
||||
"action_seconds": 3.594,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 24.609,
|
||||
"attempts": 24,
|
||||
"successes": 24,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.975,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2047.0,
|
||||
"p99": 2078.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 23.609,
|
||||
"attempts": 22,
|
||||
"successes": 22,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.932,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2047.0,
|
||||
"p99": 2078.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 13,
|
||||
"history_messages": 13,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 9.25,
|
||||
"write": {
|
||||
"elapsed_seconds": 24.609,
|
||||
"attempts": 12,
|
||||
"successes": 12,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.488,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2078.0,
|
||||
"p99": 2078.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 7.187,
|
||||
"read": {
|
||||
"elapsed_seconds": 24.609,
|
||||
"attempts": 12,
|
||||
"successes": 12,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.488,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2047.0,
|
||||
"p99": 2047.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"mode": "stop",
|
||||
"service": "api-b",
|
||||
"target_instance": "f8a853f11dcd42be9d37227923a8b62a",
|
||||
"observed_with_one_session": [
|
||||
"71f43777fc8842999fb52b8b37b54209",
|
||||
"f8a853f11dcd42be9d37227923a8b62a"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8",
|
||||
"pid": 33274,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:08:05.363422472Z",
|
||||
"status": 200,
|
||||
"instance_id": "71f43777fc8842999fb52b8b37b54209"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 496,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T13:54:44.929946678Z",
|
||||
"status": 200,
|
||||
"instance_id": "f8a853f11dcd42be9d37227923a8b62a"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8",
|
||||
"pid": 33274,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:08:05.363422472Z",
|
||||
"status": 200,
|
||||
"instance_id": "71f43777fc8842999fb52b8b37b54209"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 0,
|
||||
"state": "exited",
|
||||
"started_at": "2026-11-02T13:54:44.929946678Z"
|
||||
}
|
||||
],
|
||||
"action": "{\"stopped_service\": \"api-b\", \"instance_id\": \"f8a853f11dcd42be9d37227923a8b62a\"}\n",
|
||||
"action_seconds": 3.922,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 24.672,
|
||||
"attempts": 24,
|
||||
"successes": 24,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.973,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 23.672,
|
||||
"attempts": 22,
|
||||
"successes": 22,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.929,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 13,
|
||||
"history_messages": 13,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 9.343,
|
||||
"write": {
|
||||
"elapsed_seconds": 24.672,
|
||||
"attempts": 12,
|
||||
"successes": 12,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2063.0,
|
||||
"p99": 2063.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 7.25,
|
||||
"read": {
|
||||
"elapsed_seconds": 24.672,
|
||||
"attempts": 12,
|
||||
"successes": 12,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2094.0,
|
||||
"p99": 2094.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
$ C:\Users\ira\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url http://localhost:8080
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 7, "failed_attempts": 0, "first_recovery_seconds": 6.343}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
exit_code=0; elapsed_seconds=121.531
|
||||
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"mode": "replace",
|
||||
"service": "api-a",
|
||||
"target_instance": "71f43777fc8842999fb52b8b37b54209",
|
||||
"observed_with_one_session": [
|
||||
"71f43777fc8842999fb52b8b37b54209",
|
||||
"7755536d105945f7bc8fb8a5f1afc7db"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "b5f9cdc58cfa1e5ba32d7219909ca0b02f6984e2d69ec6090872f7c1aa3d40b8",
|
||||
"pid": 33274,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:08:05.363422472Z",
|
||||
"status": 200,
|
||||
"instance_id": "71f43777fc8842999fb52b8b37b54209"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 40829,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:11:10.686011176Z",
|
||||
"status": 200,
|
||||
"instance_id": "7755536d105945f7bc8fb8a5f1afc7db"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "23e09768ad0c70567c705b69a9383a1ba2ce89c5c2ccf58117662168c763599c",
|
||||
"pid": 43148,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:12:02.136399326Z",
|
||||
"status": 200,
|
||||
"instance_id": "1b8747dfda534a5a9ed92482ccb43f43"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 40829,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:11:10.686011176Z",
|
||||
"status": 200,
|
||||
"instance_id": "7755536d105945f7bc8fb8a5f1afc7db"
|
||||
}
|
||||
],
|
||||
"action": {
|
||||
"service": "api-a",
|
||||
"before": "71f43777fc8842999fb52b8b37b54209",
|
||||
"after": "1b8747dfda534a5a9ed92482ccb43f43"
|
||||
},
|
||||
"action_seconds": 20.032,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 28.921,
|
||||
"attempts": 28,
|
||||
"successes": 28,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.968,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2110.0,
|
||||
"p99": 2141.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 27.875,
|
||||
"attempts": 26,
|
||||
"successes": 26,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.933,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2078.0,
|
||||
"p99": 2141.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 15,
|
||||
"history_messages": 15,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 25.75,
|
||||
"write": {
|
||||
"elapsed_seconds": 28.921,
|
||||
"attempts": 14,
|
||||
"successes": 14,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.484,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2062.0,
|
||||
"p95": 2141.0,
|
||||
"p99": 2141.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 23.657,
|
||||
"read": {
|
||||
"elapsed_seconds": 28.921,
|
||||
"attempts": 14,
|
||||
"successes": 14,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.484,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2047.0,
|
||||
"p99": 2047.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"mode": "replace",
|
||||
"service": "api-b",
|
||||
"target_instance": "7755536d105945f7bc8fb8a5f1afc7db",
|
||||
"observed_with_one_session": [
|
||||
"1b8747dfda534a5a9ed92482ccb43f43",
|
||||
"7755536d105945f7bc8fb8a5f1afc7db"
|
||||
],
|
||||
"before": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "23e09768ad0c70567c705b69a9383a1ba2ce89c5c2ccf58117662168c763599c",
|
||||
"pid": 43148,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:12:02.136399326Z",
|
||||
"status": 200,
|
||||
"instance_id": "1b8747dfda534a5a9ed92482ccb43f43"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "3923c6b10754bdf24cf03312f2cdfc47d0c57b626e413c15c6bf99584795866a",
|
||||
"pid": 40829,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:11:10.686011176Z",
|
||||
"status": 200,
|
||||
"instance_id": "7755536d105945f7bc8fb8a5f1afc7db"
|
||||
}
|
||||
],
|
||||
"after_action": [
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "23e09768ad0c70567c705b69a9383a1ba2ce89c5c2ccf58117662168c763599c",
|
||||
"pid": 43148,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:12:02.136399326Z",
|
||||
"status": 200,
|
||||
"instance_id": "1b8747dfda534a5a9ed92482ccb43f43"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "51a88aae9d0221d84f2483e06469327ee9fd457c4a95f50557907d930f9e64ed",
|
||||
"pid": 46165,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:06.793037685Z",
|
||||
"status": 200,
|
||||
"instance_id": "acec6d43ecdd4b76a240c85f334d3152"
|
||||
}
|
||||
],
|
||||
"action": {
|
||||
"service": "api-b",
|
||||
"before": "7755536d105945f7bc8fb8a5f1afc7db",
|
||||
"after": "acec6d43ecdd4b76a240c85f334d3152"
|
||||
},
|
||||
"action_seconds": 18.875,
|
||||
"concurrency": 2,
|
||||
"total": {
|
||||
"elapsed_seconds": 28.797,
|
||||
"attempts": 28,
|
||||
"successes": 28,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.972,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2078.0,
|
||||
"p99": 2079.0
|
||||
}
|
||||
},
|
||||
"during_and_after_action": {
|
||||
"elapsed_seconds": 27.797,
|
||||
"attempts": 26,
|
||||
"successes": 26,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.935,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2032.0,
|
||||
"p95": 2078.0,
|
||||
"p99": 2079.0
|
||||
}
|
||||
},
|
||||
"confirmed_responses": 15,
|
||||
"history_messages": 15,
|
||||
"duplicates": 0,
|
||||
"existing_session_works": true,
|
||||
"first_write_after_action_seconds": 21.578,
|
||||
"write": {
|
||||
"elapsed_seconds": 28.797,
|
||||
"attempts": 14,
|
||||
"successes": 14,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2047.0,
|
||||
"p95": 2078.0,
|
||||
"p99": 2078.0
|
||||
}
|
||||
},
|
||||
"first_read_after_action_seconds": 23.594,
|
||||
"read": {
|
||||
"elapsed_seconds": 28.797,
|
||||
"attempts": 14,
|
||||
"successes": 14,
|
||||
"errors": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 0.486,
|
||||
"successful_latency_ms": {
|
||||
"p50": 2031.0,
|
||||
"p95": 2079.0,
|
||||
"p99": 2079.0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
$ C:\Users\ira\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe tests/resilience.py --mode persistence --action-script scripts/restart.sh --base-url http://localhost: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.
|
||||
|
||||
exit_code=0; elapsed_seconds=43.297
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"service": "api-a",
|
||||
"container_id": "ef1e096f1c30593e0d8e9ebeb467a21c997580d835473c76142127d2d402b235",
|
||||
"pid": 48570,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.63201658Z",
|
||||
"status": 200,
|
||||
"instance_id": "1b38655b9a21447494973eb99d5ea039"
|
||||
},
|
||||
{
|
||||
"service": "api-b",
|
||||
"container_id": "4cccbf699f55df2a5e9fd6e19aa897796654a47cdac2ff372565fa6c2a4677e0",
|
||||
"pid": 48587,
|
||||
"state": "running",
|
||||
"started_at": "2026-11-02T14:13:58.715403308Z",
|
||||
"status": 200,
|
||||
"instance_id": "128e6b095f444dffa33214cd3cd33184"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,47 @@
|
||||
$ docker compose --env-file .env exec -T nginx nginx -T -c /opt/lb/nginx.conf
|
||||
# configuration file /opt/lb/nginx.conf:
|
||||
worker_processes 1;
|
||||
pid /tmp/nginx.pid;
|
||||
error_log /dev/stderr warn;
|
||||
worker_shutdown_timeout 5s;
|
||||
events { worker_connections 1024; }
|
||||
http {
|
||||
log_format upstream '$request_method $uri status=$status upstream=$upstream_addr upstream_status=$upstream_status time=$request_time';
|
||||
access_log /dev/stdout upstream;
|
||||
resolver 127.0.0.11 valid=1s ipv6=off;
|
||||
resolver_timeout 1s;
|
||||
include /tmp/backends.conf;
|
||||
server {
|
||||
listen 8080;
|
||||
server_tokens off;
|
||||
client_max_body_size 256k;
|
||||
client_header_timeout 5s;
|
||||
client_body_timeout 5s;
|
||||
keepalive_timeout 2s;
|
||||
location / {
|
||||
proxy_pass http://api_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_read_timeout 8s;
|
||||
proxy_send_timeout 8s;
|
||||
proxy_next_upstream error timeout http_502 http_503 http_504;
|
||||
proxy_next_upstream_tries 2;
|
||||
proxy_next_upstream_timeout 9s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# configuration file /tmp/backends.conf:
|
||||
upstream api_backend {
|
||||
zone api_backend 64k;
|
||||
server api-a:8080 resolve max_fails=1 fail_timeout=2s;
|
||||
server api-b:8080 resolve max_fails=1 fail_timeout=2s;
|
||||
}
|
||||
|
||||
nginx: the configuration file /opt/lb/nginx.conf syntax is ok
|
||||
nginx: configuration file /opt/lb/nginx.conf test is successful
|
||||
|
||||
exit_code=0; elapsed_seconds=0.375
|
||||
@@ -0,0 +1,303 @@
|
||||
$ docker compose --env-file .env --profile test run --rm --build tests
|
||||
#0 building with "desktop-linux" instance using docker driver
|
||||
|
||||
#1 [tests internal] load build definition from Dockerfile
|
||||
#1 transferring dockerfile: 955B 0.0s done
|
||||
#1 DONE 0.0s
|
||||
|
||||
#2 [tests internal] load metadata for docker.io/library/python:3.12.8-slim-bookworm
|
||||
#2 ...
|
||||
|
||||
#3 [tests auth] library/python:pull token for registry-1.docker.io
|
||||
#3 DONE 0.0s
|
||||
|
||||
#2 [tests internal] load metadata for docker.io/library/python:3.12.8-slim-bookworm
|
||||
#2 DONE 1.7s
|
||||
|
||||
#4 [tests internal] load .dockerignore
|
||||
#4 transferring context: 196B done
|
||||
#4 DONE 0.0s
|
||||
|
||||
#5 [tests base 1/6] FROM docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
|
||||
#5 DONE 0.0s
|
||||
|
||||
#6 [tests internal] load build context
|
||||
#6 transferring context: 87.79kB 0.0s done
|
||||
#6 DONE 0.0s
|
||||
|
||||
#7 [tests base 4/6] COPY requirements.txt ./
|
||||
#7 CACHED
|
||||
|
||||
#8 [tests test 2/5] RUN pip install -r requirements-test.txt
|
||||
#8 CACHED
|
||||
|
||||
#9 [tests test 1/5] COPY requirements-test.txt ./
|
||||
#9 CACHED
|
||||
|
||||
#10 [tests test 4/5] COPY student-tests ./student-tests
|
||||
#10 CACHED
|
||||
|
||||
#11 [tests test 3/5] COPY pytest.ini ./
|
||||
#11 CACHED
|
||||
|
||||
#12 [tests base 3/6] WORKDIR /srv
|
||||
#12 CACHED
|
||||
|
||||
#13 [tests base 6/6] COPY app ./app
|
||||
#13 CACHED
|
||||
|
||||
#14 [tests base 2/6] RUN groupadd --system --gid 10001 app && useradd --system --uid 10001 --gid app --no-create-home --shell /usr/sbin/nologin app
|
||||
#14 CACHED
|
||||
|
||||
#15 [tests base 5/6] RUN pip install -r requirements.txt
|
||||
#15 CACHED
|
||||
|
||||
#16 [tests test 5/5] COPY unit-tests ./unit-tests
|
||||
#16 CACHED
|
||||
|
||||
#17 [tests] exporting to image
|
||||
#17 exporting layers done
|
||||
#17 writing image sha256:c4492757aa5070ae7b09009339bfa52d41b2ef1a39beb1d7dde355a0c2fa257e done
|
||||
#17 naming to docker.io/library/mtusi-messenger:lab3-test done
|
||||
#17 DONE 0.0s
|
||||
============================= test session starts ==============================
|
||||
collecting ... collected 226 items
|
||||
|
||||
student-tests/test_auth.py::test_register_returns_user_without_secrets PASSED [ 0%]
|
||||
student-tests/test_auth.py::test_register_password_rules[None] PASSED [ 0%]
|
||||
student-tests/test_auth.py::test_register_password_rules[] PASSED [ 1%]
|
||||
student-tests/test_auth.py::test_register_password_rules[short] PASSED [ 1%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaa] PASSED [ 2%]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 2%]
|
||||
student-tests/test_auth.py::test_register_password_rules[123456789012] PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_register_password_rules[\u043f\u0430\u0440\u043e\u043b\u044c] PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_register_password_border_lengths PASSED [ 3%]
|
||||
student-tests/test_auth.py::test_login_success_shape PASSED [ 4%]
|
||||
student-tests/test_auth.py::test_each_login_gives_new_token PASSED [ 4%]
|
||||
student-tests/test_auth.py::test_wrong_password_and_unknown_user_look_the_same PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic] PASSED [ 5%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic !!!not-base64!!!] PASSED [ 6%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic bm9jb2xvbg==] PASSED [ 6%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic 0LjQvNGPOnBhc3N3b3JkLTEyMzQ1Ng==] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic dXNlcjr//i1iYWQtdXRmOA==] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Bearer abc] PASSED [ 7%]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[] PASSED [ 8%]
|
||||
student-tests/test_auth.py::test_login_without_header_is_401 PASSED [ 8%]
|
||||
student-tests/test_auth.py::test_password_with_colon_and_unicode_works PASSED [ 9%]
|
||||
student-tests/test_auth.py::test_bearer_token_gives_access PASSED [ 9%]
|
||||
student-tests/test_auth.py::test_business_endpoint_rejects_basic PASSED [ 10%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[] PASSED [ 10%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer short] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 11%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Token abc] PASSED [ 12%]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[bearer] PASSED [ 12%]
|
||||
student-tests/test_auth.py::test_x_user_id_alone_gives_no_access PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_x_user_id_does_not_change_owner_of_session PASSED [ 13%]
|
||||
student-tests/test_auth.py::test_logout_revokes_token_and_repeat_is_401 PASSED [ 14%]
|
||||
student-tests/test_auth.py::test_logout_without_token_is_401 PASSED [ 14%]
|
||||
student-tests/test_auth.py::test_logout_revokes_only_current_session PASSED [ 15%]
|
||||
student-tests/test_auth.py::test_session_lives_longer_than_300_seconds PASSED [ 15%]
|
||||
student-tests/test_cache.py::test_user_profile_is_served_from_cache_with_bounded_ttl PASSED [ 15%]
|
||||
student-tests/test_cache.py::test_cache_never_stores_raw_tokens_or_passwords PASSED [ 16%]
|
||||
student-tests/test_cache.py::test_logout_revokes_cached_session PASSED [ 16%]
|
||||
student-tests/test_cache.py::test_late_cache_fill_cannot_resurrect_revoked_session PASSED [ 17%]
|
||||
student-tests/test_cache.py::test_flushed_cache_loses_nothing PASSED [ 17%]
|
||||
student-tests/test_cache.py::test_cache_does_not_extend_short_session PASSED [ 18%]
|
||||
student-tests/test_cache.py::test_staleness_after_out_of_band_delete_is_bounded_by_cache_ttl PASSED [ 18%]
|
||||
student-tests/test_cache.py::test_redis_down_requests_bypass_cache_and_stay_fast PASSED [ 19%]
|
||||
student-tests/test_cache.py::test_redis_down_never_trusts_anonymous_or_unknown_tokens PASSED [ 19%]
|
||||
student-tests/test_cache.py::test_revocation_lost_while_redis_down_is_flushed_on_recovery PASSED [ 19%]
|
||||
student-tests/test_cache.py::test_without_cache_url_cache_is_off PASSED [ 20%]
|
||||
student-tests/test_cache.py::test_lost_revocation_survives_api_restart[False] PASSED [ 20%]
|
||||
student-tests/test_cache.py::test_lost_revocation_survives_api_restart[True] PASSED [ 21%]
|
||||
student-tests/test_cache.py::test_cached_session_deleted_in_database_is_rejected_immediately PASSED [ 21%]
|
||||
student-tests/test_concurrency.py::test_100_messages_from_10_clients_in_parallel PASSED [ 22%]
|
||||
student-tests/test_concurrency.py::test_parallel_chat_creation_and_reading PASSED [ 22%]
|
||||
student-tests/test_contract_basics.py::test_health_endpoints PASSED [ 23%]
|
||||
student-tests/test_contract_basics.py::test_every_response_has_unique_request_id PASSED [ 23%]
|
||||
student-tests/test_contract_basics.py::test_unknown_path_is_404_in_common_format PASSED [ 23%]
|
||||
student-tests/test_contract_basics.py::test_trailing_slash_is_not_redirected PASSED [ 24%]
|
||||
student-tests/test_contract_basics.py::test_wrong_method_is_405_in_common_format PASSED [ 24%]
|
||||
student-tests/test_contract_basics.py::test_two_users_one_chat_two_messages PASSED [ 25%]
|
||||
student-tests/test_contract_basics.py::test_chat_response_shape PASSED [ 25%]
|
||||
student-tests/test_contract_basics.py::test_unexpected_exception_gives_500_without_details PASSED [ 26%]
|
||||
student-tests/test_contract_basics.py::test_logs_have_requests_but_no_secrets PASSED [ 26%]
|
||||
student-tests/test_database.py::test_password_is_stored_as_scrypt_hash_not_plaintext PASSED [ 26%]
|
||||
student-tests/test_database.py::test_same_password_gives_different_hashes PASSED [ 27%]
|
||||
student-tests/test_database.py::test_session_table_keeps_token_hash_not_token PASSED [ 27%]
|
||||
student-tests/test_database.py::test_message_is_really_in_the_database PASSED [ 28%]
|
||||
student-tests/test_database.py::test_migrations_can_run_again_without_duplicating_anything PASSED [ 28%]
|
||||
student-tests/test_database.py::test_expected_tables_and_indexes_exist PASSED [ 29%]
|
||||
student-tests/test_database.py::test_primary_and_foreign_keys_are_declared PASSED [ 29%]
|
||||
student-tests/test_database.py::test_database_itself_rejects_bad_rows PASSED [ 30%]
|
||||
student-tests/test_database.py::test_chat_creation_is_atomic PASSED [ 30%]
|
||||
student-tests/test_database.py::test_successful_chat_has_all_members_in_database PASSED [ 30%]
|
||||
student-tests/test_db_failure.py::test_database_down_gives_503_and_never_trusts_anyone PASSED [ 31%]
|
||||
student-tests/test_db_failure.py::test_database_down_with_cache_up_still_needs_database_for_data PASSED [ 31%]
|
||||
student-tests/test_duplicate_username.py::test_second_registration_with_same_username_is_409 PASSED [ 32%]
|
||||
student-tests/test_duplicate_username.py::test_duplicate_does_not_replace_original_user PASSED [ 32%]
|
||||
student-tests/test_duplicate_username.py::test_username_is_case_sensitive_lowercase_only PASSED [ 33%]
|
||||
student-tests/test_duplicate_username.py::test_parallel_registration_of_same_username_creates_exactly_one PASSED [ 33%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[] PASSED [ 34%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ] PASSED [ 34%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ] PASSED [ 34%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\n] PASSED [ 35%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\t \n] PASSED [ 35%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\xa0] PASSED [ 36%]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\u2003] PASSED [ 36%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body0] PASSED [ 37%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body1] PASSED [ 37%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body2] PASSED [ 38%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body3] PASSED [ 38%]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body4] PASSED [ 38%]
|
||||
student-tests/test_empty_message.py::test_text_length_is_counted_in_characters PASSED [ 39%]
|
||||
student-tests/test_empty_message.py::test_nul_character_is_400_not_500 PASSED [ 39%]
|
||||
student-tests/test_empty_message.py::test_unicode_survives_the_database PASSED [ 40%]
|
||||
student-tests/test_empty_message.py::test_message_has_correct_fields PASSED [ 40%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[0] PASSED [ 41%]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[9000] PASSED [ 41%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_chat PASSED [ 42%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_history PASSED [ 42%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_write PASSED [ 42%]
|
||||
student-tests/test_foreign_chat.py::test_outsider_gets_404_even_with_bad_body PASSED [ 43%]
|
||||
student-tests/test_foreign_chat.py::test_unknown_chat_looks_the_same_as_foreign PASSED [ 43%]
|
||||
student-tests/test_foreign_chat.py::test_chat_list_shows_only_own_chats PASSED [ 44%]
|
||||
student-tests/test_foreign_chat.py::test_bad_chat_id_is_400 PASSED [ 44%]
|
||||
student-tests/test_foreign_chat.py::test_no_token_is_401_everywhere PASSED [ 45%]
|
||||
student-tests/test_foreign_chat.py::test_401_comes_before_404 PASSED [ 45%]
|
||||
student-tests/test_foreign_chat.py::test_member_can_read_and_write PASSED [ 46%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[None] PASSED [ 46%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[] PASSED [ 46%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a b] PASSED [ 47%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a?b] PASSED [ 47%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 48%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a,b] PASSED [ 48%]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a/b] PASSED [ 49%]
|
||||
student-tests/test_idempotency.py::test_duplicate_headers_are_invalid PASSED [ 49%]
|
||||
student-tests/test_idempotency.py::test_replay_and_conflict_preserve_original_result PASSED [ 50%]
|
||||
student-tests/test_idempotency.py::test_parallel_same_key_across_two_applications PASSED [ 50%]
|
||||
student-tests/test_idempotency.py::test_key_scope_includes_user_and_chat PASSED [ 50%]
|
||||
student-tests/test_idempotency.py::test_expired_result_allows_new_message PASSED [ 51%]
|
||||
student-tests/test_idempotency.py::test_failure_between_message_and_result_rolls_back PASSED [ 51%]
|
||||
student-tests/test_idempotency.py::test_committed_but_lost_response_is_safe_to_retry PASSED [ 52%]
|
||||
student-tests/test_idempotency.py::test_replay_rechecks_session_and_chat_access PASSED [ 52%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{] PASSED [ 53%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[not json at all] PASSED [ 53%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[] PASSED [ 53%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": "abc",}] PASSED [ 54%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[\xff\xfe\x00] PASSED [ 54%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": NaN}] PASSED [ 55%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[["username"]] PASSED [ 55%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json["text"] PASSED [ 56%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[null] PASSED [ 56%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes0] PASSED [ 57%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes1] PASSED [ 57%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes2] PASSED [ 57%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes3] PASSED [ 58%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes4] PASSED [ 58%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes5] PASSED [ 59%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes6] PASSED [ 59%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes7] PASSED [ 60%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes8] PASSED [ 60%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes9] PASSED [ 61%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes10] PASSED [ 61%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes11] PASSED [ 61%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes12] PASSED [ 62%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes13] PASSED [ 62%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes14] PASSED [ 63%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes15] PASSED [ 63%]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes16] PASSED [ 64%]
|
||||
student-tests/test_invalid_json.py::test_border_values_are_accepted PASSED [ 64%]
|
||||
student-tests/test_invalid_json.py::test_lone_surrogate_is_400_not_500 PASSED [ 65%]
|
||||
student-tests/test_invalid_json.py::test_wrong_or_missing_content_type_is_415 PASSED [ 65%]
|
||||
student-tests/test_invalid_json.py::test_huge_body_is_413 PASSED [ 65%]
|
||||
student-tests/test_invalid_json.py::test_broken_json_in_message_and_chat PASSED [ 66%]
|
||||
student-tests/test_invalid_json.py::test_sender_id_in_message_is_rejected PASSED [ 66%]
|
||||
student-tests/test_invalid_json.py::test_chat_body_validation PASSED [ 67%]
|
||||
student-tests/test_pagination.py::test_walk_25_messages_by_7 PASSED [ 67%]
|
||||
student-tests/test_pagination.py::test_exact_multiple_has_no_empty_extra_page PASSED [ 68%]
|
||||
student-tests/test_pagination.py::test_limit_one_walks_everything PASSED [ 68%]
|
||||
student-tests/test_pagination.py::test_default_limit_is_50_and_max_is_100 PASSED [ 69%]
|
||||
student-tests/test_pagination.py::test_empty_history PASSED [ 69%]
|
||||
student-tests/test_pagination.py::test_limit_can_change_between_pages PASSED [ 69%]
|
||||
student-tests/test_pagination.py::test_messages_sent_during_walk_appear_at_the_end PASSED [ 70%]
|
||||
student-tests/test_pagination.py::test_created_at_is_increasing_and_utc PASSED [ 70%]
|
||||
student-tests/test_pagination.py::test_bad_limit_values PASSED [ 71%]
|
||||
student-tests/test_pagination.py::test_garbage_cursor_is_400 PASSED [ 71%]
|
||||
student-tests/test_pagination.py::test_cursor_from_another_chat_is_400 PASSED [ 72%]
|
||||
student-tests/test_pagination.py::test_chat_list_pagination PASSED [ 72%]
|
||||
student-tests/test_pagination.py::test_chat_list_cursor_cannot_be_used_for_messages PASSED [ 73%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages--1] PASSED [ 73%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1000000000000000000000000000000] PASSED [ 73%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-253402300800000000] PASSED [ 74%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-True] PASSED [ 74%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1.5] PASSED [ 75%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1] PASSED [ 75%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-None] PASSED [ 76%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats--1] PASSED [ 76%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1000000000000000000000000000000] PASSED [ 76%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-253402300800000000] PASSED [ 77%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-True] PASSED [ 77%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1.5] PASSED [ 78%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1] PASSED [ 78%]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-None] PASSED [ 79%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[messages-0] PASSED [ 79%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[messages-253402300799999999] PASSED [ 80%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[chats-0] PASSED [ 80%]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[chats-253402300799999999] PASSED [ 80%]
|
||||
student-tests/test_session_expiry.py::test_session_expires_after_ttl PASSED [ 81%]
|
||||
student-tests/test_session_expiry.py::test_expired_sessions_are_cleaned_on_next_login PASSED [ 81%]
|
||||
student-tests/test_session_expiry.py::test_short_ttl_from_environment_variable PASSED [ 82%]
|
||||
student-tests/test_transactions.py::test_failure_after_chat_insert_rolls_back_whole_operation PASSED [ 82%]
|
||||
student-tests/test_transactions.py::test_pool_is_bounded_by_settings PASSED [ 83%]
|
||||
student-tests/test_transactions.py::test_exhausted_pool_gives_fast_503 PASSED [ 83%]
|
||||
unit-tests/test_message_transaction.py::test_conflicting_replay_rolls_back_without_commit PASSED [ 84%]
|
||||
unit-tests/test_message_transaction.py::test_result_insert_failure_never_commits_message PASSED [ 84%]
|
||||
unit-tests/test_message_transaction.py::test_replay_returns_original_message_and_releases_transaction PASSED [ 84%]
|
||||
unit-tests/test_message_transaction.py::test_failed_commit_rolls_back_and_propagates_error PASSED [ 85%]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/users/me-GET] PASSED [ 85%]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/chats/00000000-0000-0000-0000-000000000002/messages-POST] PASSED [ 86%]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/auth/sessions/current-DELETE] PASSED [ 86%]
|
||||
unit-tests/test_mr_regressions.py::test_valid_cache_hit_checks_session_without_loading_user PASSED [ 87%]
|
||||
unit-tests/test_mr_regressions.py::test_database_failure_on_positive_cache_hit_is_503 PASSED [ 87%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages--1] PASSED [ 88%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-253402300800000000] PASSED [ 88%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1000000000000000000000000000000] PASSED [ 88%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-True] PASSED [ 89%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1.5] PASSED [ 89%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1] PASSED [ 90%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-None] PASSED [ 90%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats--1] PASSED [ 91%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-253402300800000000] PASSED [ 91%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1000000000000000000000000000000] PASSED [ 92%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-True] PASSED [ 92%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1.5] PASSED [ 92%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1] PASSED [ 93%]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-None] PASSED [ 93%]
|
||||
unit-tests/test_mr_regressions.py::test_timestamp_boundaries_roundtrip[0] PASSED [ 94%]
|
||||
unit-tests/test_mr_regressions.py::test_timestamp_boundaries_roundtrip[253402300799999999] PASSED [ 94%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[None] PASSED [ 95%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[] PASSED [ 95%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[bad key] PASSED [ 96%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 96%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[a?b] PASSED [ 96%]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[a,b] PASSED [ 97%]
|
||||
unit-tests/test_mr_regressions.py::test_message_normalization_and_conflict PASSED [ 97%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/health/live] PASSED [ 98%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/missing] PASSED [ 98%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/api/v1/users/me] PASSED [ 99%]
|
||||
unit-tests/test_mr_regressions.py::test_instance_alias_changes_between_applications PASSED [ 99%]
|
||||
unit-tests/test_mr_regressions.py::test_sigterm_drops_readiness_and_requests_graceful_exit PASSED [100%]
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/usr/local/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
======================= 226 passed, 1 warning in 46.79s ========================
|
||||
Container mtusi-messenger-lab3-db-1 Running
|
||||
Container mtusi-messenger-lab3-redis-1 Running
|
||||
|
||||
exit_code=0; elapsed_seconds=53.031
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"status": "PASS",
|
||||
"at_utc": "2026-11-02T14:15:07.979020+00:00"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
$ /workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
|
||||
exit_code=0
|
||||
@@ -0,0 +1,4 @@
|
||||
$ /workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python scripts/validate_openapi.py
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
|
||||
exit_code=0
|
||||
@@ -0,0 +1,4 @@
|
||||
$ /workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python scripts/check_lab3.py
|
||||
PASS: lab3 static structure, resource/port isolation, contract, Python/sh syntax; runtime NOT tested.
|
||||
|
||||
exit_code=0
|
||||
@@ -0,0 +1,11 @@
|
||||
$ /workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python -m pytest -q unit-tests -p no:cacheprovider
|
||||
..................................... [100%]
|
||||
=============================== warnings summary ===============================
|
||||
../.venv/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/workspace/scratch/03a740016edf/.venv/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
37 passed, 1 warning in 0.83s
|
||||
|
||||
exit_code=0
|
||||
@@ -0,0 +1,237 @@
|
||||
$ /workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python -m pytest --collect-only -q -p no:cacheprovider
|
||||
student-tests/test_auth.py::test_register_returns_user_without_secrets
|
||||
student-tests/test_auth.py::test_register_password_rules[None]
|
||||
student-tests/test_auth.py::test_register_password_rules[]
|
||||
student-tests/test_auth.py::test_register_password_rules[short]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaa]
|
||||
student-tests/test_auth.py::test_register_password_rules[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
|
||||
student-tests/test_auth.py::test_register_password_rules[123456789012]
|
||||
student-tests/test_auth.py::test_register_password_rules[\u043f\u0430\u0440\u043e\u043b\u044c]
|
||||
student-tests/test_auth.py::test_register_password_border_lengths
|
||||
student-tests/test_auth.py::test_login_success_shape
|
||||
student-tests/test_auth.py::test_each_login_gives_new_token
|
||||
student-tests/test_auth.py::test_wrong_password_and_unknown_user_look_the_same
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic !!!not-base64!!!]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic bm9jb2xvbg==]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic 0LjQvNGPOnBhc3N3b3JkLTEyMzQ1Ng==]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Basic dXNlcjr//i1iYWQtdXRmOA==]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[Bearer abc]
|
||||
student-tests/test_auth.py::test_malformed_basic_is_401[]
|
||||
student-tests/test_auth.py::test_login_without_header_is_401
|
||||
student-tests/test_auth.py::test_password_with_colon_and_unicode_works
|
||||
student-tests/test_auth.py::test_bearer_token_gives_access
|
||||
student-tests/test_auth.py::test_business_endpoint_rejects_basic
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer short]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[Token abc]
|
||||
student-tests/test_auth.py::test_bad_or_unknown_bearer_is_401[bearer]
|
||||
student-tests/test_auth.py::test_x_user_id_alone_gives_no_access
|
||||
student-tests/test_auth.py::test_x_user_id_does_not_change_owner_of_session
|
||||
student-tests/test_auth.py::test_logout_revokes_token_and_repeat_is_401
|
||||
student-tests/test_auth.py::test_logout_without_token_is_401
|
||||
student-tests/test_auth.py::test_logout_revokes_only_current_session
|
||||
student-tests/test_auth.py::test_session_lives_longer_than_300_seconds
|
||||
student-tests/test_cache.py::test_user_profile_is_served_from_cache_with_bounded_ttl
|
||||
student-tests/test_cache.py::test_cache_never_stores_raw_tokens_or_passwords
|
||||
student-tests/test_cache.py::test_logout_revokes_cached_session
|
||||
student-tests/test_cache.py::test_late_cache_fill_cannot_resurrect_revoked_session
|
||||
student-tests/test_cache.py::test_flushed_cache_loses_nothing
|
||||
student-tests/test_cache.py::test_cache_does_not_extend_short_session
|
||||
student-tests/test_cache.py::test_staleness_after_out_of_band_delete_is_bounded_by_cache_ttl
|
||||
student-tests/test_cache.py::test_redis_down_requests_bypass_cache_and_stay_fast
|
||||
student-tests/test_cache.py::test_redis_down_never_trusts_anonymous_or_unknown_tokens
|
||||
student-tests/test_cache.py::test_revocation_lost_while_redis_down_is_flushed_on_recovery
|
||||
student-tests/test_cache.py::test_without_cache_url_cache_is_off
|
||||
student-tests/test_cache.py::test_lost_revocation_survives_api_restart[False]
|
||||
student-tests/test_cache.py::test_lost_revocation_survives_api_restart[True]
|
||||
student-tests/test_cache.py::test_cached_session_deleted_in_database_is_rejected_immediately
|
||||
student-tests/test_concurrency.py::test_100_messages_from_10_clients_in_parallel
|
||||
student-tests/test_concurrency.py::test_parallel_chat_creation_and_reading
|
||||
student-tests/test_contract_basics.py::test_health_endpoints
|
||||
student-tests/test_contract_basics.py::test_every_response_has_unique_request_id
|
||||
student-tests/test_contract_basics.py::test_unknown_path_is_404_in_common_format
|
||||
student-tests/test_contract_basics.py::test_trailing_slash_is_not_redirected
|
||||
student-tests/test_contract_basics.py::test_wrong_method_is_405_in_common_format
|
||||
student-tests/test_contract_basics.py::test_two_users_one_chat_two_messages
|
||||
student-tests/test_contract_basics.py::test_chat_response_shape
|
||||
student-tests/test_contract_basics.py::test_unexpected_exception_gives_500_without_details
|
||||
student-tests/test_contract_basics.py::test_logs_have_requests_but_no_secrets
|
||||
student-tests/test_database.py::test_password_is_stored_as_scrypt_hash_not_plaintext
|
||||
student-tests/test_database.py::test_same_password_gives_different_hashes
|
||||
student-tests/test_database.py::test_session_table_keeps_token_hash_not_token
|
||||
student-tests/test_database.py::test_message_is_really_in_the_database
|
||||
student-tests/test_database.py::test_migrations_can_run_again_without_duplicating_anything
|
||||
student-tests/test_database.py::test_expected_tables_and_indexes_exist
|
||||
student-tests/test_database.py::test_primary_and_foreign_keys_are_declared
|
||||
student-tests/test_database.py::test_database_itself_rejects_bad_rows
|
||||
student-tests/test_database.py::test_chat_creation_is_atomic
|
||||
student-tests/test_database.py::test_successful_chat_has_all_members_in_database
|
||||
student-tests/test_db_failure.py::test_database_down_gives_503_and_never_trusts_anyone
|
||||
student-tests/test_db_failure.py::test_database_down_with_cache_up_still_needs_database_for_data
|
||||
student-tests/test_duplicate_username.py::test_second_registration_with_same_username_is_409
|
||||
student-tests/test_duplicate_username.py::test_duplicate_does_not_replace_original_user
|
||||
student-tests/test_duplicate_username.py::test_username_is_case_sensitive_lowercase_only
|
||||
student-tests/test_duplicate_username.py::test_parallel_registration_of_same_username_creates_exactly_one
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[ ]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\n]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\t \n]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\xa0]
|
||||
student-tests/test_empty_message.py::test_blank_text_is_rejected[\u2003]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body0]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body1]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body2]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body3]
|
||||
student-tests/test_empty_message.py::test_missing_or_wrong_type_text_is_rejected[body4]
|
||||
student-tests/test_empty_message.py::test_text_length_is_counted_in_characters
|
||||
student-tests/test_empty_message.py::test_nul_character_is_400_not_500
|
||||
student-tests/test_empty_message.py::test_unicode_survives_the_database
|
||||
student-tests/test_empty_message.py::test_message_has_correct_fields
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[0]
|
||||
student-tests/test_explain.py::test_history_page_uses_index_without_full_scan[9000]
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_chat
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_read_history
|
||||
student-tests/test_foreign_chat.py::test_outsider_cannot_write
|
||||
student-tests/test_foreign_chat.py::test_outsider_gets_404_even_with_bad_body
|
||||
student-tests/test_foreign_chat.py::test_unknown_chat_looks_the_same_as_foreign
|
||||
student-tests/test_foreign_chat.py::test_chat_list_shows_only_own_chats
|
||||
student-tests/test_foreign_chat.py::test_bad_chat_id_is_400
|
||||
student-tests/test_foreign_chat.py::test_no_token_is_401_everywhere
|
||||
student-tests/test_foreign_chat.py::test_401_comes_before_404
|
||||
student-tests/test_foreign_chat.py::test_member_can_read_and_write
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[None]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a b]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a?b]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a,b]
|
||||
student-tests/test_idempotency.py::test_key_is_required_and_validated[a/b]
|
||||
student-tests/test_idempotency.py::test_duplicate_headers_are_invalid
|
||||
student-tests/test_idempotency.py::test_replay_and_conflict_preserve_original_result
|
||||
student-tests/test_idempotency.py::test_parallel_same_key_across_two_applications
|
||||
student-tests/test_idempotency.py::test_key_scope_includes_user_and_chat
|
||||
student-tests/test_idempotency.py::test_expired_result_allows_new_message
|
||||
student-tests/test_idempotency.py::test_failure_between_message_and_result_rolls_back
|
||||
student-tests/test_idempotency.py::test_committed_but_lost_response_is_safe_to_retry
|
||||
student-tests/test_idempotency.py::test_replay_rechecks_session_and_chat_access
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[not json at all]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": "abc",}]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[\xff\xfe\x00]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[{"username": NaN}]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[["username"]]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json["text"]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_broken_json[null]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes0]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes1]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes2]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes3]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes4]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes5]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes6]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes7]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes8]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes9]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes10]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes11]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes12]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes13]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes14]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes15]
|
||||
student-tests/test_invalid_json.py::test_registration_rejects_bad_fields[changes16]
|
||||
student-tests/test_invalid_json.py::test_border_values_are_accepted
|
||||
student-tests/test_invalid_json.py::test_lone_surrogate_is_400_not_500
|
||||
student-tests/test_invalid_json.py::test_wrong_or_missing_content_type_is_415
|
||||
student-tests/test_invalid_json.py::test_huge_body_is_413
|
||||
student-tests/test_invalid_json.py::test_broken_json_in_message_and_chat
|
||||
student-tests/test_invalid_json.py::test_sender_id_in_message_is_rejected
|
||||
student-tests/test_invalid_json.py::test_chat_body_validation
|
||||
student-tests/test_pagination.py::test_walk_25_messages_by_7
|
||||
student-tests/test_pagination.py::test_exact_multiple_has_no_empty_extra_page
|
||||
student-tests/test_pagination.py::test_limit_one_walks_everything
|
||||
student-tests/test_pagination.py::test_default_limit_is_50_and_max_is_100
|
||||
student-tests/test_pagination.py::test_empty_history
|
||||
student-tests/test_pagination.py::test_limit_can_change_between_pages
|
||||
student-tests/test_pagination.py::test_messages_sent_during_walk_appear_at_the_end
|
||||
student-tests/test_pagination.py::test_created_at_is_increasing_and_utc
|
||||
student-tests/test_pagination.py::test_bad_limit_values
|
||||
student-tests/test_pagination.py::test_garbage_cursor_is_400
|
||||
student-tests/test_pagination.py::test_cursor_from_another_chat_is_400
|
||||
student-tests/test_pagination.py::test_chat_list_pagination
|
||||
student-tests/test_pagination.py::test_chat_list_cursor_cannot_be_used_for_messages
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages--1]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1000000000000000000000000000000]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-253402300800000000]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-True]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1.5]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-1]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[messages-None]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats--1]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1000000000000000000000000000000]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-253402300800000000]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-True]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1.5]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-1]
|
||||
student-tests/test_pagination.py::test_invalid_cursor_timestamp_is_400[chats-None]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[messages-0]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[messages-253402300799999999]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[chats-0]
|
||||
student-tests/test_pagination.py::test_cursor_timestamp_boundaries_are_valid[chats-253402300799999999]
|
||||
student-tests/test_session_expiry.py::test_session_expires_after_ttl
|
||||
student-tests/test_session_expiry.py::test_expired_sessions_are_cleaned_on_next_login
|
||||
student-tests/test_session_expiry.py::test_short_ttl_from_environment_variable
|
||||
student-tests/test_transactions.py::test_failure_after_chat_insert_rolls_back_whole_operation
|
||||
student-tests/test_transactions.py::test_pool_is_bounded_by_settings
|
||||
student-tests/test_transactions.py::test_exhausted_pool_gives_fast_503
|
||||
unit-tests/test_message_transaction.py::test_conflicting_replay_rolls_back_without_commit
|
||||
unit-tests/test_message_transaction.py::test_result_insert_failure_never_commits_message
|
||||
unit-tests/test_message_transaction.py::test_replay_returns_original_message_and_releases_transaction
|
||||
unit-tests/test_message_transaction.py::test_failed_commit_rolls_back_and_propagates_error
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/users/me-GET]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/chats/00000000-0000-0000-0000-000000000002/messages-POST]
|
||||
unit-tests/test_mr_regressions.py::test_stale_positive_cache_never_authorizes_revoked_token[/api/v1/auth/sessions/current-DELETE]
|
||||
unit-tests/test_mr_regressions.py::test_valid_cache_hit_checks_session_without_loading_user
|
||||
unit-tests/test_mr_regressions.py::test_database_failure_on_positive_cache_hit_is_503
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages--1]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-253402300800000000]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1000000000000000000000000000000]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-True]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1.5]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-1]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[messages-None]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats--1]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-253402300800000000]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1000000000000000000000000000000]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-True]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1.5]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-1]
|
||||
unit-tests/test_mr_regressions.py::test_cursor_timestamp_is_rejected_through_http[chats-None]
|
||||
unit-tests/test_mr_regressions.py::test_timestamp_boundaries_roundtrip[0]
|
||||
unit-tests/test_mr_regressions.py::test_timestamp_boundaries_roundtrip[253402300799999999]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[None]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[bad key]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[a?b]
|
||||
unit-tests/test_mr_regressions.py::test_message_key_validation[a,b]
|
||||
unit-tests/test_mr_regressions.py::test_message_normalization_and_conflict
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/health/live]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/missing]
|
||||
unit-tests/test_mr_regressions.py::test_instance_header_matches_process_on_all_responses[/api/v1/users/me]
|
||||
unit-tests/test_mr_regressions.py::test_instance_alias_changes_between_applications
|
||||
unit-tests/test_mr_regressions.py::test_sigterm_drops_readiness_and_requests_graceful_exit
|
||||
|
||||
=============================== warnings summary ===============================
|
||||
../.venv/lib/python3.12/site-packages/fastapi/testclient.py:1
|
||||
/workspace/scratch/03a740016edf/.venv/lib/python3.12/site-packages/fastapi/testclient.py:1: StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.
|
||||
from starlette.testclient import TestClient as TestClient # noqa
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
||||
226 tests collected in 0.09s
|
||||
|
||||
exit_code=0
|
||||
@@ -0,0 +1,4 @@
|
||||
$ /workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python -m pip check
|
||||
No broken requirements found.
|
||||
|
||||
exit_code=0
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"at_utc": "2026-11-01T13:10:16.405188+00:00",
|
||||
"python": "3.12.14",
|
||||
"checks": [
|
||||
{
|
||||
"name": "01_check",
|
||||
"command": [
|
||||
"/workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python",
|
||||
"scripts/check_contract.py"
|
||||
],
|
||||
"exit_code": 0,
|
||||
"elapsed_seconds": 0.042
|
||||
},
|
||||
{
|
||||
"name": "02_openapi",
|
||||
"command": [
|
||||
"/workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python",
|
||||
"scripts/validate_openapi.py"
|
||||
],
|
||||
"exit_code": 0,
|
||||
"elapsed_seconds": 0.457
|
||||
},
|
||||
{
|
||||
"name": "03_static_lab3",
|
||||
"command": [
|
||||
"/workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python",
|
||||
"scripts/check_lab3.py"
|
||||
],
|
||||
"exit_code": 0,
|
||||
"elapsed_seconds": 0.093
|
||||
},
|
||||
{
|
||||
"name": "04_unit",
|
||||
"command": [
|
||||
"/workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python",
|
||||
"-m",
|
||||
"pytest",
|
||||
"-q",
|
||||
"unit-tests",
|
||||
"-p",
|
||||
"no:cacheprovider"
|
||||
],
|
||||
"exit_code": 0,
|
||||
"elapsed_seconds": 1.257
|
||||
},
|
||||
{
|
||||
"name": "05_collection",
|
||||
"command": [
|
||||
"/workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python",
|
||||
"-m",
|
||||
"pytest",
|
||||
"--collect-only",
|
||||
"-q",
|
||||
"-p",
|
||||
"no:cacheprovider"
|
||||
],
|
||||
"exit_code": 0,
|
||||
"elapsed_seconds": 0.895
|
||||
},
|
||||
{
|
||||
"name": "06_dependencies",
|
||||
"command": [
|
||||
"/workspace/scratch/03a740016edf/mtusi2026lab3/../.venv/bin/python",
|
||||
"-m",
|
||||
"pip",
|
||||
"check"
|
||||
],
|
||||
"exit_code": 0,
|
||||
"elapsed_seconds": 0.242
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"docker_cli_available": false,
|
||||
"nginx_binary_available": false,
|
||||
"compose_nginx_postgresql_redis_experiments": "NOT_RUN",
|
||||
"reason": "This local checker does not run infrastructure; execute make lab3-evidence separately",
|
||||
"required_command_on_docker_host": "make lab3-evidence"
|
||||
}
|
||||
Reference in New Issue
Block a user