test: verify level-four failures and history index

This commit is contained in:
Самохвалов Андрей Ремович
2026-10-02 12:35:18 +03:00
parent d59d3f4adc
commit e50ba0f8d2
9 changed files with 258 additions and 17 deletions
+28
View File
@@ -0,0 +1,28 @@
Lab 2 U5 history index evidence
Base commit at measurement: d59d3f4; local Colima Docker: 2 CPUs, 2054840320 bytes memory.
Command: docker compose --env-file .env exec -T api python - --count 10000 --deep-offset 8000 < scripts/seed_history.py
Each run creates a new synthetic user/chat and appends its own messages to the disposable test database.
UTC: 2026-10-02T08:41:04.204691+00:00
PostgreSQL: 17.6 (Debian 17.6-2.pgdg12+1)
Synthetic chat messages: 10000
Deep cursor ordinal: 8000
History index: CREATE INDEX messages_history_idx ON public.messages USING btree (chat_id, created_at, id)
Verified: first/deep pages each have 51 ordered rows with no shared IDs
First page: EXPLAIN (ANALYZE, BUFFERS)
Limit (cost=0.29..6.76 rows=51 width=70) (actual time=0.003..0.007 rows=51 loops=1)
Buffers: shared hit=3
-> Index Scan using messages_history_idx on messages (cost=0.29..1269.95 rows=10000 width=70) (actual time=0.003..0.005 rows=51 loops=1)
Index Cond: (chat_id = '86684ee0-6818-4f81-ad7f-e7bf9069b8e8'::uuid)
Buffers: shared hit=3
Planning Time: 0.014 ms
Execution Time: 0.010 ms
Deep page: EXPLAIN (ANALYZE, BUFFERS)
Limit (cost=0.29..11.51 rows=51 width=70) (actual time=0.003..0.010 rows=51 loops=1)
Buffers: shared hit=4
-> Index Scan using messages_history_idx on messages (cost=0.29..439.78 rows=1996 width=70) (actual time=0.003..0.007 rows=51 loops=1)
Index Cond: ((chat_id = '86684ee0-6818-4f81-ad7f-e7bf9069b8e8'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 08:41:04.152402+00'::timestamp with time zone, '492d2f70-1f2b-4e98-a87d-5bab4668d05c'::uuid)))
Buffers: shared hit=4
Planning Time: 0.016 ms
Execution Time: 0.014 ms
+30
View File
@@ -0,0 +1,30 @@
Lab 2 U5 level-4 checks, 2026-10-02, base commit d59d3f4 plus local changes.
Local Colima Docker: 2 CPUs, 2054840320 bytes memory; disposable Compose stack.
Command: make test-level4 (secrets and session tokens never printed).
docker compose --env-file .env exec -T api python - < student-tests/test_database.py
...
----------------------------------------------------------------------
Ran 3 tests in 1.252s
OK
docker compose --env-file .env exec -T api python - < student-tests/test_auth.py
....
----------------------------------------------------------------------
Ran 4 tests in 5.335s
OK
docker compose --env-file .env exec -T api python - < student-tests/test_cache_failures.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.300s
OK
SQL queries (miss/hit/reload): 2/1/2; Valkey hit/miss deltas: 1/2
CHECK_COMPOSE_FAILURES=1 python3 student-tests/test_compose_failures.py
.
----------------------------------------------------------------------
Ran 1 test in 13.472s
OK
Valkey outage: 200; PostgreSQL outage: readiness/auth 503; revoked token after Valkey restart: 401