forked from mtusi2026/mtusi2026lab2
docs: fill report
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# scripts/explain.sh; date: 2026-10-29T22:07:31Z
|
||||
messages_total | messages_in_big_chat
|
||||
----------------+----------------------
|
||||
60328 | 20000
|
||||
(1 row)
|
||||
|
||||
=== 1. First page (limit=50 -> LIMIT 51), index messages_chat_created_id_idx
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.41..8.31 rows=51 width=78) (actual time=0.009..0.014 rows=51.00 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_chat_created_id_idx on messages (cost=0.41..3088.25 rows=19942 width=78) (actual time=0.008..0.012 rows=51.00 loops=1)
|
||||
Index Cond: (chat_id = '00000000-0000-4000-8000-00000000e001'::uuid)
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=4
|
||||
Planning:
|
||||
Buffers: shared hit=10
|
||||
Planning Time: 0.077 ms
|
||||
Execution Time: 0.024 ms
|
||||
(10 rows)
|
||||
|
||||
=== 2. Page in the middle by keyset cursor (after 10 000 messages)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.41..27.77 rows=51 width=78) (actual time=0.008..0.014 rows=51.00 loops=1)
|
||||
Buffers: shared hit=5
|
||||
-> Index Scan using messages_chat_created_id_idx on messages (cost=0.41..1834.26 rows=3419 width=78) (actual time=0.008..0.012 rows=51.00 loops=1)
|
||||
Index Cond: ((chat_id = '00000000-0000-4000-8000-00000000e001'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 02:46:40+00'::timestamp with time zone, 'ea1e0a08-377a-4911-aa17-221192625ad3'::uuid)))
|
||||
Index Searches: 1
|
||||
Buffers: shared hit=5
|
||||
Planning Time: 0.035 ms
|
||||
Execution Time: 0.042 ms
|
||||
(8 rows)
|
||||
|
||||
=== 3. Same middle page WITHOUT the index (dropped inside a rolled-back transaction)
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=1988.81..1988.93 rows=51 width=78) (actual time=3.462..3.467 rows=51.00 loops=1)
|
||||
Buffers: shared hit=819
|
||||
-> Sort (cost=1988.81..1997.35 rows=3419 width=78) (actual time=3.462..3.464 rows=51.00 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=819
|
||||
-> Seq Scan on messages (cost=0.00..1874.74 rows=3419 width=78) (actual time=0.498..2.888 rows=10000.00 loops=1)
|
||||
Filter: ((chat_id = '00000000-0000-4000-8000-00000000e001'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 02:46:40+00'::timestamp with time zone, 'ea1e0a08-377a-4911-aa17-221192625ad3'::uuid)))
|
||||
Rows Removed by Filter: 50328
|
||||
Buffers: shared hit=819
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.052 ms
|
||||
Execution Time: 3.492 ms
|
||||
(14 rows)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# scripts/outage-demo.sh (COMPOSE="podman compose")
|
||||
# Dependency outage demo on the live stand; date: 2026-10-29T22:09:23Z. Token is kept in a shell variable, never printed.
|
||||
baseline: GET /users/me (Bearer) -> 200
|
||||
|
||||
## podman compose stop redis
|
||||
GET /health/ready -> 503
|
||||
GET /users/me (valid Bearer) -> 503
|
||||
GET /users/me (no auth) -> 401
|
||||
POST /auth/sessions (Basic) -> 503
|
||||
body: {"error":{"code":"unavailable","message":"service temporarily unavailable","request_id":"0fc08a63-dc18-4508-a95e-7274844d13c8"}}
|
||||
## podman compose start redis -> ready; same token: GET /users/me -> 200
|
||||
|
||||
## podman compose stop postgres
|
||||
GET /health/ready -> 503
|
||||
GET /users/me (valid Bearer) -> 503
|
||||
GET /chats (valid Bearer) -> 503
|
||||
body: {"error":{"code":"unavailable","message":"service temporarily unavailable","request_id":"43f47140-394e-461e-b5bc-1863a33fc6da"}}
|
||||
## podman compose start postgres -> ready; same token: GET /users/me -> 200
|
||||
@@ -0,0 +1,26 @@
|
||||
# make test-persistence ACTION_SCRIPT=scripts/restart.sh (COMPOSE="podman compose")
|
||||
# date: 2026-10-29T22:09:51Z; podman 6.1.0, podman-compose 1.6.0
|
||||
|
||||
## containers before
|
||||
messenger_api_1 id=e8951624fe7a started=2026-10-30 01:09:02.81809688 +0300 MSK
|
||||
messenger_postgres_1 id=6aab8ebe96dd started=2026-10-30 01:09:30.742003352 +0300 MSK
|
||||
messenger_redis_1 id=7af579a966dd started=2026-10-30 01:09:28.731706375 +0300 MSK
|
||||
schema_migrations (version|dirty): 1|f
|
||||
rows users|chats|messages: 111|43|60437
|
||||
|
||||
## test
|
||||
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.
|
||||
|
||||
## containers after (same IDs, new start time = real restart, volumes kept)
|
||||
messenger_api_1 id=e8951624fe7a started=2026-10-30 01:09:54.107586909 +0300 MSK
|
||||
messenger_postgres_1 id=6aab8ebe96dd started=2026-10-30 01:09:53.97943161 +0300 MSK
|
||||
messenger_redis_1 id=7af579a966dd started=2026-10-30 01:09:54.047665509 +0300 MSK
|
||||
schema_migrations (version|dirty): 1|f
|
||||
rows users|chats|messages: 114|44|60438 (test adds 3 users, 1 chat, 1 message)
|
||||
api log after restart: "msg":"migrations applied"
|
||||
|
||||
## volumes
|
||||
messenger_pgdata
|
||||
messenger_redisdata
|
||||
@@ -0,0 +1,5 @@
|
||||
# make check && make test; date: 2026-10-29T22:09:30Z
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
python3 tests/smoke.py --base-url "http://localhost:8080"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,18 @@
|
||||
# make test-go; date: 2026-10-29T22:09:31Z; go version go1.27.1 linux/amd64
|
||||
--- PASS: TestSessionExpiry (3.10s)
|
||||
--- PASS: TestLogout (0.07s)
|
||||
--- PASS: TestWrongPassword (0.09s)
|
||||
--- PASS: TestRedisUnavailable (2.80s)
|
||||
--- PASS: TestDatabaseUnavailable (0.16s)
|
||||
--- PASS: TestInvalidJSON (0.01s)
|
||||
--- PASS: TestForeignChat (0.16s)
|
||||
--- PASS: TestEmptyMessage (0.07s)
|
||||
--- PASS: TestDuplicateUsername (0.09s)
|
||||
--- PASS: TestPaginationMultiplePages (0.08s)
|
||||
--- PASS: TestConcurrentMessages (0.50s)
|
||||
PASS
|
||||
ok messenger/internal/handler 7.128s
|
||||
--- PASS: TestRegisterUsernameRace (0.08s)
|
||||
--- PASS: TestCreateChatRollback (0.03s)
|
||||
PASS
|
||||
ok messenger/internal/repository/postgres 0.109s
|
||||
Reference in New Issue
Block a user