forked from mtusi2026/mtusi2026lab2
Добавить мессенджер на Java с PostgreSQL и сессиями в Redis.
Данные и действующий токен переживают рестарт, сессии хранятся в Redis с AOF. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
messages=10000
|
||||
|
||||
Limit (cost=0.29..53.65 rows=50 width=64) (actual time=0.017..0.028 rows=50 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using messages_history_idx on messages (cost=0.29..211.62 rows=198 width=64) (actual time=0.017..0.023 rows=50 loops=1)
|
||||
Index Cond: ((chat_id = 'f472217b-e12b-4007-9998-1c24221d01ca'::uuid) AND (ROW(created_at, id) > ROW('2026-10-14 17:46:51.250266+00'::timestamp with time zone, 'be5a4036-03e8-45a7-8d19-42244139c1d4'::uuid)))
|
||||
Buffers: shared hit=3
|
||||
Planning:
|
||||
Buffers: shared hit=33
|
||||
Planning Time: 0.174 ms
|
||||
Execution Time: 0.063 ms
|
||||
@@ -0,0 +1,11 @@
|
||||
make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
scripts/restart.sh перезапускает postgres и redis, ждёт healthy и затем перезапускает api.
|
||||
Volumes pgdata и redisdata не удаляются. Тот же Bearer-токен после рестарта читает те же данные.
|
||||
|
||||
После прогона:
|
||||
api, postgres, redis — healthy.
|
||||
uid процесса API: uid=10001(messenger)
|
||||
Redis: aof_enabled:1, aof_last_write_status:ok
|
||||
docker stop -t 10 api: docker_stop_ms=2280, лог event=shutdown phase=end duration_ms=2006
|
||||
@@ -0,0 +1,5 @@
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
Команда: make test
|
||||
BASE_URL: http://localhost:8080
|
||||
Стенд: docker compose --env-file .env up -d --build
|
||||
@@ -0,0 +1,9 @@
|
||||
mvn -B test
|
||||
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
|
||||
CONCURRENCY PASS clients=10 messages=100 unique=100
|
||||
EXPLAIN index=messages_history_idx rows=10000
|
||||
|
||||
Проверены: повтор миграции, валидация, Bearer/Basic, игнор X-User-Id,
|
||||
гонка одного username (1 успех и 15 конфликтов), откат создания чата,
|
||||
expiry при SESSION_TTL_SECONDS=2, logout, неверный пароль,
|
||||
пауза Redis и PostgreSQL (503, аноним не становится пользователем).
|
||||
Reference in New Issue
Block a user