ЛР2: PostgreSQL, Bearer-сессии и Valkey — уровень 4

This commit is contained in:
Алиса Шурман
2026-10-29 16:21:11 +03:00
parent 65003b6119
commit e634ea9699
24 changed files with 1287 additions and 18 deletions
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+74
View File
@@ -0,0 +1,74 @@
[
{
"Plan": {
"Node Type": "Limit",
"Parallel Aware": false,
"Async Capable": false,
"Startup Cost": 0.29,
"Total Cost": 16.24,
"Plan Rows": 51,
"Plan Width": 78,
"Actual Startup Time": 0.005,
"Actual Total Time": 0.009,
"Actual Rows": 51,
"Actual Loops": 1,
"Shared Hit Blocks": 4,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"Plans": [
{
"Node Type": "Index Scan",
"Parent Relationship": "Outer",
"Parallel Aware": false,
"Async Capable": false,
"Scan Direction": "Forward",
"Index Name": "messages_history",
"Relation Name": "messages",
"Alias": "messages",
"Startup Cost": 0.29,
"Total Cost": 371.12,
"Plan Rows": 1185,
"Plan Width": 78,
"Actual Startup Time": 0.004,
"Actual Total Time": 0.007,
"Actual Rows": 51,
"Actual Loops": 1,
"Index Cond": "((chat_id = '888e913d-fb7a-4aa8-8fab-6d302ee925c2'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:09+00'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))",
"Rows Removed by Index Recheck": 0,
"Shared Hit Blocks": 4,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0
}
]
},
"Planning": {
"Shared Hit Blocks": 39,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0
},
"Planning Time": 0.063,
"Triggers": [],
"Execution Time": 0.019
}
]
+75
View File
@@ -0,0 +1,75 @@
[
{
"Plan": {
"Node Type": "Limit",
"Parallel Aware": false,
"Async Capable": false,
"Startup Cost": 0.29,
"Total Cost": 16.24,
"Plan Rows": 51,
"Plan Width": 78,
"Actual Startup Time": 0.005,
"Actual Total Time": 0.009,
"Actual Rows": 51,
"Actual Loops": 1,
"Shared Hit Blocks": 4,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"Plans": [
{
"Node Type": "Index Scan",
"Parent Relationship": "Outer",
"Parallel Aware": false,
"Async Capable": false,
"Scan Direction": "Forward",
"Index Name": "messages_history",
"Relation Name": "messages",
"Alias": "messages",
"Startup Cost": 0.29,
"Total Cost": 371.12,
"Plan Rows": 1185,
"Plan Width": 78,
"Actual Startup Time": 0.004,
"Actual Total Time": 0.007,
"Actual Rows": 51,
"Actual Loops": 1,
"Index Cond": "((chat_id = '888e913d-fb7a-4aa8-8fab-6d302ee925c2'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:09+00'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))",
"Rows Removed by Index Recheck": 0,
"Shared Hit Blocks": 4,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0
}
]
},
"Planning": {
"Shared Hit Blocks": 39,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0
},
"Planning Time": 0.063,
"Triggers": [],
"Execution Time": 0.019
}
]
PASS: 10000 messages; indexed keyset page after 9000; experiment rolled back
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost: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.
+36
View File
@@ -0,0 +1,36 @@
{
"before": [
{
"Name": "/mtusi-lab2-api-1",
"Id": "be19ec097578692a63ffc49eff4a58cd451854d5fe95822c7ce363a2c667e409",
"StartedAt": "2026-10-29T13:20:02.353966763Z"
},
{
"Name": "/mtusi-lab2-postgres-1",
"Id": "bffa85f567e255fd4b619a151601a024c777777feac1b208268f62188fa98608",
"StartedAt": "2026-10-29T13:14:34.459669389Z"
},
{
"Name": "/mtusi-lab2-valkey-1",
"Id": "549e49bd8ec7220c09a68c030c52b0a3e13c1c8e3d2331a3c22e84034d23a4c7",
"StartedAt": "2026-10-29T13:14:28.072368052Z"
}
],
"after": [
{
"Name": "/mtusi-lab2-api-1",
"Id": "be19ec097578692a63ffc49eff4a58cd451854d5fe95822c7ce363a2c667e409",
"StartedAt": "2026-10-29T13:20:09.028900585Z"
},
{
"Name": "/mtusi-lab2-postgres-1",
"Id": "bffa85f567e255fd4b619a151601a024c777777feac1b208268f62188fa98608",
"StartedAt": "2026-10-29T13:20:08.810265501Z"
},
{
"Name": "/mtusi-lab2-valkey-1",
"Id": "549e49bd8ec7220c09a68c030c52b0a3e13c1c8e3d2331a3c22e84034d23a4c7",
"StartedAt": "2026-10-29T13:20:08.904470501Z"
}
]
}
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
+30
View File
@@ -0,0 +1,30 @@
{
"registration_race": {
"201": 1,
"409": 7
},
"unicode_password_with_colon": "PASS",
"password_storage": "Argon2id; no plaintext",
"rollback": "PASS: chat count unchanged after failed member FK",
"validation_and_access": "PASS",
"concurrent_messages": "100/100; pages of 7; no loss or duplicates; cross-chat cursor rejected",
"cache_ttl_seconds": 59,
"valkey_outage": {
"fallback_status": 200,
"latency_seconds": 0.4205,
"anonymous": 401,
"ready": 200
},
"database_outage": {
"authenticated": 503,
"latency_seconds": 3.009,
"anonymous": 401,
"live": 200,
"ready": 503
},
"database_recovery_seconds": 1.045,
"committed_message_after_outage": "PASS",
"logout": "PASS even with cached profile",
"expiry": "PASS: SESSION_TTL_SECONDS=2",
"migration_reapply": "PASS twice; all entity counts unchanged"
}
+31
View File
@@ -0,0 +1,31 @@
{
"registration_race": {
"201": 1,
"409": 7
},
"unicode_password_with_colon": "PASS",
"password_storage": "Argon2id; no plaintext",
"rollback": "PASS: chat count unchanged after failed member FK",
"validation_and_access": "PASS",
"concurrent_messages": "100/100; pages of 7; no loss or duplicates; cross-chat cursor rejected",
"cache_ttl_seconds": 59,
"valkey_outage": {
"fallback_status": 200,
"latency_seconds": 0.4205,
"anonymous": 401,
"ready": 200
},
"database_outage": {
"authenticated": 503,
"latency_seconds": 3.009,
"anonymous": 401,
"live": 200,
"ready": 503
},
"database_recovery_seconds": 1.045,
"committed_message_after_outage": "PASS",
"logout": "PASS even with cached profile",
"expiry": "PASS: SESSION_TTL_SECONDS=2",
"migration_reapply": "PASS twice; all entity counts unchanged"
}
PASS: all level 4 integration checks
+3
View File
@@ -0,0 +1,3 @@
/Users/sleepy13/Desktop/projects/vp/vp-lab1-fork/.venv/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
warnings.warn(
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.