выполнение лр2 на 4
Skeleton contracts / contracts (pull_request) Failing after 37s

This commit is contained in:
Ilya
2026-10-09 12:44:56 +03:00
parent e914e384fc
commit 13fa1852cb
30 changed files with 585 additions and 238 deletions
+28 -28
View File
@@ -1,36 +1,36 @@
# EXPLAIN evidence for message history pagination
# date: 2026-10-07T14:17:55Z commit: 65003b6
# date: 2026-10-09T09:35:29Z commit: e914e38
# postgres: 17.6
# messages total: 70112, in measured chat: 20000
# messages total: 70006, in measured chat: 20000
PREPARE
PREPARE
=== 1. WITH index messages_chat_history_idx: first page (limit 50 + 1) ===
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.42..8.60 rows=51 width=78) (actual time=0.014..0.019 rows=51 loops=1)
Limit (cost=0.42..7.37 rows=51 width=78) (actual time=0.017..0.022 rows=51 loops=1)
Buffers: shared hit=4
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..3227.11 rows=20122 width=78) (actual time=0.013..0.015 rows=51 loops=1)
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..2712.54 rows=19884 width=78) (actual time=0.016..0.019 rows=51 loops=1)
Index Cond: (chat_id = '00000000-0000-4000-8000-000000000100'::uuid)
Buffers: shared hit=4
Planning:
Buffers: shared hit=106
Planning Time: 0.272 ms
Execution Time: 0.031 ms
Planning Time: 0.287 ms
Execution Time: 0.035 ms
(9 rows)
=== 2. WITH index: deep page, cursor after message #15000 of 20000 ===
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.42..55.74 rows=51 width=78) (actual time=0.012..0.017 rows=51 loops=1)
Limit (cost=0.42..54.50 rows=51 width=78) (actual time=0.016..0.021 rows=51 loops=1)
Buffers: shared hit=4
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..1590.70 rows=1466 width=78) (actual time=0.012..0.014 rows=51 loops=1)
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..1492.33 rows=1407 width=78) (actual time=0.016..0.019 rows=51 loops=1)
Index Cond: ((chat_id = '00000000-0000-4000-8000-000000000100'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 04:10:00+00'::timestamp with time zone, '47ba2a9c-d238-4807-2008-6ea72cb0f95c'::uuid)))
Buffers: shared hit=4
Planning:
Buffers: shared hit=42
Planning Time: 0.276 ms
Execution Time: 0.035 ms
Planning Time: 0.286 ms
Execution Time: 0.039 ms
(9 rows)
BEGIN
@@ -38,37 +38,37 @@ DROP INDEX
=== 3. WITHOUT index: first page ===
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------
Limit (cost=2487.71..2487.84 rows=51 width=78) (actual time=4.235..4.239 rows=51 loops=1)
Buffers: shared hit=946
-> Sort (cost=2487.71..2538.02 rows=20122 width=78) (actual time=4.234..4.236 rows=51 loops=1)
Limit (cost=2472.45..2472.58 rows=51 width=78) (actual time=4.141..4.146 rows=51 loops=1)
Buffers: shared hit=940
-> Sort (cost=2472.45..2522.16 rows=19884 width=78) (actual time=4.141..4.143 rows=51 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 31kB
Buffers: shared hit=946
-> Seq Scan on messages (cost=0.00..1816.40 rows=20122 width=78) (actual time=0.011..3.325 rows=20000 loops=1)
Buffers: shared hit=940
-> Seq Scan on messages (cost=0.00..1809.08 rows=19884 width=78) (actual time=0.004..3.157 rows=20000 loops=1)
Filter: (chat_id = '00000000-0000-4000-8000-000000000100'::uuid)
Rows Removed by Filter: 50112
Buffers: shared hit=940
Rows Removed by Filter: 50006
Buffers: shared hit=934
Planning:
Buffers: shared hit=16
Planning Time: 0.098 ms
Execution Time: 4.249 ms
Planning Time: 0.091 ms
Execution Time: 4.167 ms
(14 rows)
=== 4. WITHOUT index: deep page ===
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=2215.87..2216.00 rows=51 width=78) (actual time=3.117..3.121 rows=51 loops=1)
Buffers: shared hit=940
-> Sort (cost=2215.87..2219.53 rows=1466 width=78) (actual time=3.116..3.118 rows=51 loops=1)
Limit (cost=2206.05..2206.17 rows=51 width=78) (actual time=2.882..2.886 rows=51 loops=1)
Buffers: shared hit=934
-> Sort (cost=2206.05..2209.56 rows=1407 width=78) (actual time=2.881..2.883 rows=51 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 31kB
Buffers: shared hit=940
-> Seq Scan on messages (cost=0.00..2166.96 rows=1466 width=78) (actual time=0.605..2.853 rows=5000 loops=1)
Buffers: shared hit=934
-> Seq Scan on messages (cost=0.00..2159.11 rows=1407 width=78) (actual time=0.628..2.654 rows=5000 loops=1)
Filter: ((chat_id = '00000000-0000-4000-8000-000000000100'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 04:10:00+00'::timestamp with time zone, '47ba2a9c-d238-4807-2008-6ea72cb0f95c'::uuid)))
Rows Removed by Filter: 65112
Buffers: shared hit=940
Planning Time: 0.069 ms
Execution Time: 3.133 ms
Rows Removed by Filter: 65006
Buffers: shared hit=934
Planning Time: 0.059 ms
Execution Time: 2.898 ms
(12 rows)
ROLLBACK
+3 -3
View File
@@ -1,6 +1,6 @@
# Fresh volume: migrations from scratch + public smoke
# date: 2026-10-07T14:18:43Z
$ APP_PORT=18090 docker compose -p lab2-clean up -d --wait
# date: 2026-10-08T21:04:06Z
$ docker compose -p lab2-clean up -d --wait
Container lab2-clean-api-1 Created
Container lab2-clean-api-1 Healthy
Container lab2-clean-migrate-1 Created
@@ -14,7 +14,7 @@ $ APP_PORT=18090 docker compose -p lab2-clean up -d --wait
$ docker compose -p lab2-clean logs migrate
INFO migrate: applying 0001_init
INFO migrate: migrations up to date: 1 applied now, 0 before
$ make test BASE_URL=http://localhost:18090
$ make test
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
$ docker compose -p lab2-clean run --rm migrate # second run
INFO migrate: migrations up to date: 0 applied now, 1 before
+7 -7
View File
@@ -1,9 +1,9 @@
# Persistence: API + PostgreSQL + Valkey restarted, volume kept, same token
# date: 2026-10-07T14:19:03Z
# date: 2026-10-08T21:04:36Z
## containers BEFORE
api 2026-10-07T14:18:25.262485419Z running restarts=0
postgres 2026-10-07T14:18:22.306271835Z running restarts=0
valkey 2026-10-07T14:18:21.888265501Z running restarts=0
api 2026-10-08T21:04:21.524285049Z running restarts=0
postgres 2026-10-08T21:04:18.312105839Z running restarts=0
valkey 2026-10-08T21:04:18.312749256Z running restarts=0
volume messenger-lab2_pgdata
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
@@ -11,9 +11,9 @@ Executing explicit persistence hook; hook output suppressed to avoid leaking sec
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
## containers AFTER (StartedAt changed for all three)
api 2026-10-07T14:19:08.428103009Z running restarts=0
postgres 2026-10-07T14:19:05.240867716Z running restarts=0
valkey 2026-10-07T14:19:05.240850591Z running restarts=0
api 2026-10-08T21:04:41.315237919Z running restarts=0
postgres 2026-10-08T21:04:38.136785584Z running restarts=0
valkey 2026-10-08T21:04:38.136211584Z running restarts=0
volume messenger-lab2_pgdata
$ docker compose logs migrate | tail -1
+1 -1
View File
@@ -1,4 +1,4 @@
# date: 2026-10-07T14:19:14Z
# date: 2026-10-08T21:04:36Z
$ make check
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ make test
+4 -5
View File
@@ -1,6 +1,5 @@
# date: 2026-10-07T14:19:14Z
# date: 2026-10-08T21:04:47Z
$ make test-student
BASE_URL="http://localhost:18080" sh student-tests/run_all.sh
== own_tests.py
ok - malformed JSON -> 400 invalid_request
ok - foreign chat access -> 404 (no leak)
@@ -27,18 +26,18 @@ PASS: 7 checks
ok - 20 concurrent registrations of one username -> 1x201, 19x409, 1 row
ok - chat with unknown member -> 400 and transaction rolled back (no orphan chat)
ok - password stored as $argon2id$..., sessions keep only sha256(token)
ok - migrations run twice more: schema_migrations and data unchanged (1:49)
ok - migrations run twice more: schema_migrations and data unchanged (1:113)
PASS: 4 checks
== dependency_test.py
ok - Valkey caches sessions with TTL<=300s and keeps logout tombstones
ok - Valkey stopped: ready=200, reads/writes OK, revoked token 401, 4 ms/request
ok - Valkey stopped: ready=200, reads/writes OK, revoked token 401, 3 ms/request
ok - PostgreSQL stopped: live=200, ready/business=503 in 0.0s total, unverified token not trusted
ok - PostgreSQL started again: API recovers without restart, data intact
PASS: 4 checks
== sigterm_test.sh
api stopped in 0s, exit code 0 (0 = graceful, 137 = SIGKILL)
api stopped in 1s, exit code 0 (0 = graceful, 137 = SIGKILL)
PASS: graceful SIGTERM shutdown, api restarted
ALL STUDENT TESTS PASSED