ЛР 2: PostgreSQL, сессии и Valkey — на 4
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
Fresh Linux export; no inherited secrets/data. Commands: init-env.sh twice; compose profile test build/up --wait; run-checks.sh.
|
||||
700 secrets
|
||||
444 secrets/postgres_password
|
||||
444 secrets/database_url
|
||||
444 secrets/cache_url
|
||||
755 scripts/init-env.sh
|
||||
755 scripts/restart.sh
|
||||
755 scripts/run-checks.sh
|
||||
001_initial.sql
|
||||
0
|
||||
0
|
||||
0
|
||||
@@ -0,0 +1,5 @@
|
||||
Release audit 2026-10-23 Europe/Moscow. Commands: clean Linux export; compose --profile test build/up; scripts/run-checks.sh; host compose up --wait api; public smoke.
|
||||
Running image=sha256:cbe9af6839830fd268490f97f97c9eae922339b03a6f9983914a330355a27568 configured=mtusi-lab2-api:local
|
||||
Built image=sha256:cbe9af6839830fd268490f97f97c9eae922339b03a6f9983914a330355a27568
|
||||
PASS: all src/*.py and migrations/*.sql hashes in actual updated host API equal working tree (LF, as required by .gitattributes).
|
||||
{"migrations/001_initial.sql": "5154c63cca9b5068821e5270b3d8dbc14c542b88ae5ce65422d72874118a14e5", "src/__init__.py": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b", "src/cache.py": "0f92c67b59f57a1ac5ee44d99bb5d992efa208e1d3c6fa44e5b537b913be926c", "src/config.py": "7d18c6b03d1130ca633055599f13a002d05a722a86427f2c47700b65908223b5", "src/db.py": "d21da56f3551eef2fb7e930a184264a0731eef8d6eb531929e611f8fa3df4d47", "src/errors.py": "1561923a04ed06088ab23accf1c60429187b7fc8a468082ab0cdb2ccd0aafa53", "src/main.py": "5c36a8dc3fa3dc84c69ebbfee94d1536619ee090da8d5d49931a99bfbd25f436", "src/models.py": "886786c4fa8c962c3e619e11fb0ec05870887f8ebef1c3fc7790816947f8859c", "src/pagination.py": "bba67fcab7b6ead93c4848319feccecd5e608287f0e983981b04ce0e1ca4b8f3", "src/security.py": "43a8b463e41053fe8ab125570eb7e93bbbbc13e4f5b6599457cbec22c00dc4d6", "src/store.py": "dc8c9512979dba9d54617e27b19beb40ca45972dd8f294263144bb2de716c548"}
|
||||
@@ -0,0 +1,4 @@
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
python3 scripts/validate_openapi.py
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
@@ -0,0 +1 @@
|
||||
PASS: SESSION_TTL_SECONDS=2: immediate authentication succeeds; after 2.21s cached profile cannot bypass expiry/logout
|
||||
@@ -0,0 +1,33 @@
|
||||
Rows in test chat: 10000
|
||||
|
||||
Position: 0
|
||||
Limit (cost=0.29..4.17 rows=51 width=70) (actual time=0.013..0.029 rows=51 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using messages_history on messages (cost=0.29..762.03 rows=10000 width=70) (actual time=0.012..0.022 rows=51 loops=1)
|
||||
Index Cond: (chat_id = 'afb33e87-5203-44cd-8aaa-6352dd299bff'::uuid)
|
||||
Buffers: shared hit=3
|
||||
Planning:
|
||||
Buffers: shared hit=20
|
||||
Planning Time: 0.229 ms
|
||||
Execution Time: 0.049 ms
|
||||
|
||||
Position: 5000
|
||||
Limit (cost=0.29..5.43 rows=51 width=70) (actual time=0.011..0.023 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history on messages (cost=0.29..503.22 rows=4981 width=70) (actual time=0.010..0.018 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'afb33e87-5203-44cd-8aaa-6352dd299bff'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.005001+00'::timestamp with time zone, '0c66c126-2dbf-49ff-a50d-6ffe6d9b9d0c'::uuid)))
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.146 ms
|
||||
Execution Time: 0.053 ms
|
||||
|
||||
Position: 9900
|
||||
Limit (cost=0.29..68.37 rows=51 width=70) (actual time=0.086..0.104 rows=51 loops=1)
|
||||
Buffers: shared hit=3
|
||||
-> Index Scan using messages_history on messages (cost=0.29..135.12 rows=101 width=70) (actual time=0.085..0.097 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = 'afb33e87-5203-44cd-8aaa-6352dd299bff'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.009901+00'::timestamp with time zone, '1f3e9d78-d453-4240-8e54-585c7ee9e9a6'::uuid)))
|
||||
Buffers: shared hit=3
|
||||
Planning Time: 0.150 ms
|
||||
Execution Time: 0.131 ms
|
||||
PostgreSQL: 16.8 (Debian 16.8-1.pgdg120+1)
|
||||
Durability: on on
|
||||
PASS: actual EXPLAIN ANALYZE BUFFERS at first/middle/tail; API traversal 10000 rows, 100 pages, 1.907s
|
||||
@@ -0,0 +1,4 @@
|
||||
PASS: Valkey stopped: ready=200, authenticated read/write via PG, unknown/missing/revoked=401, outsider=404; scenario 0.363s
|
||||
PASS: PostgreSQL stopped: ready/auth/write=503, live=200, no credentials=401, no cached authentication; scenario 0.056s
|
||||
PASS: PostgreSQL recovery 2.737s, same valid token/data survive, revoked token remains revoked, rejected write absent
|
||||
PASS: all 22 HTTP requests bounded below 4.5s; maximum 0.261s
|
||||
@@ -0,0 +1,2 @@
|
||||
python3 tests/smoke.py --base-url "http://api:8080"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,3 @@
|
||||
PASS: versioned migrations applied (already applied versions skipped)
|
||||
PASS: versioned migrations applied (already applied versions skipped)
|
||||
PASS: two repeated migrations; all table counts and absolute session expiries unchanged: {'users': 9, 'chats': 3, 'chat_members': 5, 'messages': 43, 'sessions': 6, 'schema_migrations': 1}
|
||||
@@ -0,0 +1,9 @@
|
||||
/mtusi-lab2-release-api-1 2026-10-23T14:41:25.192595559Z sha256:cbe9af6839830fd268490f97f97c9eae922339b03a6f9983914a330355a27568
|
||||
/mtusi-lab2-release-postgres-1 2026-10-23T14:43:17.90804068Z sha256:301bcb60b8a3ee4ab7e147932723e3abd1cef53516ce5210b39fd9fe5e3602ae
|
||||
/mtusi-lab2-release-valkey-1 2026-10-23T14:43:16.720128385Z sha256:752ba000a58bc8925d11ee863a39b5225617cd2cb3dbc9ec8ac65268b65ebb6d
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://api: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.
|
||||
/mtusi-lab2-release-api-1 2026-10-23T14:43:23.222109188Z sha256:cbe9af6839830fd268490f97f97c9eae922339b03a6f9983914a330355a27568
|
||||
/mtusi-lab2-release-postgres-1 2026-10-23T14:43:22.82384855Z sha256:301bcb60b8a3ee4ab7e147932723e3abd1cef53516ce5210b39fd9fe5e3602ae
|
||||
/mtusi-lab2-release-valkey-1 2026-10-23T14:43:22.700262536Z sha256:752ba000a58bc8925d11ee863a39b5225617cd2cb3dbc9ec8ac65268b65ebb6d
|
||||
@@ -0,0 +1,6 @@
|
||||
Release audit repository checks, 2026-10-23 Europe/Moscow.
|
||||
PASS: correct existing branch; no changes to teacher files; index empty; git diff --check.
|
||||
PASS: exactly three new shell scripts, shebang and LF verified. They remain untracked; explicit git add --chmod=+x required to set Git mode 100755.
|
||||
PASS: REPORT evidence references resolve; changed-files manifest refreshed.
|
||||
PASS: no local/release private secret values, private keys, ignored state, or files >=1MiB in submission candidates
|
||||
PASS: Python/Compose/CI parse; existing load summary arithmetic/order correct; historical build provenance explicit
|
||||
@@ -0,0 +1 @@
|
||||
PASS: same opaque token authenticates after all services restart; absolute PG expires_at unchanged; only 32-byte token hash stored
|
||||
@@ -0,0 +1,2 @@
|
||||
python3 tests/smoke.py --base-url "http://api:8080"
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,7 @@
|
||||
PASS: concurrent same username: 12 requests, 1 x 201, 11 x 409
|
||||
PASS: unknown member FK after parent INSERT rolls back chat and memberships; duplicate/missing owner -> 400
|
||||
PASS: NUL in display_name/title/text -> 400; PostgreSQL readiness remains 200
|
||||
PASS: strict types/extra fields, malformed JSON, UUID, limits/cursors, blank/oversized text, outsider isolation
|
||||
PASS: 40 concurrent writes; tied timestamp UUID ordering; complete keyset traversal, scoped cursors, changing limit, read-after-write
|
||||
PASS: malformed Basic, wrong/unknown credentials uniform 401, X-User-Id ignored, 128-code-point UTF8 colon password, stored Argon2id
|
||||
PASS: real Valkey GET hits, TTL <=60 without sliding; expiry/refill; logout rejects cached profile and repeated logout
|
||||
Reference in New Issue
Block a user