131 lines
19 KiB
JSON
131 lines
19 KiB
JSON
{
|
|
"date": "2026-10-30T10:56:54.044284+00:00",
|
|
"checks": [
|
|
{
|
|
"command": "make check",
|
|
"exit_code": 0,
|
|
"stdout": "python3 scripts/check_contract.py\nPASS: offline skeleton structure, local refs and Python syntax; application NOT tested.\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "make validate PYTHON=.venv/bin/python",
|
|
"exit_code": 0,
|
|
"stdout": ".venv/bin/python scripts/validate_openapi.py\nPASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "make test",
|
|
"exit_code": 0,
|
|
"stdout": "python3 tests/smoke.py --base-url \"http://localhost:8080\" \nPASS: lab2 public API scenario; infrastructure and grading evidence remain separate.\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_auth.py",
|
|
"exit_code": 0,
|
|
"stdout": "1. Registration\nRegistration status: 201\nRegistration headers: {'Content-Length': '144', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Date': 'Fri, 30 Oct 2026 10:56:55 GMT', 'Keep-Alive': 'timeout=60', 'Proxy-Connection': 'keep-alive', 'Server': 'uvicorn', 'X-Request-Id': 'e18774ae-f206-4216-8a6c-81648825f093'}\nRegistration body: {'id': 'abd4cc85-fe81-4dae-a33a-4b09fcc993a4', 'username': 'test_10537209d0', 'display_name': 'Test User', 'created_at': '2026-10-30T10:56:55.192161Z'}\nPASS: registration: 201 (expected 201)\nUser ID: abd4cc85-fe81-4dae-a33a-4b09fcc993a4\n\n2. Basic login\nPASS: login: 201 (expected 201)\n\n3. Access with Bearer token\nPASS: authorized request: 200 (expected 200)\n\n4. Access without token\nPASS: missing token: 401 (expected 401)\n\n5. X-User-Id cannot authorize\nPASS: X-User-Id rejected: 401 (expected 401)\n\n6. Logout\nPASS: logout: 204 (expected 204)\n\n7. Reuse revoked token\nPASS: revoked token rejected: 401 (expected 401)\n\nALL AUTH CHECKS PASSED\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_advanced.py",
|
|
"exit_code": 0,
|
|
"stdout": "1. Concurrent registration\nPASS: one registration, nine conflicts\n2. Incorrect password\nPASS: incorrect password rejected\n3. Invalid Bearer token\nPASS: invalid token rejected\nPASS: malformed and non-ASCII Bearer tokens rejected\n4. Unknown chat member\nPASS: unknown member rejected\n\nALL ADVANCED API CHECKS PASSED\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_messenger.py",
|
|
"exit_code": 0,
|
|
"stdout": "\n1. Register two users\nPASS: register alice_b35280a7: 201\nPASS: register bob_b35280a7: 201\n\n2. Login\nPASS: login alice_b35280a7: 201\nPASS: login bob_b35280a7: 201\n\n3. Create chat\nPASS: create chat: 201\nChat ID: 1b010c7a-727b-43cf-965c-4377c6c87f05\n\n4. Check chat visibility\nPASS: get chat: 200\nPASS: get chat: 200\n\n5. Send messages\nPASS: send message: 201\nPASS: send message: 201\nPASS: send message: 201\nPASS: send message: 201\nPASS: send message: 201\n\n6. Read first page\nPASS: first page: 200\n\n7. Read second page\nPASS: second page: 200\n\n8. Check chat list\nPASS: list chats: 200\n\n9. Check PostgreSQL persistence\nCreated chat: 1b010c7a-727b-43cf-965c-4377c6c87f05\nCreated messages: 5\n\nALL MESSENGER CHECKS PASSED\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_redis_failure.py",
|
|
"exit_code": 0,
|
|
"stdout": "PASS: Redis contains session profile with TTL\nPASS: PostgreSQL read/write and logout work without Redis\nPASS: stale cache cannot revive revoked session; Redis recovered\n",
|
|
"stderr": " Container mtusi2026lab2-redis-1 Stopping\n Container mtusi2026lab2-redis-1 Stopped\ntime=\"2026-10-30T13:56:57+03:00\" level=warning msg=\"Found orphan containers ([mtusi2026lab2-api-ttl-1]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.\"\n Container mtusi2026lab2-redis-1 Created\n Container mtusi2026lab2-redis-1 Starting\n Container mtusi2026lab2-redis-1 Started\n Container mtusi2026lab2-redis-1 Waiting\n Container mtusi2026lab2-redis-1 Healthy\n"
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_db_failure.py",
|
|
"exit_code": 0,
|
|
"stdout": "PASS: token works before database failure\nPASS: database failure does not grant access: 503\nALL DATABASE FAILURE CHECKS PASSED; original session recovered\n",
|
|
"stderr": " Container mtusi2026lab2-postgres-1 Stopping\n Container mtusi2026lab2-postgres-1 Stopped\n Container mtusi2026lab2-postgres-1 Starting\n Container mtusi2026lab2-postgres-1 Started\n"
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_migrations.py",
|
|
"exit_code": 0,
|
|
"stdout": "PASS: migration creates five tables from zero and reapplies without errors; rolled back\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "docker compose exec -T api python",
|
|
"exit_code": 0,
|
|
"stdout": "PASS: failure after first member insert rolls back chat and membership\n",
|
|
"stderr": "",
|
|
"stdin_file": "scripts/check_transactions.py"
|
|
},
|
|
{
|
|
"command": "make test-persistence ACTION_SCRIPT=scripts/restart.sh",
|
|
"exit_code": 0,
|
|
"stdout": "python3 tests/resilience.py --mode persistence --action-script \"scripts/restart.sh\" --base-url \"http://localhost:8080\" \nExecuting explicit persistence hook; hook output suppressed to avoid leaking secrets.\nPASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "docker compose -f compose.yaml -f compose.ttl.yaml up -d --build --wait api-ttl",
|
|
"exit_code": 0,
|
|
"stdout": "Compose now can delegate build to bake for better performances\nJust set COMPOSE_BAKE=true\n#0 building with \"desktop-linux\" instance using docker driver\n\n#1 [api-ttl internal] load build definition from Dockerfile\n#1 transferring dockerfile: 778B done\n#1 DONE 0.0s\n\n#2 [api-ttl internal] load metadata for docker.io/library/python:3.11.16-slim-bookworm\n#2 DONE 0.0s\n\n#3 [api-ttl internal] load .dockerignore\n#3 transferring context: 196B done\n#3 DONE 0.0s\n\n#4 [api-ttl internal] load build context\n#4 transferring context: 720B done\n#4 DONE 0.0s\n\n#5 [api-ttl 1/6] FROM docker.io/library/python:3.11.16-slim-bookworm@sha256:a36c24f9cbdf4fd0f52d67f0823eeac19c2028c637cecc392d97f980d4fec56b\n#5 resolve docker.io/library/python:3.11.16-slim-bookworm@sha256:a36c24f9cbdf4fd0f52d67f0823eeac19c2028c637cecc392d97f980d4fec56b\n#5 resolve docker.io/library/python:3.11.16-slim-bookworm@sha256:a36c24f9cbdf4fd0f52d67f0823eeac19c2028c637cecc392d97f980d4fec56b 0.7s done\n#5 DONE 0.7s\n\n#6 [api-ttl 3/6] COPY requirements.txt .\n#6 CACHED\n\n#7 [api-ttl 4/6] RUN python -m pip install --no-cache-dir -r requirements.txt\n#7 CACHED\n\n#8 [api-ttl 5/6] RUN useradd --uid 10001 --create-home --shell /usr/sbin/nologin appuser\n#8 CACHED\n\n#9 [api-ttl 2/6] WORKDIR /app\n#9 CACHED\n\n#10 [api-ttl 6/6] COPY --chown=appuser:appuser src/ ./src/\n#10 CACHED\n\n#11 [api-ttl] exporting to image\n#11 exporting layers done\n#11 exporting manifest sha256:a6a0f6f9fc66e2ad26dd5d141b27ab8e4d3a8ee26b43afa21aa58c6e5ef10fcd done\n#11 exporting config sha256:9232a3492de92095ab11f4877bc256cb3227c8ae3cc63430bd9f3664a4d357ce done\n#11 exporting attestation manifest sha256:4673ee5cb2ce9fedb997670011d04711c70452a44bc23d18c8313e17370062e2 done\n#11 exporting manifest list sha256:8f1054addd1e51ae837fa0a23e0e485839f97b15257f8aa53638fd848978c5c5 done\n#11 naming to docker.io/library/mtusi2026lab2-api-ttl:latest done\n#11 unpacking to docker.io/library/mtusi2026lab2-api-ttl:latest done\n#11 DONE 0.1s\n\n#12 [api-ttl] resolving provenance for metadata file\n#12 DONE 0.0s\n",
|
|
"stderr": " api-ttl Built\n Container mtusi2026lab2-postgres-1 Running\n Container mtusi2026lab2-api-ttl-1 Recreate\n Container mtusi2026lab2-api-ttl-1 Recreated\n Container mtusi2026lab2-postgres-1 Waiting\n Container mtusi2026lab2-postgres-1 Healthy\n Container mtusi2026lab2-api-ttl-1 Starting\n Container mtusi2026lab2-api-ttl-1 Started\n Container mtusi2026lab2-postgres-1 Waiting\n Container mtusi2026lab2-api-ttl-1 Waiting\n Container mtusi2026lab2-postgres-1 Healthy\n Container mtusi2026lab2-api-ttl-1 Healthy\n"
|
|
},
|
|
{
|
|
"command": "python3 scripts/check_ttl.py",
|
|
"exit_code": 0,
|
|
"stdout": "PASS: session expires after TTL\n",
|
|
"stderr": ""
|
|
},
|
|
{
|
|
"command": "docker compose -f compose.yaml -f compose.ttl.yaml stop api-ttl",
|
|
"exit_code": 0,
|
|
"stdout": "",
|
|
"stderr": " Container mtusi2026lab2-api-ttl-1 Stopping\n Container mtusi2026lab2-api-ttl-1 Stopped\n"
|
|
},
|
|
{
|
|
"command": "docker compose exec -T postgres psql -X -v ON_ERROR_STOP=1 -U messenger -d messenger",
|
|
"exit_code": 0,
|
|
"stdout": "BEGIN\nSET\nPREPARE\n QUERY PLAN \n-----------------------------------------------------------------------------------------------------------------------------------------------------\n Limit (cost=0.42..582.96 rows=584 width=78) (actual time=0.020..0.032 rows=51 loops=1)\n Buffers: shared hit=2 read=3\n -> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..5820.85 rows=5835 width=78) (actual time=0.019..0.028 rows=51 loops=1)\n Index Cond: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3)))\n Buffers: shared hit=2 read=3\n Planning:\n Buffers: shared hit=6\n Planning Time: 0.128 ms\n Execution Time: 0.054 ms\n(9 rows)\n\nROLLBACK\n",
|
|
"stderr": "",
|
|
"stdin_file": "scripts/explain_pagination.sql"
|
|
},
|
|
{
|
|
"command": "docker compose exec -T postgres psql -X -v ON_ERROR_STOP=1 -U messenger -d messenger",
|
|
"exit_code": 0,
|
|
"stdout": "BEGIN\nTiming is on.\nANALYZE\nTime: 117.334 ms\n chat_id | messages_count \n--------------------------------------+----------------\n f68eff95-e44f-4c79-997c-49eb725cfb4d | 90005\n b14d0a4f-3046-44b2-871e-4ebfb752c543 | 11613\n 41d9abbc-4d0b-44f7-a1a2-ea3de4faa0c3 | 10942\n 1b7b678e-d262-4d61-8167-7fc8b736f3ff | 10005\n 0d8c7368-f88a-4bdb-972e-e4d7e1cd437a | 5\n(5 rows)\n\nTime: 10.412 ms\nTime: 8.597 ms\nTEST A: existing composite index\n QUERY PLAN \n-------------------------------------------------------------------------------------------------------------------------------------------------------\n Limit (cost=0.42..6.74 rows=50 width=45) (actual time=0.025..0.036 rows=50 loops=1)\n Buffers: shared hit=3 read=2\n -> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..11395.89 rows=90150 width=45) (actual time=0.024..0.033 rows=50 loops=1)\n Index Cond: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid)\n Buffers: shared hit=3 read=2\n Planning:\n Buffers: shared hit=10\n Planning Time: 0.069 ms\n Execution Time: 0.044 ms\n(9 rows)\n\nTime: 0.360 ms\nTEST B: additional index\nCREATE INDEX\nTime: 0.285 ms\nANALYZE\nTime: 123.698 ms\n QUERY PLAN \n-------------------------------------------------------------------------------------------------------------------------------------------------------\n Limit (cost=0.42..6.75 rows=50 width=45) (actual time=0.007..0.014 rows=50 loops=1)\n Buffers: shared hit=5\n -> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..11378.89 rows=89905 width=45) (actual time=0.006..0.011 rows=50 loops=1)\n Index Cond: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid)\n Buffers: shared hit=5\n Planning:\n Buffers: shared hit=15\n Planning Time: 0.081 ms\n Execution Time: 0.023 ms\n(9 rows)\n\nTime: 0.279 ms\nIndex sizes\n indexrelname | size \n------------------------------+---------\n idx_messages_chat_created_id | 9328 kB\n idx_messages_chat_id_only | 1016 kB\n messages_pkey | 5392 kB\n(3 rows)\n\nTime: 1.366 ms\nROLLBACK\nTime: 0.119 ms\n",
|
|
"stderr": "NOTICE: relation \"idx_messages_chat_id_only\" already exists, skipping\n",
|
|
"stdin_file": "scripts/benchmark_indexes.sql"
|
|
},
|
|
{
|
|
"command": "docker compose exec -T postgres psql -X -v ON_ERROR_STOP=1 -U messenger -d messenger",
|
|
"exit_code": 0,
|
|
"stdout": "Timing is on.\nTime: 8.859 ms\nCOMPOSITE INDEX\n QUERY PLAN \n-------------------------------------------------------------------------------------------------------------------------------------------------------\n Limit (cost=0.42..6.06 rows=50 width=46) (actual time=0.028..0.039 rows=50 loops=1)\n Buffers: shared hit=5\n -> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..11162.90 rows=98962 width=46) (actual time=0.027..0.036 rows=50 loops=1)\n Index Cond: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid)\n Buffers: shared hit=5\n Planning:\n Buffers: shared hit=14\n Planning Time: 0.097 ms\n Execution Time: 0.048 ms\n(9 rows)\n\nTime: 0.507 ms\nBEGIN\nTime: 0.083 ms\nCREATE INDEX\nTime: 0.205 ms\nDROP INDEX\nTime: 0.680 ms\nSINGLE COLUMN INDEX\n QUERY PLAN \n-----------------------------------------------------------------------------------------------------------------------------------------\n Limit (cost=5448.46..5454.21 rows=50 width=46) (actual time=13.704..14.946 rows=50 loops=1)\n Buffers: shared hit=114 read=1543\n -> Gather Merge (cost=5448.46..12142.95 rows=58213 width=46) (actual time=13.703..14.938 rows=50 loops=1)\n Workers Planned: 1\n Workers Launched: 1\n Buffers: shared hit=114 read=1543\n -> Sort (cost=4448.45..4593.98 rows=58213 width=46) (actual time=12.461..12.463 rows=50 loops=2)\n Sort Key: created_at, id\n Sort Method: top-N heapsort Memory: 28kB\n Buffers: shared hit=114 read=1543\n Worker 0: Sort Method: top-N heapsort Memory: 28kB\n -> Parallel Seq Scan on messages (cost=0.00..2514.65 rows=58213 width=46) (actual time=0.012..8.363 rows=45002 loops=2)\n Filter: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid)\n Rows Removed by Filter: 16310\n Buffers: shared hit=70 read=1543\n Planning:\n Buffers: shared hit=4\n Planning Time: 0.038 ms\n Execution Time: 14.977 ms\n(19 rows)\n\nTime: 15.268 ms\nROLLBACK\nTime: 0.138 ms\nORIGINAL INDEX RESTORED\n",
|
|
"stderr": "NOTICE: relation \"idx_messages_chat_id_only\" already exists, skipping\n",
|
|
"stdin_file": "scripts/compare_indexes.sql"
|
|
},
|
|
{
|
|
"command": "docker compose exec -T postgres psql -X -v ON_ERROR_STOP=1 -U messenger -d messenger",
|
|
"exit_code": 0,
|
|
"stdout": "Timing is on.\nBEGIN\nTime: 0.114 ms\nDROP INDEX\nTime: 0.510 ms\nDROP INDEX\nTime: 0.255 ms\nWRITE WITHOUT SECONDARY INDEXES\n QUERY PLAN \n----------------------------------------------------------------------------------------------------------------------------------------------\n Insert on messages (cost=0.00..275.41 rows=0 width=0) (actual time=38.420..38.421 rows=0 loops=1)\n Buffers: shared hit=39651 read=676 dirtied=815 written=143\n -> Subquery Scan on \"*SELECT*\" (cost=0.00..275.41 rows=10000 width=88) (actual time=0.387..11.577 rows=10000 loops=1)\n Buffers: shared hit=1\n -> Limit (cost=0.00..150.41 rows=10000 width=80) (actual time=0.386..10.826 rows=10000 loops=1)\n Buffers: shared hit=1\n -> Nested Loop (cost=0.00..42113.50 rows=2800000 width=80) (actual time=0.385..10.225 rows=10000 loops=1)\n Buffers: shared hit=1\n -> Function Scan on generate_series (cost=0.00..100.00 rows=10000 width=0) (actual time=0.358..0.388 rows=345 loops=1)\n -> Materialize (cost=0.00..14.20 rows=280 width=32) (actual time=0.000..0.001 rows=29 loops=345)\n Buffers: shared hit=1\n -> Seq Scan on chats c (cost=0.00..12.80 rows=280 width=32) (actual time=0.009..0.013 rows=29 loops=1)\n Buffers: shared hit=1\n Planning:\n Buffers: shared hit=65\n Planning Time: 0.148 ms\n Trigger for constraint messages_chat_id_fkey: time=26.385 calls=10000\n Trigger for constraint messages_sender_id_fkey: time=45.532 calls=10000\n Execution Time: 111.483 ms\n(19 rows)\n\nTime: 112.022 ms\nROLLBACK\nTime: 0.118 ms\nBEGIN\nTime: 0.125 ms\nCREATE INDEX\nTime: 0.326 ms\nWRITE WITH EXISTING INDEXES\n QUERY PLAN \n----------------------------------------------------------------------------------------------------------------------------------------------\n Insert on messages (cost=0.00..275.41 rows=0 width=0) (actual time=48.708..48.709 rows=0 loops=1)\n Buffers: shared hit=90737 read=23 dirtied=292 written=245\n -> Subquery Scan on \"*SELECT*\" (cost=0.00..275.41 rows=10000 width=88) (actual time=0.533..11.244 rows=10000 loops=1)\n Buffers: shared hit=1\n -> Limit (cost=0.00..150.41 rows=10000 width=80) (actual time=0.532..10.510 rows=10000 loops=1)\n Buffers: shared hit=1\n -> Nested Loop (cost=0.00..42113.50 rows=2800000 width=80) (actual time=0.531..9.910 rows=10000 loops=1)\n Buffers: shared hit=1\n -> Function Scan on generate_series (cost=0.00..100.00 rows=10000 width=0) (actual time=0.497..0.525 rows=345 loops=1)\n -> Materialize (cost=0.00..14.20 rows=280 width=32) (actual time=0.000..0.001 rows=29 loops=345)\n Buffers: shared hit=1\n -> Seq Scan on chats c (cost=0.00..12.80 rows=280 width=32) (actual time=0.008..0.011 rows=29 loops=1)\n Buffers: shared hit=1\n Planning Time: 0.055 ms\n Trigger for constraint messages_chat_id_fkey: time=26.086 calls=10000\n Trigger for constraint messages_sender_id_fkey: time=41.720 calls=10000\n Execution Time: 117.756 ms\n(17 rows)\n\nTime: 118.278 ms\nROLLBACK\nTime: 0.159 ms\n",
|
|
"stderr": "NOTICE: relation \"idx_messages_chat_id_only\" already exists, skipping\n",
|
|
"stdin_file": "scripts/benchmark_writes.sql"
|
|
}
|
|
],
|
|
"restart_before": {
|
|
"api": "2026-10-30T10:55:12.637263918Z",
|
|
"postgres": "2026-10-30T10:57:10.385474751Z",
|
|
"redis": "2026-10-30T10:56:57.171946925Z"
|
|
},
|
|
"restart_after": {
|
|
"api": "2026-10-30T10:57:19.664978005Z",
|
|
"postgres": "2026-10-30T10:57:13.61408121Z",
|
|
"redis": "2026-10-30T10:57:13.675466502Z"
|
|
},
|
|
"all_three_services_restarted": true,
|
|
"backup_restore_evidence": "evidence/backup_restore.json"
|
|
}
|