ЛР5: брокер Redis Streams, worker, outbox, retry/DLQ/replay, варианты

This commit is contained in:
LOSYASH
2026-11-12 15:14:48 +01:00
parent 276dbdad8a
commit b4804ac5c1
98 changed files with 9131 additions and 38 deletions
+108
View File
@@ -0,0 +1,108 @@
# attachments
# date: 2026-11-11T23:52:28 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/attachments.py --base-url http://localhost:8080
== позитивный сценарий ==
ok - upload PNG -> 202 (got 202)
ok - 202 queued, variants=[], error_code=null
ok - sha256/size describe the original
ok - no S3 key/bucket in public JSON
ok - upload JPEG with Unicode filename -> 202 (got 202)
ok - filename returned as is (display only)
ok - both become ready (worker)
ok - member downloads PNG -> 200 (got 200)
ok - downloaded bytes are identical (sha256)
ok - true Content-Type image/png
ok - nosniff header
ok - member downloads JPEG (variant=original) -> 200 (got 200)
ok - JPEG bytes and type
ok - message with empty text + 2 attachments -> 201 (got 201)
ok - attachment_ids kept in request order
ok - history shows attachment_ids
ok - text-only POST (lab3) still valid, attachment_ids=[]
ok - member reads metadata -> 200 (got 200)
ok - thumbnail variant exists in lab5 -> 200 (got 200)
ok - unknown variant name -> 400 (got 400)
== доступ ==
ok - outsider GET attachment metadata -> 404 (got 404)
ok - unknown attachment metadata -> 404 (got 404)
ok - outsider GET attachment/content -> 404 (got 404)
ok - unknown attachment/content -> 404 (got 404)
ok - anonymous download -> 401 (got 401)
ok - attachment id is not a UUID -> 400 (got 400)
ok - outsider uploads into foreign chat -> 404 (got 404)
ok - anonymous upload -> 401 (got 401)
== привязка к сообщению ==
ok - eve uploads into her own chat -> 202 (got 202)
ok - alice uploads into her second chat -> 202 (got 202)
ok - foreign attachment_id (eve's chat) in message -> 404 (got 404)
ok - attachment of ANOTHER chat of the same user -> 404 (got 404)
ok - unknown attachment_id -> 404 (got 404)
ok - one valid + one foreign -> whole message rejected -> 404 (got 404)
ok - duplicate attachment_ids -> 400 (got 400)
ok - same UUID in different case is a duplicate -> 400 (got 400)
ok - more than 10 attachment_ids -> 400 (got 400)
ok - attachment_id is not a UUID -> 400 (got 400)
ok - attachment_ids: null -> 400 (got 400)
ok - blank text without attachments -> 400 (got 400)
ok - text field is required -> 400 (got 400)
ok - any member may reference a chat attachment again -> 201 (got 201)
ok - eve attaches alice's file to her own chat -> 404 (got 404)
== идемпотентность с вложениями ==
ok - missing attachment_ids == [] (same Message)
ok - same key, different attachment_ids -> 409 (got 409)
ok - replay with attachments returns the same Message
== размер ==
ok - Content-Length = 10 MiB + 1, body never sent (limit before reading) -> 413 (got 413)
ok - Content-Length = 500 MiB -> 413 (got 413)
ok - chunked body > 10 MiB without Content-Length (stream cut at limit) -> 413 (got 413)
ok - real PNG of 11424004 bytes -> 413 (got 413)
ok - empty body -> 400 (got 400)
== пиксели ==
ok - decompression bomb 8000x8000 in 62290 bytes -> 413 (got 413)
ok - 40 040 001 pixels (just over the limit) -> 413 (got 413)
== повреждённые файлы ==
ok - truncated PNG -> 415 (got 415)
ok - truncated PNG: error code
ok - PNG with flipped byte (CRC) -> 415 (got 415)
ok - PNG with flipped byte (CRC): error code
ok - PNG signature only -> 415 (got 415)
ok - PNG signature only: error code
ok - PNG header + garbage -> 415 (got 415)
ok - PNG header + garbage: error code
ok - truncated JPEG -> 415 (got 415)
ok - truncated JPEG: error code
ok - JPEG SOI + garbage -> 415 (got 415)
ok - JPEG SOI + garbage: error code
== fuzz: случайные порчи байтов (только 202 или 415, никогда 500) ==
ok - 30 corrupted files -> only 202/415 (got [202, 415])
== подмена MIME ==
ok - PNG bytes sent as image/jpeg -> 415 (got 415)
ok - JPEG bytes sent as image/png -> 415 (got 415)
ok - text renamed to .png -> 415 (got 415)
ok - GIF sent as image/png -> 415 (got 415)
ok - HTML sent as image/jpeg -> 415 (got 415)
ok - PNG with Content-Type image/gif -> 415 (got 415)
ok - PNG with Content-Type application/octet-stream -> 415 (got 415)
ok - PNG with Content-Type text/html -> 415 (got 415)
== опасные filename ==
ok - filename '../../etc/passwd' -> 400 (got 400)
ok - filename 'dir/a.png' -> 400 (got 400)
ok - filename 'C:\\Windows\\a.png' -> 400 (got 400)
ok - filename 'a\x00.png' -> 400 (got 400)
ok - filename 'a\nb.png' -> 400 (got 400)
ok - filename 'tab\t.png' -> 400 (got 400)
ok - filename '\x1b[31mred.png' -> 400 (got 400)
ok - filename 'photo\u202egnp.exe' -> 400 (got 400)
ok - filename '..' -> 400 (got 400)
ok - filename '.' -> 400 (got 400)
ok - filename ' ' -> 400 (got 400)
ok - filename 'xxxxxxxxxxxxxxxxxxxx' -> 400 (got 400)
ok - filename missing -> 400 (got 400)
ok - filename of exactly 255 chars -> 202 (got 202)
ok - filename with spaces, Unicode and punctuation -> 202 (got 202)
ok - media type parameters are ignored -> 202 (got 202)
ok - no 500 and no dropped connection among 99 checked responses
91 passed, 0 failed
[exit 0]
+22
View File
@@ -0,0 +1,22 @@
# broker-config
# date: 2026-11-11T23:54:10 commit: 276dbda
$ docker compose --env-file .env exec -T broker redis-cli CONFIG GET append*
appendfilename
appendonly.aof
appendonly
yes
appendfsync
always
appenddirname
appendonlydir
[exit 0]
$ docker compose --env-file .env exec -T broker redis-cli CONFIG GET maxmemory-policy
maxmemory-policy
noeviction
[exit 0]
$ docker compose --env-file .env exec -T api python -m app.tools queue
{"stream_length": 11, "groups": [{"name": "workers", "consumers": 2, "pending": 2, "lag": 9}], "dlq_length": 0, "outbox_unpublished": 0, "jobs_by_status": {"ready": 8, "processing": 2, "queued": 9}}
[exit 0]
+6
View File
@@ -0,0 +1,6 @@
# check
# date: 2026-11-11T23:51:41 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
[exit 0]
+56
View File
@@ -0,0 +1,56 @@
# failover
# date: 2026-11-12T15:08:35 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe tests/resilience.py --mode failover --action-script C:\Users\79152\Desktop\mtusi2026lab5\scripts\stop-one.cmd --base-url http://localhost:8080
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 116, "failed_attempts": 0, "first_recovery_seconds": 1.536}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
[exit 0]
$ C:\Users\79152\Desktop\mtusi2026lab5\scripts\restore-api.cmd
Container mtusi-lab5-postgres-1 Waiting
Container mtusi-lab5-s3-1 Waiting
Container mtusi-lab5-postgres-1 Healthy
Container mtusi-lab5-s3-1 Healthy
Container mtusi-lab5-migrate-1 Starting
Container mtusi-lab5-s3-init-1 Starting
Container mtusi-lab5-migrate-1 Started
Container mtusi-lab5-s3-init-1 Started
Container mtusi-lab5-broker-1 Waiting
Container mtusi-lab5-migrate-1 Waiting
Container mtusi-lab5-s3-init-1 Waiting
Container mtusi-lab5-postgres-1 Waiting
Container mtusi-lab5-broker-1 Healthy
Container mtusi-lab5-postgres-1 Healthy
Container mtusi-lab5-migrate-1 Exited
Container mtusi-lab5-s3-init-1 Exited
Container mtusi-lab5-api-1 Starting
Container mtusi-lab5-api-1 Started
[exit 0]
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe tests/resilience.py --mode failover --action-script C:\Users\79152\Desktop\mtusi2026lab5\scripts\stop-one.cmd --base-url http://localhost:8080
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 112, "failed_attempts": 0, "first_recovery_seconds": 2.007}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
[exit 0]
$ C:\Users\79152\Desktop\mtusi2026lab5\scripts\restore-api.cmd
Container mtusi-lab5-s3-1 Waiting
Container mtusi-lab5-postgres-1 Waiting
Container mtusi-lab5-s3-1 Healthy
Container mtusi-lab5-s3-init-1 Starting
Container mtusi-lab5-postgres-1 Healthy
Container mtusi-lab5-migrate-1 Starting
Container mtusi-lab5-s3-init-1 Started
Container mtusi-lab5-migrate-1 Started
Container mtusi-lab5-migrate-1 Waiting
Container mtusi-lab5-s3-init-1 Waiting
Container mtusi-lab5-postgres-1 Waiting
Container mtusi-lab5-broker-1 Waiting
Container mtusi-lab5-broker-1 Healthy
Container mtusi-lab5-postgres-1 Healthy
Container mtusi-lab5-migrate-1 Exited
Container mtusi-lab5-s3-init-1 Exited
Container mtusi-lab5-api-1 Starting
Container mtusi-lab5-api-1 Started
[exit 0]
+17
View File
@@ -0,0 +1,17 @@
# jobs-broker-down
# date: 2026-11-11T23:55:16 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario broker-down
== брокер недоступен: приём не зависит от брокера (transactional outbox) ==
ok - /health/ready = 200: broker is not critical for API
ok - upload → 202 queued while broker is down (2.1s, publish timeout ≤ 2s)
ok - intent kept in outbox, not published yet
ok - after broker is back: status ready, error_code null
ok - after broker is back: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after broker is back: original byte-for-byte
ok - after broker is back: thumbnail 256x160, sha256 matches
ok - relay published the outbox row when broker came back
[broker-down: 14s]
8 passed, 0 failed
[exit 0]
+15
View File
@@ -0,0 +1,15 @@
# jobs-crash-ack
# date: 2026-11-11T23:56:55 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario crash-ack
== crash после COMMIT ready, до ack ==
ok - commit before crash: status ready, error_code null
ok - commit before crash: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - commit before crash: original byte-for-byte
ok - commit before crash: thumbnail 256x160, sha256 matches
ok - unacked message redelivered after restart and acked as no-op
ok - ready recorded once, 3 variants
[crash-ack: 26s]
6 passed, 0 failed
[exit 0]
+17
View File
@@ -0,0 +1,17 @@
# jobs-crash-s3
# date: 2026-11-11T23:56:03 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario crash-s3
== crash после записи в S3, до COMMIT и ack ==
recovered in 26.9s (worker restart + lease expiry)
ok - after crash before ack: status ready, error_code null
ok - after crash before ack: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after crash before ack: original byte-for-byte
ok - after crash before ack: thumbnail 256x160, sha256 matches
ok - same attempt taken over after lease expiry (redelivery, not a new job)
ok - S3 objects from the crashed attempt reused: still exactly 3 variants
events: ['22:56:14.755 accepted 1 api', '22:56:14.773 claimed 1 e4d49d50907a-1', '22:56:39.238 lease_takeover 1 e4d49d50907a-1', '22:56:41.607 ready 1 e4d49d50907a']
[crash-s3: 48s]
6 passed, 0 failed
[exit 0]
+19
View File
@@ -0,0 +1,19 @@
# jobs-lease
# date: 2026-11-11T23:58:48 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario lease
== долгая, но живая задача: heartbeat продлевает аренду ==
ok - job ran 32s > lease 20s, no takeover, attempt 1
== замёрзший worker: аренда истекает, задачу забирают ==
ok - claimed by worker-fault, then it froze (processing)
recovered in 37.3s
ok - after frozen worker: status ready, error_code null
ok - after frozen worker: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after frozen worker: original byte-for-byte
ok - after frozen worker: thumbnail 256x160, sha256 matches
ok - reaper: lease expired → attempt 2 → ready
ok - woken stale worker could not commit (lease_token fencing), result unchanged
[lease: 127s]
8 passed, 0 failed
[exit 0]
+16
View File
@@ -0,0 +1,16 @@
# jobs-outbox
# date: 2026-11-11T23:57:25 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario outbox
== crash API между COMMIT и publish (transactional outbox) ==
ok - client did NOT get 202: API died after COMMIT (got 502)
ok - attachment and job were committed before the crash (1 new)
ok - relay-published job: status ready, error_code null
ok - relay-published job: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - relay-published job: original byte-for-byte
ok - relay-published job: thumbnail 256x160, sha256 matches
ok - outbox row published by relay (no new job created)
[outbox: 20s]
7 passed, 0 failed
[exit 0]
+15
View File
@@ -0,0 +1,15 @@
# jobs-redelivery
# date: 2026-11-11T23:55:34 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario redelivery
== повторная доставка уже ready-задачи ==
published duplicate: 1794437748730-0 {"schema_version": 1, "job_id": "29c2c47f-13f7-4064-ab1e-56d9860223d8", "type": "at
published duplicate: 1794437752117-0 {"schema_version": 1, "job_id": "29c2c47f-13f7-4064-ab1e-56d9860223d8", "type": "at
ok - duplicates: status stays ready, variants unchanged (same sha256)
ok - no second set of variants: rows=3, S3 objects=3
ok - job finished exactly once, attempt unchanged
ok - duplicates acked (no pending messages)
[redelivery: 25s]
4 passed, 0 failed
[exit 0]
+21
View File
@@ -0,0 +1,21 @@
# jobs-registry
# date: 2026-11-12T00:00:58 commit: 276dbda
$ docker compose --env-file .env exec -T api python -m app.replay --list
failed jobs: 0
[exit 0]
$ docker compose --env-file .env exec -T api python -m app.replay --dlq
1794437902645-0 {"job": "{\"attachment_id\":\"3916ea43-cfd7-4506-838a-5b206345e6b4\",\"job_id\":\"0bb5d8ca-8fad-4a3c-974e-1781acfa27e4\"}", "reason": "retry_exhausted (injected_transient)", "source_id": "1794437902611-0", "at": "2026-11-11T22:58:22.645225Z"}
[exit 0]
$ docker compose --env-file .env exec -T api python -m app.tools queue
{"stream_length": 0, "groups": [{"name": "workers", "consumers": 4, "pending": 0, "lag": 0}], "dlq_length": 1, "outbox_unpublished": 0, "jobs_by_status": {"ready": 28}}
[exit 0]
$ docker compose --env-file .env --profile fault stop api-fault worker-fault
Container mtusi-lab5-worker-fault-1 Stopping
Container mtusi-lab5-api-fault-1 Stopping
Container mtusi-lab5-worker-fault-1 Stopped
Container mtusi-lab5-api-fault-1 Stopped
[exit 0]
+22
View File
@@ -0,0 +1,22 @@
# jobs-retry-replay
# date: 2026-11-11T23:57:49 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario retry-replay
== временные ошибки → backoff+jitter → failed → replay ==
ok - after 22s: failed, error_code=retry_exhausted
ok - bounded: 5 attempts, 4 scheduled retries, delays [0.7, 1.1, 3.6, 6.3]
ok - backoff grows 2^n with jitter in [d/2, d] (JOB_BACKOFF_BASE_SECONDS=1)
ok - content of failed → 409 (got 409)
ok - failed attachment cannot be attached → 409 (got 409)
ok - failed job is in the registry (python -m app.replay --list)
ok - explicit replay accepted
ok - after replay: status ready, error_code null
ok - after replay: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after replay: original byte-for-byte
ok - after replay: thumbnail 256x160, sha256 matches
ok - same job_id, attempt 6, replays=1 (audit)
ok - replay of a ready job is refused (no duplicate execution)
[retry-replay: 55s]
13 passed, 0 failed
[exit 0]
+26
View File
@@ -0,0 +1,26 @@
# jobs-worker-down
# date: 2026-11-11T23:54:34 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/jobs.py --base-url http://localhost:8080 --scenario worker-down
== worker остановлен: приём не зависит от обработки ==
ok - upload → 202 queued without worker (0.06s)
ok - still queued after 3 s: API did not resize synchronously
ok - content of queued attachment → 409 (got 409)
ok - thumbnail of queued attachment → 409 (got 409)
ok - message with queued attachment → 201 (got 201)
ok - other messages keep working
ok - job is in the broker stream (len=1), outbox published
== рестарт брокера и API с сохранением volumes ==
ok - after broker restart the message is still there (len=1)
ok - same session, same attachment, still queued
== worker запущен ==
ok - after restart: status ready, error_code null
ok - after restart: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after restart: original byte-for-byte
ok - after restart: thumbnail 256x160, sha256 matches
ok - staging removed after ready (original lives in originals/)
attachment 6297945b-c47d-4659-846b-8a2bba4cedb2, job 41928f68-bbf4-415a-b615-022121ec24f2, events: ['22:54:40.477 accepted 1 api', '22:55:06.052 claimed 1 7f4ae0224d1d-0', '22:55:08.563 ready 1 7f4ae0224d1d']
[worker-down: 38s]
14 passed, 0 failed
[exit 0]
+105
View File
@@ -0,0 +1,105 @@
== позитивный сценарий ==
ok - upload PNG -> 202 (got 202)
ok - 202 queued, variants=[], error_code=null
ok - sha256/size describe the original
ok - no S3 key/bucket in public JSON
ok - upload JPEG with Unicode filename -> 202 (got 202)
ok - filename returned as is (display only)
ok - both become ready (worker)
ok - member downloads PNG -> 200 (got 200)
ok - downloaded bytes are identical (sha256)
ok - true Content-Type image/png
ok - nosniff header
ok - member downloads JPEG (variant=original) -> 200 (got 200)
ok - JPEG bytes and type
ok - message with empty text + 2 attachments -> 201 (got 201)
ok - attachment_ids kept in request order
ok - history shows attachment_ids
ok - text-only POST (lab3) still valid, attachment_ids=[]
ok - member reads metadata -> 200 (got 200)
ok - thumbnail variant exists in lab5 -> 200 (got 200)
ok - unknown variant name -> 400 (got 400)
== доступ ==
ok - outsider GET attachment metadata -> 404 (got 404)
ok - unknown attachment metadata -> 404 (got 404)
ok - outsider GET attachment/content -> 404 (got 404)
ok - unknown attachment/content -> 404 (got 404)
ok - anonymous download -> 401 (got 401)
ok - attachment id is not a UUID -> 400 (got 400)
ok - outsider uploads into foreign chat -> 404 (got 404)
ok - anonymous upload -> 401 (got 401)
== привязка к сообщению ==
ok - eve uploads into her own chat -> 202 (got 202)
ok - alice uploads into her second chat -> 202 (got 202)
ok - foreign attachment_id (eve's chat) in message -> 404 (got 404)
ok - attachment of ANOTHER chat of the same user -> 404 (got 404)
ok - unknown attachment_id -> 404 (got 404)
ok - one valid + one foreign -> whole message rejected -> 404 (got 404)
ok - duplicate attachment_ids -> 400 (got 400)
ok - same UUID in different case is a duplicate -> 400 (got 400)
ok - more than 10 attachment_ids -> 400 (got 400)
ok - attachment_id is not a UUID -> 400 (got 400)
ok - attachment_ids: null -> 400 (got 400)
ok - blank text without attachments -> 400 (got 400)
ok - text field is required -> 400 (got 400)
ok - any member may reference a chat attachment again -> 201 (got 201)
ok - eve attaches alice's file to her own chat -> 404 (got 404)
== идемпотентность с вложениями ==
ok - missing attachment_ids == [] (same Message)
ok - same key, different attachment_ids -> 409 (got 409)
ok - replay with attachments returns the same Message
== размер ==
ok - Content-Length = 10 MiB + 1, body never sent (limit before reading) -> 413 (got 413)
ok - Content-Length = 500 MiB -> 413 (got 413)
ok - chunked body > 10 MiB without Content-Length (stream cut at limit) -> 413 (got 413)
ok - real PNG of 10835273 bytes -> 413 (got 413)
ok - real PNG of 10439723 bytes (≤ 10 MiB) accepted -> 202 (got 202)
ok - big file sha256/size
ok - empty body -> 400 (got 400)
== пиксели ==
ok - decompression bomb 8000x8000 in 62290 bytes -> 413 (got 413)
ok - 40 040 001 pixels (just over the limit) -> 413 (got 413)
== повреждённые файлы ==
ok - truncated PNG -> 415 (got 415)
ok - truncated PNG: error code
ok - PNG with flipped byte (CRC) -> 415 (got 415)
ok - PNG with flipped byte (CRC): error code
ok - PNG signature only -> 415 (got 415)
ok - PNG signature only: error code
ok - PNG header + garbage -> 415 (got 415)
ok - PNG header + garbage: error code
ok - truncated JPEG -> 415 (got 415)
ok - truncated JPEG: error code
ok - JPEG SOI + garbage -> 415 (got 415)
ok - JPEG SOI + garbage: error code
== fuzz: случайные порчи байтов (только 202 или 415, никогда 500) ==
ok - 30 corrupted files -> only 202/415 (got [202, 415])
== подмена MIME ==
ok - PNG bytes sent as image/jpeg -> 415 (got 415)
ok - JPEG bytes sent as image/png -> 415 (got 415)
ok - text renamed to .png -> 415 (got 415)
ok - GIF sent as image/png -> 415 (got 415)
ok - HTML sent as image/jpeg -> 415 (got 415)
ok - PNG with Content-Type image/gif -> 415 (got 415)
ok - PNG with Content-Type application/octet-stream -> 415 (got 415)
ok - PNG with Content-Type text/html -> 415 (got 415)
== опасные filename ==
ok - filename '../../etc/passwd' -> 400 (got 400)
ok - filename 'dir/a.png' -> 400 (got 400)
ok - filename 'C:\\Windows\\a.png' -> 400 (got 400)
ok - filename 'a\x00.png' -> 400 (got 400)
ok - filename 'a\nb.png' -> 400 (got 400)
ok - filename 'tab\t.png' -> 400 (got 400)
ok - filename '\x1b[31mred.png' -> 400 (got 400)
ok - filename 'photo\u202egnp.exe' -> 400 (got 400)
ok - filename '..' -> 400 (got 400)
ok - filename '.' -> 400 (got 400)
ok - filename ' ' -> 400 (got 400)
ok - filename 'xxxxxxxxxxxxxxxxxxxx' -> 400 (got 400)
ok - filename missing -> 400 (got 400)
ok - filename of exactly 255 chars -> 202 (got 202)
ok - filename with spaces, Unicode and punctuation -> 202 (got 202)
ok - media type parameters are ignored -> 202 (got 202)
ok - no 500 and no dropped connection among 100 checked responses
93 passed, 0 failed
+3
View File
@@ -0,0 +1,3 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 143, "failed_attempts": 0, "first_recovery_seconds": 0.114}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+93
View File
@@ -0,0 +1,93 @@
== worker остановлен: приём не зависит от обработки ==
ok - upload → 202 queued without worker (0.02s)
ok - still queued after 3 s: API did not resize synchronously
ok - content of queued attachment → 409 (got 409)
ok - thumbnail of queued attachment → 409 (got 409)
ok - message with queued attachment → 201 (got 201)
ok - other messages keep working
ok - job is in the broker stream (len=1), outbox published
== рестарт брокера и API с сохранением volumes ==
ok - after broker restart the message is still there (len=1)
ok - same session, same attachment, still queued
== worker запущен ==
ok - after restart: status ready, error_code null
ok - after restart: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after restart: original byte-for-byte
ok - after restart: thumbnail 256x160, sha256 matches
ok - staging removed after ready (original lives in originals/)
attachment b442df77-ff58-4ab7-89e9-979b507b38f8, job e2871dfb-6dd2-46c7-8dd1-ce29c7f22558, events: ['01:30:28.325 accepted 1 api', '01:30:37.814 claimed 1 worker-1-0', '01:30:38.282 ready 1 worker-1']
[worker-down: 14s]
== брокер недоступен: приём не зависит от брокера (transactional outbox) ==
ok - /health/ready = 200: broker is not critical for API
ok - upload → 202 queued while broker is down (0.0s, publish timeout ≤ 2s)
ok - intent kept in outbox, not published yet
ok - after broker is back: status ready, error_code null
ok - after broker is back: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after broker is back: original byte-for-byte
ok - after broker is back: thumbnail 256x160, sha256 matches
ok - relay published the outbox row when broker came back
[broker-down: 4s]
== повторная доставка уже ready-задачи ==
published duplicate: 1794436247461-0 {"schema_version": 1, "job_id": "5c7dd513-a5f2-4663-b2ad-c498ea0163e5", "type": "at
published duplicate: 1794436247942-0 {"schema_version": 1, "job_id": "5c7dd513-a5f2-4663-b2ad-c498ea0163e5", "type": "at
ok - duplicates: status stays ready, variants unchanged (same sha256)
ok - no second set of variants: rows=3, S3 objects=3
ok - job finished exactly once, attempt unchanged
ok - duplicates acked (no pending messages)
[redelivery: 7s]
== crash после записи в S3, до COMMIT и ack ==
recovered in 22.7s (worker restart + lease expiry)
ok - after crash before ack: status ready, error_code null
ok - after crash before ack: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after crash before ack: original byte-for-byte
ok - after crash before ack: thumbnail 256x160, sha256 matches
ok - same attempt taken over after lease expiry (redelivery, not a new job)
ok - S3 objects from the crashed attempt reused: still exactly 3 variants
events: ['01:30:56.132 accepted 1 api', '01:30:56.135 claimed 1 worker-fault-1', '01:31:18.241 lease_takeover 1 worker-fault-1', '01:31:18.745 ready 1 worker-fault']
[crash-s3: 27s]
== crash после COMMIT ready, до ack ==
ok - commit before crash: status ready, error_code null
ok - commit before crash: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - commit before crash: original byte-for-byte
ok - commit before crash: thumbnail 256x160, sha256 matches
ok - unacked message redelivered after restart and acked as no-op
ok - ready recorded once, 3 variants
[crash-ack: 8s]
== crash API между COMMIT и publish (transactional outbox) ==
ok - client did NOT get 202: API died after COMMIT (got 502)
ok - attachment and job were committed before the crash (1 new)
ok - relay-published job: status ready, error_code null
ok - relay-published job: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - relay-published job: original byte-for-byte
ok - relay-published job: thumbnail 256x160, sha256 matches
ok - outbox row published by relay (no new job created)
[outbox: 4s]
== временные ошибки → backoff+jitter → failed → replay ==
ok - after 23s: failed, error_code=retry_exhausted
ok - bounded: 5 attempts, 4 scheduled retries, delays [0.6, 1.8, 3.8, 6.4]
ok - backoff grows 2^n with jitter in [d/2, d] (JOB_BACKOFF_BASE_SECONDS=1)
ok - content of failed → 409 (got 409)
ok - failed attachment cannot be attached → 409 (got 409)
ok - failed job is in the registry (python -m app.replay --list)
ok - explicit replay accepted
ok - after replay: status ready, error_code null
ok - after replay: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after replay: original byte-for-byte
ok - after replay: thumbnail 256x160, sha256 matches
ok - same job_id, attempt 6, replays=1 (audit)
ok - replay of a ready job is refused (no duplicate execution)
[retry-replay: 31s]
== долгая, но живая задача: heartbeat продлевает аренду ==
ok - job ran 31s > lease 20s, no takeover, attempt 1
== замёрзший worker: аренда истекает, задачу забирают ==
ok - claimed by worker-fault, then it froze (processing)
recovered in 40.8s
ok - after frozen worker: status ready, error_code null
ok - after frozen worker: variants thumbnail+crop+optimized (['thumbnail', 'crop', 'optimized'])
ok - after frozen worker: original byte-for-byte
ok - after frozen worker: thumbnail 256x160, sha256 matches
ok - reaper: lease expired → attempt 2 → ready
ok - woken stale worker could not commit (lease_token fencing), result unchanged
[lease: 104s]
66 passed, 0 failed
+2
View File
@@ -0,0 +1,2 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+5
View File
@@ -0,0 +1,5 @@
failed jobs: 0
1794436317733-0 {"job": "{\"attachment_id\":\"e8a81276-b5df-45cc-8362-f38abe00a557\",\"job_id\":\"2db55464-1734-40c4-9ce1-05b1db9fb834\"}", "reason": "injected_transient", "source_id": "1794436317728-0", "at": "2026-11-11T22:31:57.733543Z"}
1794436083241-0 {"job": "{\"attachment_id\":\"abc0488f-8870-4a6b-96de-299a6571d281\",\"job_id\":\"900a5962-c5a8-4680-8cfd-d3033df2e16d\"}", "reason": "injected_transient", "source_id": "1794436083233-0", "at": "2026-11-11T22:28:03.241832Z"}
1794435590706-0 {"job": "{\"attachment_id\":\"92896e61-6806-4f6e-b4ac-31c8c7aa1c86\",\"job_id\":\"fae19d4e-898f-4d18-bc22-5dd0dbe3c53a\"}", "reason": "injected_transient", "source_id": "1794435590697-0", "at": "2026-11-11T22:19:50.706703Z"}
{"stream_length": 0, "groups": [{"name": "workers", "consumers": 4, "pending": 0, "lag": 0}], "dlq_length": 3, "outbox_unpublished": 0, "jobs_by_status": {"ready": 70}}
+1
View File
@@ -0,0 +1 @@
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
+59
View File
@@ -0,0 +1,59 @@
== аутентификация ==
ok - wrong password -> 401 + Basic challenge
ok - unknown user -> 401 (same as wrong password)
ok - no token -> 401 + Bearer challenge
ok - X-User-Id alone gives no access
ok - unknown/forged token -> 401
ok - Basic on business endpoint -> 401
ok - X-User-Id cannot override bearer identity
ok - password shorter than 12 -> 400
== logout ==
ok - logout -> 204
ok - token after logout -> 401
ok - second logout -> 401
== гонка регистрации одного username ==
ok - 20 parallel registrations -> one 201, nineteen 409 (got [201, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409])
== ошибки и доступ (из lab1) ==
ok - malformed JSON -> 400
ok - duplicate username -> 409
ok - invalid username 'review123\n' -> 400, not 500 (got 400)
ok - invalid username 'review123\r\n' -> 400, not 500 (got 400)
ok - invalid username ' review123' -> 400, not 500 (got 400)
ok - invalid username 'Review123' -> 400, not 500 (got 400)
ok - invalid username 'ab' -> 400, not 500 (got 400)
ok - blank message -> 400
ok - sender_id in body is rejected
ok - outsider POST to foreign chat -> 404
ok - outsider GET foreign history -> 404
ok - invalid chat uuid -> 400
== пагинация ==
ok - 5 messages / limit 2 -> 3 pages, no duplicates
ok - cursor from another chat -> 400
== Content-Type ==
ok - valid JSON with text/plain -> 415 (got 415)
ok - message with text/plain -> 415 (got 415)
ok - text/plain without token -> 401 first (got 401)
ok - application/json; charset=utf-8 accepted (got 201)
30 passed, 0 failed
== 20 параллельных запросов с одним ключом ==
ok - all parallel repeats -> 201 (got [201])
ok - all responses carry the same message id (1 distinct)
ok - requests were served by >=2 replicas (2)
ok - exactly one message in history
ok - every replay returns the identical Message
== семантика ключа ==
ok - same key, different body -> 409 (got 409)
ok - other JSON formatting = same request (got 201)
ok - same key in another chat is independent
ok - same key from another user is independent
ok - missing Idempotency-Key -> 400 (got 400)
ok - invalid key 'has space'... -> 400 (got 400)
ok - invalid key 'xxxxxxxxxxxx'... -> 400 (got 400)
ok - invalid key 'slash/key'... -> 400 (got 400)
ok - replay without session -> 401, access re-checked (got 401)
== неопределённый результат: клиент повторяет с тем же ключом ==
ok - retry after uncertain result -> 201
ok - still exactly one message
16 passed, 0 failed
+7
View File
@@ -0,0 +1,7 @@
ok normal 320x200 with alpha: ok (0.4s)
ok pixel limit (36 Mp > limit 10 Mp): invalid_image: pixel limit (0.4s)
ok memory limit (36 Mp, RLIMIT_AS 120 MiB): invalid_image: memory limit (0.3s)
ok corrupt/truncated PNG: invalid_image: cannot decode: OSError (0.3s)
ok time limit (hangs 10 s, timeout 2 s): timeout(killed) (2.0s)
5 passed, 0 failed
+19
View File
@@ -0,0 +1,19 @@
# no-local-file
# date: 2026-11-12T00:01:21 commit: 276dbda
$ docker compose --env-file .env exec -T --index 1 api python -m app.tools find-local 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
{"files_scanned": 64, "copies_found": []}
[exit 0]
$ docker compose --env-file .env exec -T --index 2 api python -m app.tools find-local 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
{"files_scanned": 57, "copies_found": []}
[exit 0]
$ docker compose --env-file .env exec -T worker python -m app.tools find-local 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
{"files_scanned": 58, "copies_found": []}
[exit 0]
$ docker inspect -f {{.Name}} mounts={{json .Mounts}} 858c692aadd78f68ceaadb4d8ee90ab48f93af82b843580a957dfb564d076383 96a8e9076e16f4080345c85bcd5f2267e5abe6a8b0e8b47e56d200fbe29ec603
/mtusi-lab5-api-1 mounts=[]
/mtusi-lab5-api-2 mounts=[]
[exit 0]
+44
View File
@@ -0,0 +1,44 @@
# orphans
# date: 2026-11-12T00:01:29 commit: 276dbda
$ docker compose --env-file .env --profile fault up -d api-fault
Container mtusi-lab5-postgres-1 Running
Container mtusi-lab5-postgres-1 Waiting
Container mtusi-lab5-postgres-1 Healthy
Container mtusi-lab5-api-fault-1 Starting
Container mtusi-lab5-api-fault-1 Started
[exit 0]
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/orphans.py --base-url http://localhost:8080 --fault-url http://localhost:8082
ok - fault replica (profile fault) is ready on --fault-url
ok - committed attachment that must survive every cleanup
ok - it is processed to ready (lab5)
baseline: {'objects': 29, 'attachments': 29, 'upload_intents': 0}
== 1. прерванная загрузка ==
ok - no object, no metadata, no journal row after interrupted upload ({'objects': 29, 'attachments': 29, 'upload_intents': 0})
== 2. отказ БД после PUT: немедленная компенсация ==
ok - upload answered 503, not 202 (got 503)
ok - object deleted by compensation, journal clean ({'objects': 29, 'attachments': 29, 'upload_intents': 0})
== 3. процесс убит между PUT и COMMIT ==
ok - client did NOT get 202 (got 502)
ok - orphan object + journal row left behind, no metadata ({'objects': 30, 'attachments': 29, 'upload_intents': 1})
ok - default grace 900 s: fresh upload is NOT touched
ok - dry-run reports 1 object, changes nothing
ok - janitor removed orphan + journal row ({'grace_seconds': 5, 'dry_run': False, 'locked': True, 'intents_expired': 1, 'intents_removed': 1, 'objects_deleted': 1, 'would_delete_objects': 0, 'orphans_found': 0, 'errors': 0, 'duration_ms': 30.5})
ok - second run is a no-op (idempotent)
== 4. объект без журнала (страховочный обход bucket) ==
ok - untracked object planted
ok - scan with grace 1 h ignores a fresh object
ok - scan dry-run finds 1
ok - scan deletes the untracked object ({'grace_seconds': 5, 'dry_run': False, 'locked': True, 'intents_expired': 0, 'intents_removed': 0, 'objects_deleted': 1, 'would_delete_objects': 0, 'orphans_found': 1, 'errors': 0, 'objects_scanned': 30, 'duration_ms': 126.7})
== 5. готовые вложения не тронуты ==
ok - committed attachment still downloads, sha256 matches
ok - published original + metadata, staging cleaned, no journal row ({'staging_object_exists': False, 'original_object_exists': True, 'attachment_row': True, 'attachment_status': 'ready', 'upload_intent': False})
18 passed, 0 failed
[exit 0]
$ docker compose --env-file .env --profile fault stop api-fault
Container mtusi-lab5-api-fault-1 Stopping
Container mtusi-lab5-api-fault-1 Stopped
[exit 0]
+31
View File
@@ -0,0 +1,31 @@
# persistence
# date: 2026-11-12T15:08:19 commit: 276dbda
$ docker compose --env-file .env ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab5-api-1 mtusi-messenger:lab5 "python -m app" api 5 minutes ago Up 4 minutes (healthy) 8080/tcp
mtusi-lab5-api-2 mtusi-messenger:lab5 "python -m app" api 5 minutes ago Up 4 minutes (healthy) 8080/tcp
mtusi-lab5-broker-1 redis:7.4.1-alpine "docker-entrypoint.s…" broker 15 hours ago Up 5 minutes (healthy) 6379/tcp
mtusi-lab5-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 15 hours ago Up 5 minutes (healthy) 127.0.0.1:8080-8082->8080-8082/tcp
mtusi-lab5-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 15 hours ago Up 5 minutes (healthy) 5432/tcp
mtusi-lab5-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 15 hours ago Up 5 minutes (healthy) 6379/tcp
mtusi-lab5-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z "/usr/bin/docker-ent…" s3 15 hours ago Up 3 minutes (healthy) 9000/tcp
mtusi-lab5-worker-1 mtusi-messenger:lab5 "python -m app.worker" worker 4 minutes ago Up 4 minutes (healthy) 8080/tcp
[exit 0]
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe tests/resilience.py --mode persistence --action-script C:\Users\79152\Desktop\mtusi2026lab5\scripts\restart.cmd --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.
[exit 0]
$ docker compose --env-file .env ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab5-api-1 mtusi-messenger:lab5 "python -m app" api 5 minutes ago Up 5 seconds (health: starting) 8080/tcp
mtusi-lab5-api-2 mtusi-messenger:lab5 "python -m app" api 5 minutes ago Up 5 seconds (health: starting) 8080/tcp
mtusi-lab5-broker-1 redis:7.4.1-alpine "docker-entrypoint.s…" broker 15 hours ago Up 6 seconds (healthy) 6379/tcp
mtusi-lab5-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 15 hours ago Up 4 seconds (health: starting) 127.0.0.1:8080-8082->8080-8082/tcp
mtusi-lab5-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 15 hours ago Up 6 seconds (health: starting) 5432/tcp
mtusi-lab5-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 15 hours ago Up 6 seconds (health: starting) 6379/tcp
mtusi-lab5-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z "/usr/bin/docker-ent…" s3 15 hours ago Up 8 seconds (healthy) 9000/tcp
mtusi-lab5-worker-1 mtusi-messenger:lab5 "python -m app.worker" worker 5 minutes ago Up 5 seconds (health: starting) 8080/tcp
[exit 0]
+7
View File
@@ -0,0 +1,7 @@
# queue-drain
# date: 2026-11-12T15:06:34 commit: 276dbda
queue drained in 102.6 s: {'ready': 332}
$ docker compose --env-file .env exec -T api python -m app.tools queue
{"stream_length": 0, "groups": [{"name": "workers", "consumers": 6, "pending": 0, "lag": 0}], "dlq_length": 1, "outbox_unpublished": 0, "jobs_by_status": {"ready": 332}}
[exit 0]
+30
View File
@@ -0,0 +1,30 @@
# s3-bootstrap
# date: 2026-11-12T00:01:07 commit: 276dbda
$ docker compose --env-file .env run --rm s3-init
Container mtusi-lab5-s3-1 Running
Container mtusi-lab5-s3-1 Waiting
Container mtusi-lab5-s3-1 Healthy
Container mtusi-lab5-s3-init-run-a68a74b86415 Creating
Container mtusi-lab5-s3-init-run-a68a74b86415 Created
Bucket created successfully `root/messenger-attachments`.
Access permission for `root/messenger-attachments` is set to `private`
policy lab4-api-rw attached to API user
verified: API user has policy lab4-api-rw
Access permission for `root/messenger-attachments` is `private`
bootstrap done: bucket=messenger-attachments (private), API user restricted by policy lab4-api-rw
[exit 0]
$ docker compose --env-file .env run --rm s3-init
Container mtusi-lab5-s3-1 Running
Container mtusi-lab5-s3-1 Waiting
Container mtusi-lab5-s3-1 Healthy
Container mtusi-lab5-s3-init-run-17a0af6b8ff2 Creating
Container mtusi-lab5-s3-init-run-17a0af6b8ff2 Created
Bucket created successfully `root/messenger-attachments`.
Access permission for `root/messenger-attachments` is set to `private`
policy lab4-api-rw attached to API user
verified: API user has policy lab4-api-rw
Access permission for `root/messenger-attachments` is `private`
bootstrap done: bucket=messenger-attachments (private), API user restricted by policy lab4-api-rw
[exit 0]
+22
View File
@@ -0,0 +1,22 @@
# s3-outage
# date: 2026-11-12T15:04:18 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/s3_outage.py --base-url http://localhost:8080
ok - upload before outage
ok - it is processed to ready before the outage (lab5: 202 → worker)
== MinIO остановлен ==
ok - upload -> 503 unavailable (got 503)
ok - bounded by timeouts, not a hang (6.6 s)
ok - download -> 503 (got 503)
ok - metadata still served from PostgreSQL
ok - text messages still work
ok - message referencing an existing attachment still works (metadata only)
ok - /health/ready = 200 (S3 is not critical for text path)
== MinIO снова работает ==
ok - file uploaded before outage downloads unchanged
ok - uploads work again on all replicas: 4 x 202 in a row after 4.7 s (codes during recovery: [503, 202, 503, 202, 503, 202, 503, 202, 503, 202, 503, 202, 503, 202, 202, 202, 202])
stats: {'objects': 242, 'attachments': 242, 'upload_intents': 1}
ok - janitor cleaned journal rows left by failed uploads ({'grace_seconds': 0, 'dry_run': False, 'locked': True, 'intents_expired': 1, 'intents_removed': 1, 'objects_deleted': 1, 'would_delete_objects': 0, 'orphans_found': 0, 'errors': 0, 'duration_ms': 39.5})
12 passed, 0 failed
[exit 0]
+17
View File
@@ -0,0 +1,17 @@
# s3-private
# date: 2026-11-12T00:01:16 commit: 276dbda
$ docker compose --env-file .env exec -T api python -m app.tools private-check
ok API credentials: GET own object -> 200
ok anonymous GET object -> 403
ok anonymous LIST bucket -> 403
ok anonymous PUT object -> 403
ok API credentials: ListBuckets (no foreign buckets) -> only messenger-attachments
ok API credentials: CreateBucket -> AccessDenied
ok API credentials: PutBucketPolicy (make public) -> AccessDenied
ok API credentials: DeleteBucket -> AccessDenied
8 passed, 0 failed
[exit 0]
127.0.0.1:9000 closed (TimeoutError) ok
127.0.0.1:9001 closed (TimeoutError) ok
+6
View File
@@ -0,0 +1,6 @@
# smoke
# date: 2026-11-11T23:51:45 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe tests/smoke.py --base-url http://localhost:8080
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
[exit 0]
+30
View File
@@ -0,0 +1,30 @@
# stand
# date: 2026-11-11T23:51:42 commit: 276dbda
$ docker compose --env-file .env ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab5-api-1 mtusi-messenger:lab5 "python -m app" api 2 minutes ago Up 2 minutes (healthy) 8080/tcp
mtusi-lab5-api-2 mtusi-messenger:lab5 "python -m app" api 2 minutes ago Up 2 minutes (healthy) 8080/tcp
mtusi-lab5-broker-1 redis:7.4.1-alpine "docker-entrypoint.s…" broker 2 minutes ago Up 2 minutes (healthy) 6379/tcp
mtusi-lab5-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 2 minutes ago Up 2 minutes (healthy) 127.0.0.1:8080-8082->8080-8082/tcp
mtusi-lab5-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 2 minutes ago Up 2 minutes (healthy) 5432/tcp
mtusi-lab5-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 2 minutes ago Up 2 minutes (healthy) 6379/tcp
mtusi-lab5-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z "/usr/bin/docker-ent…" s3 2 minutes ago Up 2 minutes (healthy) 9000/tcp
mtusi-lab5-worker-1 mtusi-messenger:lab5 "python -m app.worker" worker 2 minutes ago Up 2 minutes (healthy) 8080/tcp
[exit 0]
$ docker compose --env-file .env config --images
redis:7.4.1-alpine
haproxy:3.0.5-alpine
mtusi-messenger:lab5
postgres:16.4-alpine
mtusi-messenger:lab5
pgsty/mc:RELEASE.2026-09-16T00-00-00Z
mtusi-messenger:lab5
redis:7.4.1-alpine
pgsty/minio:RELEASE.2026-08-04T00-00-00Z
[exit 0]
$ docker compose --env-file .env exec -T api python -m app.migrate
applied: nothing (up to date)
[exit 0]
+67
View File
@@ -0,0 +1,67 @@
# student-tests
# date: 2026-11-11T23:52:05 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/run.py --base-url http://localhost:8080
== аутентификация ==
ok - wrong password -> 401 + Basic challenge
ok - unknown user -> 401 (same as wrong password)
ok - no token -> 401 + Bearer challenge
ok - X-User-Id alone gives no access
ok - unknown/forged token -> 401
ok - Basic on business endpoint -> 401
ok - X-User-Id cannot override bearer identity
ok - password shorter than 12 -> 400
== logout ==
ok - logout -> 204
ok - token after logout -> 401
ok - second logout -> 401
== гонка регистрации одного username ==
ok - 20 parallel registrations -> one 201, nineteen 409 (got [201, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409, 409])
== ошибки и доступ (из lab1) ==
ok - malformed JSON -> 400
ok - duplicate username -> 409
ok - invalid username 'review123\n' -> 400, not 500 (got 400)
ok - invalid username 'review123\r\n' -> 400, not 500 (got 400)
ok - invalid username ' review123' -> 400, not 500 (got 400)
ok - invalid username 'Review123' -> 400, not 500 (got 400)
ok - invalid username 'ab' -> 400, not 500 (got 400)
ok - blank message -> 400
ok - sender_id in body is rejected
ok - outsider POST to foreign chat -> 404
ok - outsider GET foreign history -> 404
ok - invalid chat uuid -> 400
== пагинация ==
ok - 5 messages / limit 2 -> 3 pages, no duplicates
ok - cursor from another chat -> 400
== Content-Type ==
ok - valid JSON with text/plain -> 415 (got 415)
ok - message with text/plain -> 415 (got 415)
ok - text/plain without token -> 401 first (got 401)
ok - application/json; charset=utf-8 accepted (got 201)
30 passed, 0 failed
[exit 0]
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/idempotency.py --base-url http://localhost:8080
== 20 параллельных запросов с одним ключом ==
ok - all parallel repeats -> 201 (got [201])
ok - all responses carry the same message id (1 distinct)
ok - requests were served by >=2 replicas (2)
ok - exactly one message in history
ok - every replay returns the identical Message
== семантика ключа ==
ok - same key, different body -> 409 (got 409)
ok - other JSON formatting = same request (got 201)
ok - same key in another chat is independent
ok - same key from another user is independent
ok - missing Idempotency-Key -> 400 (got 400)
ok - invalid key 'has space'... -> 400 (got 400)
ok - invalid key 'xxxxxxxxxxxx'... -> 400 (got 400)
ok - invalid key 'slash/key'... -> 400 (got 400)
ok - replay without session -> 401, access re-checked (got 401)
== неопределённый результат: клиент повторяет с тем же ключом ==
ok - retry after uncertain result -> 201
ok - still exactly one message
16 passed, 0 failed
[exit 0]
+391
View File
@@ -0,0 +1,391 @@
{
"file_bytes": 10026876,
"concurrency": 10,
"rounds": 3,
"uploads": 30,
"status_counts": {
"202": 30
},
"sha256_ok": 30,
"instances": [
"215466c2b510",
"e6cf2ec7aa3b"
],
"elapsed_s": 13.39,
"throughput_MiB_s": 21.4,
"latency_s": {
"p50": 4.36,
"max": 4.68
},
"memory_MiB": {
"idle": {
"e6cf2ec7aa3b": {
"usage": 73.8,
"anon": 68.5,
"peak": 141.4
},
"215466c2b510": {
"usage": 73.0,
"anon": 68.3,
"peak": 149.5
}
},
"sampled_peak": {
"e6cf2ec7aa3b": {
"usage": 139.6,
"anon": 90.5
},
"215466c2b510": {
"usage": 141.4,
"anon": 93.7
}
},
"after": {
"e6cf2ec7aa3b": {
"usage": 84.1,
"anon": 78.2,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.3,
"anon": 82.1,
"peak": 151.6
}
},
"max_growth_usage": 68.4,
"max_growth_anon": 25.4,
"cgroup_peak_after": {
"e6cf2ec7aa3b": 146.6,
"215466c2b510": 151.6
}
},
"container_limit_MiB": 256,
"samples": 25,
"raw_samples": [
{
"t": 0.35,
"e6cf2ec7aa3b": {
"usage": 77.7,
"anon": 72.3,
"peak": 141.4
},
"215466c2b510": {
"usage": 75.4,
"anon": 70.8,
"peak": 149.5
}
},
{
"t": 1.03,
"e6cf2ec7aa3b": {
"usage": 88.3,
"anon": 81.9,
"peak": 141.4
},
"215466c2b510": {
"usage": 76.6,
"anon": 71.4,
"peak": 149.5
}
},
{
"t": 1.82,
"e6cf2ec7aa3b": {
"usage": 89.1,
"anon": 83.2,
"peak": 141.4
},
"215466c2b510": {
"usage": 90.2,
"anon": 75.7,
"peak": 149.5
}
},
{
"t": 2.55,
"e6cf2ec7aa3b": {
"usage": 88.2,
"anon": 80.5,
"peak": 141.4
},
"215466c2b510": {
"usage": 130.1,
"anon": 81.4,
"peak": 149.5
}
},
{
"t": 3.22,
"e6cf2ec7aa3b": {
"usage": 96.7,
"anon": 72.2,
"peak": 141.4
},
"215466c2b510": {
"usage": 95.6,
"anon": 81.2,
"peak": 149.5
}
},
{
"t": 3.8,
"e6cf2ec7aa3b": {
"usage": 108.5,
"anon": 75.9,
"peak": 141.4
},
"215466c2b510": {
"usage": 86.7,
"anon": 81.2,
"peak": 149.5
}
},
{
"t": 4.31,
"e6cf2ec7aa3b": {
"usage": 90.8,
"anon": 75.8,
"peak": 141.4
},
"215466c2b510": {
"usage": 86.6,
"anon": 81.2,
"peak": 149.5
}
},
{
"t": 5.23,
"e6cf2ec7aa3b": {
"usage": 83.2,
"anon": 78.9,
"peak": 141.4
},
"215466c2b510": {
"usage": 93.2,
"anon": 87.4,
"peak": 149.5
}
},
{
"t": 6.23,
"e6cf2ec7aa3b": {
"usage": 84.6,
"anon": 79.3,
"peak": 141.4
},
"215466c2b510": {
"usage": 96.5,
"anon": 91.4,
"peak": 149.5
}
},
{
"t": 7.1,
"e6cf2ec7aa3b": {
"usage": 99.1,
"anon": 75.9,
"peak": 141.4
},
"215466c2b510": {
"usage": 100.5,
"anon": 93.7,
"peak": 149.5
}
},
{
"t": 7.73,
"e6cf2ec7aa3b": {
"usage": 119.8,
"anon": 78.0,
"peak": 141.4
},
"215466c2b510": {
"usage": 100.2,
"anon": 81.4,
"peak": 149.5
}
},
{
"t": 8.32,
"e6cf2ec7aa3b": {
"usage": 139.6,
"anon": 87.8,
"peak": 146.6
},
"215466c2b510": {
"usage": 122.5,
"anon": 81.4,
"peak": 149.5
}
},
{
"t": 8.81,
"e6cf2ec7aa3b": {
"usage": 123.9,
"anon": 90.5,
"peak": 146.6
},
"215466c2b510": {
"usage": 132.4,
"anon": 81.5,
"peak": 149.5
}
},
{
"t": 9.53,
"e6cf2ec7aa3b": {
"usage": 87.1,
"anon": 81.0,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.0,
"anon": 81.6,
"peak": 149.5
}
},
{
"t": 10.22,
"e6cf2ec7aa3b": {
"usage": 89.1,
"anon": 82.9,
"peak": 146.6
},
"215466c2b510": {
"usage": 88.0,
"anon": 82.1,
"peak": 149.5
}
},
{
"t": 10.83,
"e6cf2ec7aa3b": {
"usage": 89.4,
"anon": 82.8,
"peak": 146.6
},
"215466c2b510": {
"usage": 88.4,
"anon": 82.1,
"peak": 149.5
}
},
{
"t": 11.42,
"e6cf2ec7aa3b": {
"usage": 90.0,
"anon": 82.9,
"peak": 146.6
},
"215466c2b510": {
"usage": 88.6,
"anon": 82.0,
"peak": 149.5
}
},
{
"t": 12.12,
"e6cf2ec7aa3b": {
"usage": 107.6,
"anon": 82.9,
"peak": 146.6
},
"215466c2b510": {
"usage": 107.8,
"anon": 82.1,
"peak": 149.5
}
},
{
"t": 12.73,
"e6cf2ec7aa3b": {
"usage": 134.3,
"anon": 82.8,
"peak": 146.6
},
"215466c2b510": {
"usage": 141.4,
"anon": 91.3,
"peak": 149.7
}
},
{
"t": 13.21,
"e6cf2ec7aa3b": {
"usage": 134.4,
"anon": 82.9,
"peak": 146.6
},
"215466c2b510": {
"usage": 135.1,
"anon": 93.2,
"peak": 151.6
}
},
{
"t": 13.61,
"e6cf2ec7aa3b": {
"usage": 83.9,
"anon": 78.0,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.4,
"anon": 82.1,
"peak": 151.6
}
},
{
"t": 14.0,
"e6cf2ec7aa3b": {
"usage": 87.6,
"anon": 81.7,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.2,
"anon": 82.1,
"peak": 151.6
}
},
{
"t": 14.51,
"e6cf2ec7aa3b": {
"usage": 94.4,
"anon": 88.6,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.5,
"anon": 82.1,
"peak": 151.6
}
},
{
"t": 14.91,
"e6cf2ec7aa3b": {
"usage": 84.2,
"anon": 78.1,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.4,
"anon": 82.1,
"peak": 151.6
}
},
{
"t": 15.28,
"e6cf2ec7aa3b": {
"usage": 83.9,
"anon": 78.1,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.3,
"anon": 82.1,
"peak": 151.6
}
}
]
}
+586
View File
@@ -0,0 +1,586 @@
{
"file_bytes": 10026613,
"concurrency": 20,
"rounds": 3,
"uploads": 60,
"status_counts": {
"202": 60
},
"sha256_ok": 60,
"instances": [
"215466c2b510",
"e6cf2ec7aa3b"
],
"elapsed_s": 25.05,
"throughput_MiB_s": 22.9,
"latency_s": {
"p50": 7.18,
"max": 8.63
},
"memory_MiB": {
"idle": {
"e6cf2ec7aa3b": {
"usage": 83.9,
"anon": 78.1,
"peak": 147.7
},
"215466c2b510": {
"usage": 99.6,
"anon": 94.4,
"peak": 151.6
}
},
"sampled_peak": {
"e6cf2ec7aa3b": {
"usage": 153.1,
"anon": 107.1
},
"215466c2b510": {
"usage": 146.2,
"anon": 101.9
}
},
"after": {
"e6cf2ec7aa3b": {
"usage": 93.7,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.5,
"anon": 90.3,
"peak": 212.6
}
},
"max_growth_usage": 69.2,
"max_growth_anon": 29.0,
"cgroup_peak_after": {
"e6cf2ec7aa3b": 203.8,
"215466c2b510": 212.6
}
},
"container_limit_MiB": 256,
"samples": 40,
"raw_samples": [
{
"t": 0.6,
"e6cf2ec7aa3b": {
"usage": 87.7,
"anon": 82.9,
"peak": 147.7
},
"215466c2b510": {
"usage": 100.1,
"anon": 94.4,
"peak": 151.6
}
},
{
"t": 1.39,
"e6cf2ec7aa3b": {
"usage": 100.4,
"anon": 94.0,
"peak": 147.7
},
"215466c2b510": {
"usage": 89.9,
"anon": 84.6,
"peak": 151.6
}
},
{
"t": 2.34,
"e6cf2ec7aa3b": {
"usage": 103.4,
"anon": 96.9,
"peak": 147.7
},
"215466c2b510": {
"usage": 91.3,
"anon": 85.0,
"peak": 151.6
}
},
{
"t": 3.2,
"e6cf2ec7aa3b": {
"usage": 106.0,
"anon": 99.4,
"peak": 153.3
},
"215466c2b510": {
"usage": 92.2,
"anon": 85.1,
"peak": 155.1
}
},
{
"t": 3.79,
"e6cf2ec7aa3b": {
"usage": 93.4,
"anon": 87.0,
"peak": 166.3
},
"215466c2b510": {
"usage": 91.2,
"anon": 85.4,
"peak": 183.6
}
},
{
"t": 4.39,
"e6cf2ec7aa3b": {
"usage": 94.8,
"anon": 86.8,
"peak": 186.6
},
"215466c2b510": {
"usage": 97.8,
"anon": 81.0,
"peak": 189.1
}
},
{
"t": 5.0,
"e6cf2ec7aa3b": {
"usage": 98.6,
"anon": 82.7,
"peak": 190.6
},
"215466c2b510": {
"usage": 116.1,
"anon": 81.1,
"peak": 189.1
}
},
{
"t": 5.71,
"e6cf2ec7aa3b": {
"usage": 128.4,
"anon": 86.8,
"peak": 192.6
},
"215466c2b510": {
"usage": 119.8,
"anon": 81.0,
"peak": 189.1
}
},
{
"t": 6.63,
"e6cf2ec7aa3b": {
"usage": 153.1,
"anon": 86.8,
"peak": 194.6
},
"215466c2b510": {
"usage": 146.2,
"anon": 93.0,
"peak": 189.1
}
},
{
"t": 7.2,
"e6cf2ec7aa3b": {
"usage": 137.7,
"anon": 86.9,
"peak": 194.6
},
"215466c2b510": {
"usage": 133.1,
"anon": 94.5,
"peak": 189.1
}
},
{
"t": 7.59,
"e6cf2ec7aa3b": {
"usage": 138.2,
"anon": 86.8,
"peak": 194.6
},
"215466c2b510": {
"usage": 115.8,
"anon": 83.2,
"peak": 189.1
}
},
{
"t": 8.05,
"e6cf2ec7aa3b": {
"usage": 92.7,
"anon": 86.7,
"peak": 194.6
},
"215466c2b510": {
"usage": 88.4,
"anon": 83.2,
"peak": 189.1
}
},
{
"t": 8.91,
"e6cf2ec7aa3b": {
"usage": 94.9,
"anon": 88.3,
"peak": 194.6
},
"215466c2b510": {
"usage": 93.5,
"anon": 87.8,
"peak": 189.1
}
},
{
"t": 9.8,
"e6cf2ec7aa3b": {
"usage": 107.2,
"anon": 100.4,
"peak": 194.6
},
"215466c2b510": {
"usage": 90.6,
"anon": 84.3,
"peak": 189.1
}
},
{
"t": 10.62,
"e6cf2ec7aa3b": {
"usage": 112.1,
"anon": 105.3,
"peak": 194.6
},
"215466c2b510": {
"usage": 92.0,
"anon": 85.4,
"peak": 189.1
}
},
{
"t": 11.42,
"e6cf2ec7aa3b": {
"usage": 101.0,
"anon": 92.8,
"peak": 194.6
},
"215466c2b510": {
"usage": 93.9,
"anon": 85.7,
"peak": 190.7
}
},
{
"t": 12.24,
"e6cf2ec7aa3b": {
"usage": 96.4,
"anon": 87.3,
"peak": 196.8
},
"215466c2b510": {
"usage": 112.5,
"anon": 86.1,
"peak": 191.2
}
},
{
"t": 12.92,
"e6cf2ec7aa3b": {
"usage": 117.1,
"anon": 87.5,
"peak": 196.8
},
"215466c2b510": {
"usage": 121.2,
"anon": 86.8,
"peak": 193.7
}
},
{
"t": 13.72,
"e6cf2ec7aa3b": {
"usage": 139.4,
"anon": 87.5,
"peak": 196.8
},
"215466c2b510": {
"usage": 140.0,
"anon": 97.5,
"peak": 193.7
}
},
{
"t": 14.39,
"e6cf2ec7aa3b": {
"usage": 150.9,
"anon": 89.5,
"peak": 198.8
},
"215466c2b510": {
"usage": 135.7,
"anon": 99.2,
"peak": 193.7
}
},
{
"t": 14.99,
"e6cf2ec7aa3b": {
"usage": 131.9,
"anon": 89.4,
"peak": 198.8
},
"215466c2b510": {
"usage": 133.7,
"anon": 100.6,
"peak": 193.7
}
},
{
"t": 15.37,
"e6cf2ec7aa3b": {
"usage": 131.9,
"anon": 89.5,
"peak": 198.8
},
"215466c2b510": {
"usage": 130.2,
"anon": 88.3,
"peak": 193.7
}
},
{
"t": 15.86,
"e6cf2ec7aa3b": {
"usage": 132.2,
"anon": 89.6,
"peak": 198.8
},
"215466c2b510": {
"usage": 130.4,
"anon": 88.3,
"peak": 193.7
}
},
{
"t": 16.21,
"e6cf2ec7aa3b": {
"usage": 123.1,
"anon": 90.1,
"peak": 198.8
},
"215466c2b510": {
"usage": 130.0,
"anon": 88.3,
"peak": 193.7
}
},
{
"t": 17.13,
"e6cf2ec7aa3b": {
"usage": 105.8,
"anon": 99.8,
"peak": 198.8
},
"215466c2b510": {
"usage": 93.6,
"anon": 88.2,
"peak": 193.7
}
},
{
"t": 18.01,
"e6cf2ec7aa3b": {
"usage": 113.1,
"anon": 106.9,
"peak": 198.8
},
"215466c2b510": {
"usage": 93.5,
"anon": 87.6,
"peak": 193.7
}
},
{
"t": 18.83,
"e6cf2ec7aa3b": {
"usage": 114.2,
"anon": 107.1,
"peak": 198.8
},
"215466c2b510": {
"usage": 96.2,
"anon": 90.2,
"peak": 193.7
}
},
{
"t": 19.73,
"e6cf2ec7aa3b": {
"usage": 101.4,
"anon": 94.7,
"peak": 198.8
},
"215466c2b510": {
"usage": 97.1,
"anon": 90.1,
"peak": 193.7
}
},
{
"t": 20.63,
"e6cf2ec7aa3b": {
"usage": 102.9,
"anon": 94.7,
"peak": 198.8
},
"215466c2b510": {
"usage": 105.2,
"anon": 99.3,
"peak": 195.3
}
},
{
"t": 21.5,
"e6cf2ec7aa3b": {
"usage": 114.6,
"anon": 94.7,
"peak": 203.8
},
"215466c2b510": {
"usage": 108.6,
"anon": 100.3,
"peak": 207.7
}
},
{
"t": 22.21,
"e6cf2ec7aa3b": {
"usage": 128.8,
"anon": 94.6,
"peak": 203.8
},
"215466c2b510": {
"usage": 126.7,
"anon": 101.9,
"peak": 209.1
}
},
{
"t": 22.9,
"e6cf2ec7aa3b": {
"usage": 146.2,
"anon": 94.8,
"peak": 203.8
},
"215466c2b510": {
"usage": 131.3,
"anon": 90.2,
"peak": 212.6
}
},
{
"t": 23.7,
"e6cf2ec7aa3b": {
"usage": 147.4,
"anon": 87.8,
"peak": 203.8
},
"215466c2b510": {
"usage": 136.4,
"anon": 90.1,
"peak": 212.6
}
},
{
"t": 24.43,
"e6cf2ec7aa3b": {
"usage": 113.2,
"anon": 97.6,
"peak": 203.8
},
"215466c2b510": {
"usage": 129.8,
"anon": 90.2,
"peak": 212.6
}
},
{
"t": 25.04,
"e6cf2ec7aa3b": {
"usage": 94.1,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 122.8,
"anon": 90.3,
"peak": 212.6
}
},
{
"t": 25.38,
"e6cf2ec7aa3b": {
"usage": 93.8,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.6,
"anon": 90.3,
"peak": 212.6
}
},
{
"t": 25.8,
"e6cf2ec7aa3b": {
"usage": 93.7,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.9,
"anon": 90.3,
"peak": 212.6
}
},
{
"t": 26.19,
"e6cf2ec7aa3b": {
"usage": 93.8,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.6,
"anon": 90.3,
"peak": 212.6
}
},
{
"t": 26.56,
"e6cf2ec7aa3b": {
"usage": 93.8,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.6,
"anon": 90.2,
"peak": 212.6
}
},
{
"t": 26.97,
"e6cf2ec7aa3b": {
"usage": 93.9,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.6,
"anon": 90.3,
"peak": 212.6
}
}
]
}
+156
View File
@@ -0,0 +1,156 @@
# upload-memory
# date: 2026-11-12T15:04:54 commit: 276dbda
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/upload_memory.py --base-url http://localhost:8080 --concurrency 10 --output evidence/upload-memory-10.json
file: 10026876 bytes (9.56 MiB), sha256 4582d3a7982b…
idle MiB: {'e6cf2ec7aa3b': {'usage': 73.8, 'anon': 68.5, 'peak': 141.4}, '215466c2b510': {'usage': 73.0, 'anon': 68.3, 'peak': 149.5}}
{
"file_bytes": 10026876,
"concurrency": 10,
"rounds": 3,
"uploads": 30,
"status_counts": {
"202": 30
},
"sha256_ok": 30,
"instances": [
"215466c2b510",
"e6cf2ec7aa3b"
],
"elapsed_s": 13.39,
"throughput_MiB_s": 21.4,
"latency_s": {
"p50": 4.36,
"max": 4.68
},
"memory_MiB": {
"idle": {
"e6cf2ec7aa3b": {
"usage": 73.8,
"anon": 68.5,
"peak": 141.4
},
"215466c2b510": {
"usage": 73.0,
"anon": 68.3,
"peak": 149.5
}
},
"sampled_peak": {
"e6cf2ec7aa3b": {
"usage": 139.6,
"anon": 90.5
},
"215466c2b510": {
"usage": 141.4,
"anon": 93.7
}
},
"after": {
"e6cf2ec7aa3b": {
"usage": 84.1,
"anon": 78.2,
"peak": 146.6
},
"215466c2b510": {
"usage": 87.3,
"anon": 82.1,
"peak": 151.6
}
},
"max_growth_usage": 68.4,
"max_growth_anon": 25.4,
"cgroup_peak_after": {
"e6cf2ec7aa3b": 146.6,
"215466c2b510": 151.6
}
},
"container_limit_MiB": 256
}
ok - download c8359ca8 sha256 matches
ok - download fcda2c0f sha256 matches
ok - download 6c733ea4 sha256 matches
ok - all 30 uploads -> 202
ok - sha256 of every upload matches
ok - peak process memory (anon) growth per replica 25.4 MiB < 100 MiB (naive buffering: ≥ 5 × 9.6 MiB × 2)
saved evidence/upload-memory-10.json
6 passed, 0 failed
[exit 0]
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/upload_memory.py --base-url http://localhost:8080 --concurrency 20 --output evidence/upload-memory-20.json
file: 10026613 bytes (9.56 MiB), sha256 8bb6a49a0703…
idle MiB: {'e6cf2ec7aa3b': {'usage': 83.9, 'anon': 78.1, 'peak': 147.7}, '215466c2b510': {'usage': 99.6, 'anon': 94.4, 'peak': 151.6}}
{
"file_bytes": 10026613,
"concurrency": 20,
"rounds": 3,
"uploads": 60,
"status_counts": {
"202": 60
},
"sha256_ok": 60,
"instances": [
"215466c2b510",
"e6cf2ec7aa3b"
],
"elapsed_s": 25.05,
"throughput_MiB_s": 22.9,
"latency_s": {
"p50": 7.18,
"max": 8.63
},
"memory_MiB": {
"idle": {
"e6cf2ec7aa3b": {
"usage": 83.9,
"anon": 78.1,
"peak": 147.7
},
"215466c2b510": {
"usage": 99.6,
"anon": 94.4,
"peak": 151.6
}
},
"sampled_peak": {
"e6cf2ec7aa3b": {
"usage": 153.1,
"anon": 107.1
},
"215466c2b510": {
"usage": 146.2,
"anon": 101.9
}
},
"after": {
"e6cf2ec7aa3b": {
"usage": 93.7,
"anon": 87.9,
"peak": 203.8
},
"215466c2b510": {
"usage": 95.5,
"anon": 90.3,
"peak": 212.6
}
},
"max_growth_usage": 69.2,
"max_growth_anon": 29.0,
"cgroup_peak_after": {
"e6cf2ec7aa3b": 203.8,
"215466c2b510": 212.6
}
},
"container_limit_MiB": 256
}
ok - download 56cafe16 sha256 matches
ok - download 6a3c88ac sha256 matches
ok - download 795dd71a sha256 matches
ok - all 60 uploads -> 202
ok - sha256 of every upload matches
ok - peak process memory (anon) growth per replica 29.0 MiB < 100 MiB (naive buffering: ≥ 10 × 9.6 MiB × 2)
saved evidence/upload-memory-20.json
6 passed, 0 failed
[exit 0]
+12
View File
@@ -0,0 +1,12 @@
# worker-limits
# date: 2026-11-11T23:54:14 commit: 276dbda
$ docker compose --env-file .env exec -T api python -m app.tools limits-selftest
ok normal 320x200 with alpha: ok (3.3s)
ok pixel limit (36 Mp > limit 10 Mp): invalid_image: pixel limit (3.8s)
ok memory limit (36 Mp, RLIMIT_AS 120 MiB): invalid_image: memory limit (2.0s)
ok corrupt/truncated PNG: invalid_image: cannot decode: OSError (2.9s)
ok time limit (hangs 10 s, timeout 2 s): timeout(killed) (2.0s)
5 passed, 0 failed
[exit 0]