Implement lab2 PostgreSQL sessions and Redis cache
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
Pager usage is off.
|
||||
=== PostgreSQL version ===
|
||||
version
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
PostgreSQL 16.4 (Debian 16.4-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
|
||||
(1 row)
|
||||
|
||||
BEGIN
|
||||
INSERT 0 1
|
||||
INSERT 0 1
|
||||
INSERT 0 10000
|
||||
COMMIT
|
||||
ANALYZE
|
||||
=== Fixture size ===
|
||||
chat_id | message_count | distinct_timestamps
|
||||
--------------------------------------+---------------+---------------------
|
||||
0d8d1cf4-bdfa-47a5-a665-3975e1113d78 | 10000 | 1000
|
||||
(1 row)
|
||||
|
||||
=== History index definition ===
|
||||
indexdef
|
||||
----------------------------------------------------------------------------------------------------
|
||||
CREATE INDEX messages_chat_created_id_idx ON public.messages USING btree (chat_id, created_at, id)
|
||||
(1 row)
|
||||
|
||||
=== First page: LIMIT 51 ===
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.29..4.28 rows=51 width=78) (actual time=0.007..0.015 rows=51 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using messages_chat_created_id_idx on messages (cost=0.29..783.65 rows=10000 width=78) (actual time=0.006..0.011 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '0d8d1cf4-bdfa-47a5-a665-3975e1113d78'::uuid)
|
||||
Buffers: shared hit=3
|
||||
Planning:
|
||||
Buffers: shared hit=9
|
||||
Planning Time: 0.067 ms
|
||||
Execution Time: 0.025 ms
|
||||
(9 rows)
|
||||
|
||||
=== Middle page: keyset cursor, LIMIT 51 ===
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.29..5.66 rows=51 width=78) (actual time=0.005..0.017 rows=51 loops=1)
|
||||
Buffers: shared hit=9
|
||||
-> Index Scan using messages_chat_created_id_idx on messages (cost=0.29..527.86 rows=5010 width=78) (actual time=0.005..0.013 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '0d8d1cf4-bdfa-47a5-a665-3975e1113d78'::uuid) AND (ROW(created_at, id) > ROW('2000-01-01 00:00:00.499+00'::timestamp with time zone, 'f53aa6fb-ea52-4332-a211-d239fbf6c885'::uuid)))
|
||||
Buffers: shared hit=9
|
||||
Planning Time: 0.052 ms
|
||||
Execution Time: 0.052 ms
|
||||
(7 rows)
|
||||
@@ -0,0 +1,11 @@
|
||||
test_chat_creation_rollback (__main__.Lab2Checks.test_chat_creation_rollback) ... ok
|
||||
test_concurrent_username_registration (__main__.Lab2Checks.test_concurrent_username_registration) ... ok
|
||||
test_logout (__main__.Lab2Checks.test_logout) ... ok
|
||||
test_unicode_password_with_colons (__main__.Lab2Checks.test_unicode_password_with_colons) ... ok
|
||||
test_wrong_password (__main__.Lab2Checks.test_wrong_password) ... ok
|
||||
test_x_user_id_does_not_authenticate_or_change_user (__main__.Lab2Checks.test_x_user_id_does_not_authenticate_or_change_user) ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 6 tests in 1.523s
|
||||
|
||||
OK
|
||||
@@ -0,0 +1,6 @@
|
||||
PASS: Redis outage fallback; authenticated request took 0.296s
|
||||
PASS: PostgreSQL outage fails closed; authenticated request took 3.005s
|
||||
PASS: existing session recovered after PostgreSQL restart
|
||||
PASS: short session expired; observed after 2.065s
|
||||
RESTORED: services running; SESSION_TTL_SECONDS=3600
|
||||
PASS: dependency outages and short session expiry
|
||||
@@ -0,0 +1,24 @@
|
||||
make test-extra && make test-faults
|
||||
make[1]: Entering directory '/home/polina/projects/mtusi2026lab2'
|
||||
BASE_URL="http://localhost:18081" python3 tests/lab2_checks.py
|
||||
test_chat_creation_rollback (__main__.Lab2Checks.test_chat_creation_rollback) ... ok
|
||||
test_concurrent_username_registration (__main__.Lab2Checks.test_concurrent_username_registration) ... ok
|
||||
test_logout (__main__.Lab2Checks.test_logout) ... ok
|
||||
test_unicode_password_with_colons (__main__.Lab2Checks.test_unicode_password_with_colons) ... ok
|
||||
test_wrong_password (__main__.Lab2Checks.test_wrong_password) ... ok
|
||||
test_x_user_id_does_not_authenticate_or_change_user (__main__.Lab2Checks.test_x_user_id_does_not_authenticate_or_change_user) ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 6 tests in 1.384s
|
||||
|
||||
OK
|
||||
make[1]: Leaving directory '/home/polina/projects/mtusi2026lab2'
|
||||
make[1]: Entering directory '/home/polina/projects/mtusi2026lab2'
|
||||
BASE_URL="http://localhost:18081" python3 tests/lab2_faults.py
|
||||
PASS: Redis outage fallback; authenticated request took 0.140s
|
||||
PASS: PostgreSQL outage fails closed; authenticated request took 3.006s
|
||||
PASS: existing session recovered after PostgreSQL restart
|
||||
PASS: short session expired; observed after 2.067s
|
||||
RESTORED: services running; SESSION_TTL_SECONDS=3600
|
||||
PASS: dependency outages and short session expiry
|
||||
make[1]: Leaving directory '/home/polina/projects/mtusi2026lab2'
|
||||
@@ -0,0 +1,3 @@
|
||||
/mtusi2026lab2-api-1 started=2026-10-16T14:38:37.177198952Z status=running
|
||||
/mtusi2026lab2-postgres-1 started=2026-10-16T14:38:30.216555143Z status=running
|
||||
/mtusi2026lab2-redis-1 started=2026-10-16T14:38:30.148534088Z status=running
|
||||
@@ -0,0 +1,3 @@
|
||||
/mtusi2026lab2-api-1 started=2026-10-16T14:33:23.126243575Z status=running
|
||||
/mtusi2026lab2-postgres-1 started=2026-10-16T11:25:08.609760528Z status=running
|
||||
/mtusi2026lab2-redis-1 started=2026-10-16T11:25:08.607145864Z status=running
|
||||
@@ -0,0 +1,2 @@
|
||||
python3 tests/smoke.py --base-url "http://localhost:18081"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
Reference in New Issue
Block a user