Обновить доказательства на коде после ревью, сверить с ними отчёт и выделить исправления базы в шаблоне PR
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
Целевая оценка (3/4/5): 4
|
||||
Трек 5, если заявлен: не заявлен
|
||||
|
||||
Что реализовано и что перенесено: перенесён минимум lab1 (формат ошибок, keyset-пагинация, UUIDv7, graceful shutdown). Пользователи, чаты, участники и сообщения хранятся в PostgreSQL 18 (pgx, миграции goose при старте, атомарное создание чата). Регистрация с паролем (Argon2id), вход через Basic, непрозрачный Bearer-токен, сессии в Valkey с AOF `appendfsync always` и абсолютным сроком, logout. Недоступность PostgreSQL или Valkey даёт 503 с причиной в логе. Стенд в compose с secrets, хук перезапуска, EXPLAIN истории. Подробности и исправления базы lab1 — в REPORT.md.
|
||||
Что реализовано и что перенесено: перенесён минимум lab1 (формат ошибок, keyset-пагинация, UUIDv7, graceful shutdown). Пользователи, чаты, участники и сообщения хранятся в PostgreSQL 18 (pgx, миграции goose при старте, атомарное создание чата). Регистрация с паролем (Argon2id), вход через Basic, непрозрачный Bearer-токен, сессии в Valkey с AOF `appendfsync always` и абсолютным сроком, logout. Недоступность PostgreSQL или Valkey даёт 503 с причиной в логе. Стенд в compose с secrets, хук перезапуска, EXPLAIN истории. Исправления базы lab1: `WithUser` перенесён из `auth` в `httpx` (иначе цикл импортов `auth ↔ user`), `server.Run` не зависит от сборки приложения, `member_ids` всегда в порядке id; in-memory хранилища удалены. Подробности — в REPORT.md.
|
||||
Команды запуска из чистого clone: `make secrets && make up`, затем `make test`, `make test-persistence ACTION_SCRIPT=scripts/restart.sh`, `make unit` (нужен Docker), `make explain`; удаление данных — `make destroy`.
|
||||
Результаты проверок и ссылка на REPORT.md: REPORT.md, раздел «Доказательства критериев»; файлы в `evidence/`.
|
||||
Ограничения / известные ошибки: один host без репликации; потеря Valkey разлогинивает всех; без TLS (lab7); описание семантики пагинации при конкурентных вставках — в REPORT.md.
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
make secrets # ./secrets: пароли PostgreSQL и Valkey и URL для API; существующие файлы не перезаписываются
|
||||
make up # docker compose up -d --build --wait: postgres и valkey healthy → api применяет миграции → healthy
|
||||
make check PYTHON=python
|
||||
make validate PYTHON=python # полная проверка OpenAPI; нужен pip install -r requirements-dev.txt
|
||||
make test PYTHON=python
|
||||
make test-persistence ACTION_SCRIPT=scripts/restart.sh PYTHON=python # на Windows: ACTION_SCRIPT=scripts/restart.cmd
|
||||
make unit # собственные тесты; нужен запущенный Docker: тесты поднимают свои PostgreSQL и Valkey
|
||||
@@ -107,7 +108,7 @@ CI. `.github/workflows/app.yml`: unit-тесты с race detector (на runner
|
||||
|
||||
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства |
|
||||
| --- | --- | --- | --- |
|
||||
| Публичный smoke | `make check`, `make test` | оба PASS | evidence/smoke.txt |
|
||||
| Публичный smoke | `make check`, `make validate`, `make test` | все PASS | evidence/smoke.txt |
|
||||
| Минимум lab1 с переходом на Bearer | `make test` (сценарий lab2), `TestProtectedRoutesAcceptOnlyBearer` и остальные HTTP-тесты `internal/app` | PASS | evidence/smoke.txt, evidence/tests.txt |
|
||||
| Данные и действующие сессии переживают рестарт API и хранилищ без удаления volumes | `make test-persistence ACTION_SCRIPT=scripts/restart.cmd` (`restart.sh`: `docker compose stop` + `up -d --wait`) | PASS тем же токеном; `StartedAt` всех трёх контейнеров изменился | evidence/persistence.txt |
|
||||
| PostgreSQL: пользователи, чаты, участники, сообщения; PK/FK, UNIQUE username; миграции с нуля | `make destroy && make up`, `\dt`, `\di` | `schema ready applied_migrations=[1]`, 4 таблицы и индексы | evidence/bootstrap.txt |
|
||||
@@ -120,7 +121,7 @@ CI. `.github/workflows/app.yml`: unit-тесты с race detector (на runner
|
||||
| Valkey реально используется для сессий с TTL и persistence | `CONFIG GET`; остановка/запуск Valkey с тем же токеном | `appendonly yes`, `appendfsync always`, `noeviction`; после рестарта Valkey токен работает | evidence/bootstrap.txt, evidence/dependency-failures.txt |
|
||||
| Параметризованные запросы, ограниченный пул и таймауты | код `store/postgres.go` (только `$n`), `TestPoolAppliesLimitsAndTimeouts`, `TestTimeoutBoundsTheRequestContext` | `MaxConns=10`, `statement_timeout=5s`, connect 1 с, дедлайн запроса | evidence/tests.txt |
|
||||
| Гонка регистрации одного username | `TestConcurrentRegistrationOfOneUsernameHasOneWinner` | 10 параллельных попыток: ровно 1 успех, 9 × 409, одна строка | evidence/tests.txt |
|
||||
| Индекс истории обоснован EXPLAIN на ≥10 000 сообщений, без полного scan на страницу | `make explain` (102 000 сообщений, 12 000 в целевом чате, транзакция с ROLLBACK) | `Index Scan using messages_pkey`, `Index Cond (chat_id = … AND id > …)`, 51 строка; 51 буфер на первой странице и 6 на глубокой, 0.05–0.1 мс; OFFSET той же страницы — сортировка 10 052 строк, 495 буферов, 4.6 мс | evidence/explain-history.txt |
|
||||
| Индекс истории обоснован EXPLAIN на ≥10 000 сообщений, без полного scan на страницу | `make explain` (102 000 сообщений, 12 000 в целевом чате, транзакция с ROLLBACK) | `Index Scan using messages_pkey`, `Index Cond (chat_id = … AND id > …)`, 51 строка; 51 буфер на первой странице и 6 на глубокой, 0.05–0.1 мс; OFFSET той же страницы — сортировка 10 052 строк, 495 буферов, 6.5 мс | evidence/explain-history.txt |
|
||||
| Автопроверки expiry, logout, неверного пароля, недоступности Redis/БД | `TestSessionExpiresAfterTTL`, `TestLogoutRevokesOnlyTheCurrentToken`, `TestLoginFailuresAreUniformBasicChallenges`, `TestValkeyOutageAnswers503`, `TestPostgresOutageAnswers503`, `TestHungPostgresAnswers503WithinTheRequestTimeout` | все PASS; при отказе — 503, никогда 200 или 401 | evidence/tests.txt, evidence/dependency-failures.txt |
|
||||
| Гонки отправки сообщений | `make concurrency` | 100/100 созданы, перечислены и уникальны, порядок по id | evidence/concurrency.json |
|
||||
| Выбранный трек 5 | не заявлен | — | — |
|
||||
@@ -132,8 +133,8 @@ CI. `.github/workflows/app.yml`: unit-тесты с race detector (на runner
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||
| --- | --- | --- | --- |
|
||||
| Полный рестарт: `docker compose stop` и `up -d --wait` (хук persistence) | те же данные и тот же токен | PASS, все три процесса перезапущены | весь тест с хуком ~15 с; потерь нет |
|
||||
| `docker compose stop valkey` | 503 на защищённые запросы и вход, ready 503, регистрация работает | 503 за 1.2 с (дозвон ограничен 1 с; без ограничения поиск имени остановленного контейнера в DNS Docker не укладывается в дедлайн запроса 5 с), `POST /users` 201, в логе `cause: dial tcp: lookup valkey: i/o timeout` | после `start` тот же токен 200: сессии восстановлены из AOF |
|
||||
| `docker compose stop postgres` | 503 на операции с данными, ready 503 | первый запрос — 503 за 0.2 с (соединение из пула уже разорвано), следующие — за 1.2 с (новое соединение ждёт поиск имени, ограниченный 1 с); в логе причина подключения | после `start` 200 без перезапуска API: пул переподключается |
|
||||
| `docker compose stop valkey` | 503 на защищённые запросы и вход, ready 503, регистрация работает | 503 за 1.0 с (дозвон ограничен 1 с; без ограничения поиск имени остановленного контейнера в DNS Docker не укладывается в дедлайн запроса 5 с), `POST /users` 201, в логе `cause: dial tcp: lookup valkey: i/o timeout` | после `start` тот же токен 200: сессии восстановлены из AOF |
|
||||
| `docker compose stop postgres` | 503 на операции с данными, ready 503 | первый запрос — 503 за 0.02 с (PostgreSQL при остановке закрыл соединения пула, в логе `57P01`), следующие — за 1.0 с (новое соединение ждёт поиск имени, ограниченный 1 с, в логе `hostname resolving error … i/o timeout`) | после `start` 200 без перезапуска API: пул переподключается |
|
||||
| PostgreSQL на паузе (`docker pause`, тест) | запрос не висит дольше дедлайна | 503 при дедлайне 300 мс, ready 503 | — |
|
||||
| `SESSION_TTL_SECONDS=2` | сессия истекает | 200 сразу, 401 Bearer через 3 с | — |
|
||||
| Ввод, который PostgreSQL не может хранить: NUL в `display_name`/`title`/`text`, NUL или не-UTF-8 в Basic username | 400 / 401, не 500 | 400 и 401 (проверка в приложении) | — |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Bootstrap from empty volumes: make destroy && make secrets up
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
$ make up
|
||||
@@ -9,10 +9,10 @@ Volume mtusi2026lab2_valkeydata Created
|
||||
Container mtusi2026lab2-valkey-1 Created
|
||||
Container mtusi2026lab2-postgres-1 Created
|
||||
Container mtusi-messenger-lab2 Created
|
||||
Container mtusi2026lab2-postgres-1 Started
|
||||
Container mtusi2026lab2-valkey-1 Started
|
||||
Container mtusi2026lab2-postgres-1 Healthy
|
||||
Container mtusi2026lab2-postgres-1 Started
|
||||
Container mtusi2026lab2-valkey-1 Healthy
|
||||
Container mtusi2026lab2-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab2 Started
|
||||
Container mtusi2026lab2-postgres-1 Healthy
|
||||
Container mtusi2026lab2-valkey-1 Healthy
|
||||
@@ -21,12 +21,12 @@ Container mtusi-messenger-lab2 Healthy
|
||||
$ docker compose ps
|
||||
SERVICE IMAGE STATUS PORTS
|
||||
api mtusi-messenger:lab2 Up 6 seconds (healthy) 127.0.0.1:8080->8080/tcp
|
||||
postgres postgres:18.6-alpine3.24@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873 Up 11 seconds (healthy) 5432/tcp
|
||||
valkey valkey/valkey:9.1.2-alpine3.24@sha256:48332870af354a799964c0012ae1194a0bf2bf894eb508f945810596dc2d8d11 Up 11 seconds (healthy) 6379/tcp
|
||||
postgres postgres:18.6-alpine3.24@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873 Up 12 seconds (healthy) 5432/tcp
|
||||
valkey valkey/valkey:9.1.2-alpine3.24@sha256:48332870af354a799964c0012ae1194a0bf2bf894eb508f945810596dc2d8d11 Up 12 seconds (healthy) 6379/tcp
|
||||
|
||||
$ docker compose logs api | grep -E "schema ready|starting"
|
||||
{"time":"2026-10-06T13:00:02.672577874Z","level":"INFO","msg":"schema ready","applied_migrations":[1]}
|
||||
{"time":"2026-10-06T13:00:02.689453662Z","level":"INFO","msg":"starting","env":"lab","addr":"0.0.0.0:8080","shutdown_timeout":"8s","session_ttl":"1h0m0s"}
|
||||
{"time":"2026-10-21T12:10:07.644733332Z","level":"INFO","msg":"schema ready","applied_migrations":[1]}
|
||||
{"time":"2026-10-21T12:10:07.674799548Z","level":"INFO","msg":"starting","env":"lab","addr":"0.0.0.0:8080","shutdown_timeout":"8s","session_ttl":"1h0m0s"}
|
||||
|
||||
$ psql \dt and \di (schema created by the migration)
|
||||
List of tables
|
||||
@@ -60,4 +60,4 @@ maxmemory 268435456
|
||||
maxmemory-policy noeviction
|
||||
|
||||
$ second start: migrations are a no-op
|
||||
{"time":"2026-10-06T13:00:12.891361865Z","level":"INFO","msg":"schema ready","applied_migrations":[]}
|
||||
{"time":"2026-10-21T12:10:18.658799511Z","level":"INFO","msg":"schema ready","applied_migrations":[]}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"base_url": "http://localhost:8080",
|
||||
"started_at": "2026-10-06T13:01:23.3690872Z",
|
||||
"started_at": "2026-10-21T12:11:30.6825994Z",
|
||||
"clients": 10,
|
||||
"per_client": 10,
|
||||
"expected_messages": 100,
|
||||
@@ -11,6 +11,6 @@
|
||||
"created_but_not_listed": 0,
|
||||
"history_ordered_by_id": true,
|
||||
"pages_read": 1,
|
||||
"elapsed_seconds": 0.1081132,
|
||||
"elapsed_seconds": 0.0793356,
|
||||
"passed": true
|
||||
}
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
# Dependency outages on the stand (request deadline 5 s, dial/connect 1 s)
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# Dependency outages on the stand (request deadline 5 s, dial/connect and host lookup 1 s, readiness budget 1 s)
|
||||
# date: 2026-10-21T12:14:15Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
baseline GET /users/me: 200
|
||||
|
||||
$ docker compose stop valkey
|
||||
{"error":{"code":"unavailable","message":"session store unavailable","request_id":"6dc8e40f8ed60f3d3e32c65da449744e"}}
|
||||
client sees only a safe message:
|
||||
{"error":{"code":"unavailable","message":"session store unavailable","request_id":"dcf58dc8b038da34fbffaa398be2ae19"}}
|
||||
|
||||
-> 503 in 1.223578s
|
||||
POST /auth/sessions: 503 in 1.235624s
|
||||
POST /users (PostgreSQL only): 201
|
||||
{"error":{"code":"unavailable","message":"valkey is unavailable","request_id":"99a17ea0c0423c3142e004f27e09f739"}}
|
||||
|
||||
-> 503
|
||||
api log:
|
||||
{"time":"2026-10-06T13:01:03.639113985Z","level":"ERROR","msg":"request failed","request_id":"99a17ea0c0423c3142e004f27e09f739","error":"valkey is unavailable","cause":"dial tcp: lookup valkey: i/o timeout"}
|
||||
GET /users/me: 503 in 1.029945s, request_id 409bc8d095cd5c0aa8bff3a5a6103336
|
||||
POST /auth/sessions: 503 in 1.067333s, request_id b80c3cf8d77205be7d145d366e3eba7c
|
||||
POST /users (PostgreSQL only): 201
|
||||
GET /health/ready: 503
|
||||
api log, by request_id:
|
||||
409bc8d095cd5c0aa8bff3a5a6103336: session store unavailable <- dial tcp: lookup valkey: i/o timeout
|
||||
b80c3cf8d77205be7d145d366e3eba7c: session store unavailable <- dial tcp: lookup valkey: i/o timeout
|
||||
after docker compose start valkey, same token: 200 (session survived via AOF)
|
||||
|
||||
$ docker compose stop postgres
|
||||
{"error":{"code":"unavailable","message":"database unavailable","request_id":"eeb05d0a51641fb655e0f516f3704b67"}}
|
||||
first request: the pooled connection was closed by the server on shutdown
|
||||
GET /chats: 503 in 0.022848s, request_id 484577a2014613ccc2cc0af7a110147b
|
||||
next requests: a new connection waits for the host lookup, bounded by 1 s
|
||||
GET /chats: 503 in 1.018873s, request_id 68b40ce6917aac8cae5a3a06f53f0d3f
|
||||
GET /chats: 503 in 1.019858s, request_id d085caa2d09226ceebe5b9aad55cbc2b
|
||||
GET /chats: 503 in 1.016325s, request_id e646903eb0912bf1c2b75a3dee3c302e
|
||||
client sees only a safe message:
|
||||
{"error":{"code":"unavailable","message":"database unavailable","request_id":"0dc9f28ccba988caededb452faec06ac"}}
|
||||
|
||||
-> 503 in 0.230062s
|
||||
{"error":{"code":"unavailable","message":"postgres is unavailable","request_id":"1df2b60f6d15c835ed4549601fba01d5"}}
|
||||
|
||||
-> 503
|
||||
api log:
|
||||
{"time":"2026-10-06T13:01:10.362999264Z","level":"ERROR","msg":"request failed","request_id":"1df2b60f6d15c835ed4549601fba01d5","error":"postgres is unavailable","cause":"failed to connect to `user=messenger database=messenger`: hostname resolving error: lookup postgres on 127.0.0.11:53: dial udp 127.0.0.11:53: i/o timeout"}
|
||||
GET /health/ready: 503
|
||||
api log, by request_id:
|
||||
484577a2014613ccc2cc0af7a110147b: select chats: database unavailable <- FATAL: terminating connection due to administrator command (SQLSTATE 57P01)
|
||||
68b40ce6917aac8cae5a3a06f53f0d3f: select chats: database unavailable <- failed to connect to `user=messenger database=messenger`: hostname resolving error: lookup postgres on 127.0.0.11:53: dial udp 127.0.0.11:53: i/o timeout
|
||||
d085caa2d09226ceebe5b9aad55cbc2b: select chats: database unavailable <- failed to connect to `user=messenger database=messenger`: hostname resolving error: lookup postgres on 127.0.0.11:53: dial udp 127.0.0.11:53: i/o timeout
|
||||
e646903eb0912bf1c2b75a3dee3c302e: select chats: database unavailable <- failed to connect to `user=messenger database=messenger`: hostname resolving error: lookup postgres on 127.0.0.11:53: dial udp 127.0.0.11:53: i/o timeout
|
||||
after docker compose start postgres: 200
|
||||
GET /health/ready: 200
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
# Session expiry with SESSION_TTL_SECONDS=2
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
api SESSION_TTL_SECONDS=2
|
||||
@@ -7,6 +7,6 @@ GET /users/me right after login: 200
|
||||
GET /users/me 3 s later:
|
||||
HTTP/1.1 401 Unauthorized
|
||||
Www-Authenticate: Bearer realm="messenger"
|
||||
{"error":{"code":"unauthorized","message":"a valid bearer token is required","request_id":"30f35aed484df88d7c07e7ee17e2a92a"}}
|
||||
{"error":{"code":"unauthorized","message":"a valid bearer token is required","request_id":"e191d8f08a51fced88868d6fac0d8674"}}
|
||||
|
||||
api restored with SESSION_TTL_SECONDS=3600
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# EXPLAIN (ANALYZE, BUFFERS) of the history query: make explain
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
big_chat_messages | all_messages
|
||||
@@ -11,51 +11,51 @@
|
||||
== First page: no cursor, limit 50 (+1 row that tells whether a next page exists)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..23.86 rows=51 width=67) (actual time=0.020..0.077 rows=51.00 loops=1)
|
||||
Limit (cost=0.42..23.92 rows=51 width=67) (actual time=0.027..0.060 rows=51.00 loops=1)
|
||||
Buffers: shared hit=51
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..5535.89 rows=12045 width=67) (actual time=0.018..0.072 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid) AND (id > '00000000-0000-0000-0000-000000000000'::uuid))
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..5526.02 rows=11988 width=67) (actual time=0.026..0.056 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid) AND (id > '00000000-0000-0000-0000-000000000000'::uuid))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=51
|
||||
Planning:
|
||||
Buffers: shared hit=17
|
||||
Planning Time: 0.327 ms
|
||||
Execution Time: 0.101 ms
|
||||
Planning Time: 0.211 ms
|
||||
Execution Time: 0.097 ms
|
||||
(10 rows)
|
||||
|
||||
|
||||
== Deep page: cursor after the 10 001st message of the chat
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.42..185.00 rows=51 width=67) (actual time=0.021..0.033 rows=51.00 loops=1)
|
||||
Limit (cost=0.42..184.60 rows=51 width=67) (actual time=0.018..0.030 rows=51.00 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..655.49 rows=181 width=67) (actual time=0.020..0.029 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid) AND (id > '01a1114d-e03e-797e-bdd0-3cb5b8cb3079'::uuid))
|
||||
-> Index Scan using messages_pkey on messages (cost=0.42..650.48 rows=180 width=67) (actual time=0.018..0.026 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid) AND (id > '01a15e5f-9557-7527-8fb0-c493cb1229d4'::uuid))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.093 ms
|
||||
Execution Time: 0.050 ms
|
||||
Planning Time: 0.071 ms
|
||||
Execution Time: 0.047 ms
|
||||
(8 rows)
|
||||
|
||||
|
||||
== For contrast, OFFSET pagination of the same page reads every skipped row
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=2837.94..2838.07 rows=51 width=67) (actual time=4.491..4.496 rows=51.00 loops=1)
|
||||
Limit (cost=2832.42..2832.54 rows=51 width=67) (actual time=6.369..6.376 rows=51.00 loops=1)
|
||||
Buffers: shared hit=495
|
||||
-> Sort (cost=2812.94..2843.06 rows=12047 width=67) (actual time=3.874..4.232 rows=10052.00 loops=1)
|
||||
-> Sort (cost=2807.41..2837.39 rows=11989 width=67) (actual time=5.728..6.109 rows=10052.00 loops=1)
|
||||
Sort Key: id
|
||||
Sort Method: quicksort Memory: 1978kB
|
||||
Buffers: shared hit=495
|
||||
-> Bitmap Heap Scan on messages (cost=585.78..1996.37 rows=12047 width=67) (actual time=0.422..1.796 rows=12000.00 loops=1)
|
||||
Recheck Cond: (chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid)
|
||||
-> Bitmap Heap Scan on messages (cost=585.33..1995.19 rows=11989 width=67) (actual time=0.717..2.712 rows=12000.00 loops=1)
|
||||
Recheck Cond: (chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid)
|
||||
Heap Blocks: exact=363
|
||||
Buffers: shared hit=495
|
||||
-> Bitmap Index Scan on messages_pkey (cost=0.00..582.77 rows=12047 width=0) (actual time=0.386..0.386 rows=12000.00 loops=1)
|
||||
Index Cond: (chat_id = '01a1114d-de5d-7f2e-8176-990d37b9797e'::uuid)
|
||||
-> Bitmap Index Scan on messages_pkey (cost=0.00..582.34 rows=11989 width=0) (actual time=0.672..0.673 rows=12000.00 loops=1)
|
||||
Index Cond: (chat_id = '01a15e5f-93aa-7f38-9ff3-684f0d6ded77'::uuid)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=132
|
||||
Planning Time: 0.043 ms
|
||||
Execution Time: 4.629 ms
|
||||
Planning Time: 0.041 ms
|
||||
Execution Time: 6.524 ms
|
||||
(16 rows)
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# Persistence: make test-persistence ACTION_SCRIPT=scripts/restart.cmd (scripts/restart.sh on Linux)
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
== containers before
|
||||
/mtusi-messenger-lab2 started=2026-10-06T13:00:12.720916013Z status=running
|
||||
/mtusi2026lab2-postgres-1 started=2026-10-06T12:59:56.582818179Z status=running
|
||||
/mtusi2026lab2-valkey-1 started=2026-10-06T12:59:56.579702461Z status=running
|
||||
/mtusi-messenger-lab2 started=2026-10-21T12:10:18.43319842Z status=running
|
||||
/mtusi2026lab2-postgres-1 started=2026-10-21T12:10:01.058712538Z status=running
|
||||
/mtusi2026lab2-valkey-1 started=2026-10-21T12:10:01.069796526Z status=running
|
||||
|
||||
$ make test-persistence ACTION_SCRIPT=scripts/restart.cmd PYTHON=python
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
== containers after (every StartedAt changed: all three processes were restarted, volumes kept)
|
||||
/mtusi-messenger-lab2 started=2026-10-06T13:00:28.600983618Z status=running
|
||||
/mtusi2026lab2-postgres-1 started=2026-10-06T13:00:22.758610805Z status=running
|
||||
/mtusi2026lab2-valkey-1 started=2026-10-06T13:00:22.751213945Z status=running
|
||||
/mtusi-messenger-lab2 started=2026-10-21T12:10:34.891259448Z status=running
|
||||
/mtusi2026lab2-postgres-1 started=2026-10-21T12:10:28.977896441Z status=running
|
||||
/mtusi2026lab2-valkey-1 started=2026-10-21T12:10:28.995400471Z status=running
|
||||
|
||||
+5
-2
@@ -1,9 +1,12 @@
|
||||
# Public checks: make check, make test
|
||||
# date: 2026-10-06T12:59:03Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# Public checks: make check, make validate, make test
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
|
||||
$ make check PYTHON=python
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
|
||||
$ make validate PYTHON=python # after pip install -r requirements-dev.txt
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
|
||||
$ make test PYTHON=python
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
+45
-44
@@ -1,49 +1,50 @@
|
||||
# Automated tests against real PostgreSQL and Valkey (testcontainers): go test -race -v
|
||||
# date: 2026-10-06T13:02:19Z, commit: 949622e (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1
|
||||
# full suite: make unit (go test -race -count=1 ./...), 16 packages ok
|
||||
# date: 2026-10-21T12:09:10Z, commit: 7aa86d3 (branch solution/bpi2301-bakulin)
|
||||
# host: Windows 11, Docker Desktop 28.5.1 (4 CPU, 4111327232 bytes RAM), Go go1.27.1, Python 3.13.1
|
||||
# full suite: make unit (go test -race -count=1 ./...), 16 packages ok, 0 failed
|
||||
|
||||
--- PASS: TestRegisterUserShapeAndConflicts (0.31s)
|
||||
--- PASS: TestConcurrentSendsProduceExactlyUniqueMessages (1.92s)
|
||||
--- PASS: TestLoginReturnsBearerSession (0.35s)
|
||||
--- PASS: TestLoginFailuresAreUniformBasicChallenges (0.43s)
|
||||
--- PASS: TestLoginAcceptsColonAndUnicodePasswords (0.14s)
|
||||
--- PASS: TestProtectedRoutesAcceptOnlyBearer (0.26s)
|
||||
--- PASS: TestLogoutRevokesOnlyTheCurrentToken (0.19s)
|
||||
--- PASS: TestSessionExpiresAfterTTL (1.35s)
|
||||
--- PASS: TestValkeyOutageAnswers503 (3.98s)
|
||||
--- PASS: TestPostgresOutageAnswers503 (4.06s)
|
||||
--- PASS: TestHungPostgresAnswers503WithinTheRequestTimeout (5.45s)
|
||||
ok messenger/internal/app 29.152s
|
||||
--- PASS: TestLoginIssuesOpaqueTokenBackedByStoredSession (0.20s)
|
||||
--- PASS: TestLoginWithBadCredentialsCreatesNoSession (0.30s)
|
||||
--- PASS: TestAuthenticateResolvesTheOwner (0.27s)
|
||||
--- PASS: TestLogoutRevokesOnlyThatSession (0.36s)
|
||||
--- PASS: TestSessionExpiresAfterTTL (1.34s)
|
||||
ok messenger/internal/auth 13.245s
|
||||
--- PASS: TestCreateRollsBackWhenMemberInsertFails (0.08s)
|
||||
--- PASS: TestConcurrentAppendsKeepEveryMessage (0.21s)
|
||||
ok messenger/internal/chat/store 9.320s
|
||||
--- PASS: TestKindOfDefaultsToInternal (0.00s)
|
||||
ok messenger/internal/platform/apperr 1.572s
|
||||
--- PASS: TestDefaults (0.02s)
|
||||
--- PASS: TestSecretFilesAreRequiredAndNeverEchoed (0.07s)
|
||||
--- PASS: TestOverrides (0.02s)
|
||||
--- PASS: TestInvalidValuesAreReported (0.09s)
|
||||
ok messenger/internal/platform/config 1.801s
|
||||
--- PASS: TestUnavailableCauseIsLoggedButNotReturned (0.06s)
|
||||
--- PASS: TestRegisterUserShapeAndConflicts (0.18s)
|
||||
--- PASS: TestConcurrentSendsProduceExactlyUniqueMessages (0.97s)
|
||||
--- PASS: TestLoginReturnsBearerSession (0.14s)
|
||||
--- PASS: TestLoginFailuresAreUniformBasicChallenges (0.26s)
|
||||
--- PASS: TestLoginAcceptsColonAndUnicodePasswords (0.08s)
|
||||
--- PASS: TestProtectedRoutesAcceptOnlyBearer (0.17s)
|
||||
--- PASS: TestLogoutRevokesOnlyTheCurrentToken (0.16s)
|
||||
--- PASS: TestSessionExpiresAfterTTL (1.29s)
|
||||
--- PASS: TestValkeyOutageAnswers503 (3.75s)
|
||||
--- PASS: TestPostgresOutageAnswers503 (3.83s)
|
||||
--- PASS: TestHungPostgresAnswers503WithinTheRequestTimeout (5.34s)
|
||||
ok messenger/internal/app 30.321s
|
||||
--- PASS: TestLoginIssuesOpaqueTokenBackedByStoredSession (0.11s)
|
||||
--- PASS: TestLoginWithBadCredentialsCreatesNoSession (0.21s)
|
||||
--- PASS: TestAuthenticateResolvesTheOwner (0.15s)
|
||||
--- PASS: TestLogoutRevokesOnlyThatSession (0.14s)
|
||||
--- PASS: TestSessionExpiresAfterTTL (1.19s)
|
||||
ok messenger/internal/auth 15.854s
|
||||
ok messenger/internal/chat 12.655s [no tests to run]
|
||||
--- PASS: TestConcurrentAppendsKeepEveryMessage (0.17s)
|
||||
ok messenger/internal/chat/store 13.188s
|
||||
ok messenger/internal/platform/apperr 1.627s [no tests to run]
|
||||
ok messenger/internal/platform/config 1.627s [no tests to run]
|
||||
--- PASS: TestUnavailableCauseIsLoggedButNotReturned (0.03s)
|
||||
--- PASS: TestTimeoutBoundsTheRequestContext (0.05s)
|
||||
ok messenger/internal/platform/httpx 5.748s
|
||||
--- PASS: TestMigrateIsRepeatable (0.01s)
|
||||
ok messenger/internal/platform/httpx 2.942s
|
||||
ok messenger/internal/platform/ident 1.656s [no tests to run]
|
||||
ok messenger/internal/platform/pagination 1.778s [no tests to run]
|
||||
ok messenger/internal/platform/password 1.641s [no tests to run]
|
||||
--- PASS: TestMigrateIsRepeatable (0.02s)
|
||||
--- PASS: TestPoolAppliesLimitsAndTimeouts (0.01s)
|
||||
--- PASS: TestClassifyMarksUnreachableDatabaseAsUnavailable (0.00s)
|
||||
--- PASS: TestClassifyRealConnectFailure (0.00s)
|
||||
ok messenger/internal/platform/postgres 9.271s
|
||||
--- PASS: TestRegisterStoresUserWithPasswordHash (0.11s)
|
||||
--- PASS: TestRegisterRejectsInvalidInputAndStoresNothing (0.02s)
|
||||
--- PASS: TestRegisterReportsDuplicateAsConflict (0.21s)
|
||||
--- PASS: TestConcurrentRegistrationOfOneUsernameHasOneWinner (0.30s)
|
||||
--- PASS: TestExistingIDsReturnsOnlyRegistered (0.27s)
|
||||
--- PASS: TestAuthenticateChecksPassword (0.16s)
|
||||
--- PASS: TestAuthenticateFailuresLookTheSame (0.39s)
|
||||
ok messenger/internal/user 10.562s
|
||||
--- PASS: TestClassifyRealConnectFailure (0.01s)
|
||||
ok messenger/internal/platform/postgres 9.771s
|
||||
ok messenger/internal/platform/valkey 2.782s [no tests to run]
|
||||
ok messenger/internal/server 3.156s [no tests to run]
|
||||
ok messenger/internal/testenv 2.767s [no tests to run]
|
||||
--- PASS: TestRegisterStoresUserWithPasswordHash (0.08s)
|
||||
--- PASS: TestRegisterRejectsInvalidInputAndStoresNothing (0.01s)
|
||||
--- PASS: TestRegisterReportsDuplicateAsConflict (0.14s)
|
||||
--- PASS: TestConcurrentRegistrationOfOneUsernameHasOneWinner (0.24s)
|
||||
--- PASS: TestExistingIDsReturnsOnlyRegistered (0.16s)
|
||||
--- PASS: TestAuthenticateChecksPassword (0.14s)
|
||||
--- PASS: TestAuthenticateFailuresLookTheSame (0.32s)
|
||||
ok messenger/internal/user 12.868s
|
||||
|
||||
Reference in New Issue
Block a user