ЛР4: S3-хранилище (MinIO) и вложения

This commit is contained in:
LOSYASH
2026-10-29 19:53:41 +03:00
parent ec540a1a72
commit 92ce8c9a59
70 changed files with 6622 additions and 45 deletions
+107
View File
@@ -0,0 +1,107 @@
# attachments
# date: 2026-10-29T19:34:36 commit: no-git
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe student-tests/attachments.py --base-url http://localhost:8080
== позитивный сценарий ==
ok - upload PNG -> 201 (got 201)
ok - 201 ready, variants=[], error_code=null
ok - sha256/size describe the original
ok - no S3 key/bucket in public JSON
ok - upload JPEG with Unicode filename -> 201 (got 201)
ok - filename returned as is (display only)
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 does not exist in lab4 -> 404 (got 404)
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 -> 201 (got 201)
ok - alice uploads into her second chat -> 201 (got 201)
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 11424141 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: случайные порчи байтов (только 201 или 415, никогда 500) ==
ok - 30 corrupted files -> only 201/415 (got [201, 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 -> 201 (got 201)
ok - filename with spaces, Unicode and punctuation -> 201 (got 201)
ok - media type parameters are ignored -> 201 (got 201)
ok - no 500 and no dropped connection among 99 checked responses
90 passed, 0 failed
[exit 0]
+6
View File
@@ -0,0 +1,6 @@
# check
# date: 2026-10-29T19:34:08 commit: no-git
$ 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]
+52
View File
@@ -0,0 +1,52 @@
# failover
# date: 2026-10-29T19:39:32 commit: no-git
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe tests/resilience.py --mode failover --action-script C:\Users\79152\Downloads\mtusi2026lab4-solution (1)\mtusi2026lab4\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": 113, "failed_attempts": 0, "first_recovery_seconds": 2.028}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
[exit 0]
$ C:\Users\79152\Downloads\mtusi2026lab4-solution (1)\mtusi2026lab4\scripts\restore-api.cmd
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-s3-init-1 Starting
Container mtusi-lab4-migrate-1 Starting
Container mtusi-lab4-migrate-1 Started
Container mtusi-lab4-s3-init-1 Started
Container mtusi-lab4-migrate-1 Waiting
Container mtusi-lab4-s3-init-1 Waiting
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-migrate-1 Exited
Container mtusi-lab4-s3-init-1 Exited
Container mtusi-lab4-api-1 Starting
Container mtusi-lab4-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\Downloads\mtusi2026lab4-solution (1)\mtusi2026lab4\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": 115, "failed_attempts": 0, "first_recovery_seconds": 1.843}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
[exit 0]
$ C:\Users\79152\Downloads\mtusi2026lab4-solution (1)\mtusi2026lab4\scripts\restore-api.cmd
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-migrate-1 Starting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-s3-init-1 Starting
Container mtusi-lab4-s3-init-1 Started
Container mtusi-lab4-migrate-1 Started
Container mtusi-lab4-migrate-1 Waiting
Container mtusi-lab4-s3-init-1 Waiting
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-migrate-1 Exited
Container mtusi-lab4-s3-init-1 Exited
Container mtusi-lab4-api-1 Starting
Container mtusi-lab4-api-1 Started
[exit 0]
+15
View File
@@ -0,0 +1,15 @@
# no-local-file
# date: 2026-10-29T19:36:27 commit: no-git
$ docker compose --env-file .env exec -T --index 1 api python -m app.tools find-local 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
{"files_scanned": 52, "copies_found": []}
[exit 0]
$ docker compose --env-file .env exec -T --index 2 api python -m app.tools find-local 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
{"files_scanned": 52, "copies_found": []}
[exit 0]
$ docker inspect -f {{.Name}} mounts={{json .Mounts}} 807f1011fecb89bb1de9c29b42976ef462f61b37b4acf474f5e3d4123f0b86a2 3b090ba3d3a9293dcef2063f61491adafbe302578252bc499aead98c39dcc3da
/mtusi-lab4-api-1 mounts=[]
/mtusi-lab4-api-2 mounts=[]
[exit 0]
+45
View File
@@ -0,0 +1,45 @@
# orphans
# date: 2026-10-29T19:36:33 commit: no-git
$ docker compose --env-file .env --profile fault up -d api-fault
Container mtusi-lab4-postgres-1 Running
Container mtusi-lab4-api-fault-1 Recreate
Container mtusi-lab4-api-fault-1 Recreated
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-api-fault-1 Starting
Container mtusi-lab4-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
baseline: {'objects': 35, 'attachments': 35, 'upload_intents': 0}
== 1. прерванная загрузка ==
ok - no object, no metadata, no journal row after interrupted upload ({'objects': 35, 'attachments': 35, 'upload_intents': 0})
== 2. отказ БД после PUT: немедленная компенсация ==
ok - upload answered 503, not 201 (got 503)
ok - object deleted by compensation, journal clean ({'objects': 35, 'attachments': 35, 'upload_intents': 0})
== 3. процесс убит между PUT и COMMIT ==
ok - client did NOT get 201 (got 502)
ok - orphan object + journal row left behind, no metadata ({'objects': 36, 'attachments': 35, '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': 33.0})
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': 36, 'duration_ms': 86.7})
== 5. готовые вложения не тронуты ==
ok - committed attachment still downloads, sha256 matches
ok - object + metadata, no journal row ({'object_exists': True, 'attachment_row': True, 'upload_intent': False})
17 passed, 0 failed
[exit 0]
$ docker compose --env-file .env --profile fault stop api-fault
Container mtusi-lab4-api-fault-1 Stopping
Container mtusi-lab4-api-fault-1 Stopped
[exit 0]
+27
View File
@@ -0,0 +1,27 @@
# persistence
# date: 2026-10-29T19:39:19 commit: no-git
$ docker compose --env-file .env ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "python -m app" api 5 minutes ago Up 5 minutes (healthy) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "python -m app" api 5 minutes ago Up 5 minutes (healthy) 8080/tcp
mtusi-lab4-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 20 minutes ago Up 11 minutes (healthy) 127.0.0.1:8080-8082->8080-8082/tcp
mtusi-lab4-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 20 minutes ago Up 11 minutes (healthy) 5432/tcp
mtusi-lab4-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 20 minutes ago Up 11 minutes (healthy) 6379/tcp
mtusi-lab4-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z "/usr/bin/docker-ent…" s3 20 minutes ago Up 51 seconds (healthy) 9000/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\Downloads\mtusi2026lab4-solution (1)\mtusi2026lab4\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-lab4-api-1 mtusi-messenger:lab4 "python -m app" api 5 minutes ago Up 5 seconds (health: starting) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "python -m app" api 5 minutes ago Up 4 seconds (health: starting) 8080/tcp
mtusi-lab4-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 21 minutes ago Up 3 seconds (health: starting) 127.0.0.1:8080-8082->8080-8082/tcp
mtusi-lab4-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 21 minutes ago Up 5 seconds (health: starting) 5432/tcp
mtusi-lab4-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 21 minutes ago Up 7 seconds (healthy) 6379/tcp
mtusi-lab4-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z "/usr/bin/docker-ent…" s3 21 minutes ago Up 5 seconds (health: starting) 9000/tcp
[exit 0]
+30
View File
@@ -0,0 +1,30 @@
# s3-bootstrap
# date: 2026-10-29T19:36:13 commit: no-git
$ docker compose --env-file .env run --rm s3-init
Container mtusi-lab4-s3-1 Running
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-s3-init-run-653b9b4a6219 Creating
Container mtusi-lab4-s3-init-run-653b9b4a6219 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-lab4-s3-1 Running
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-s3-init-run-5831f8c376db Creating
Container mtusi-lab4-s3-init-run-5831f8c376db 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]
+21
View File
@@ -0,0 +1,21 @@
# s3-outage
# date: 2026-10-29T19:49:31 commit: no-git
$ 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
== MinIO остановлен ==
ok - upload -> 503 unavailable (got 503)
ok - bounded by timeouts, not a hang (4.4 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 201 in a row after 5.1 s (codes during recovery: [503, 201, 503, 201, 503, 201, 503, 201, 503, 201, 503, 201, 503, 201, 503, 201, 201, 201, 201])
stats: {'objects': 152, 'attachments': 152, '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': 75.2})
11 passed, 0 failed
[exit 0]
+17
View File
@@ -0,0 +1,17 @@
# s3-private
# date: 2026-10-29T19:36:21 commit: no-git
$ 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-10-29T19:34:10 commit: no-git
$ C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\python.exe tests/smoke.py --base-url http://localhost:8080
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
[exit 0]
+26
View File
@@ -0,0 +1,26 @@
# stand
# date: 2026-10-29T19:49:28 commit: no-git
$ docker compose --env-file .env ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "python -m app" api 9 seconds ago Up 2 seconds (health: starting) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "python -m app" api 9 seconds ago Up 2 seconds (health: starting) 8080/tcp
mtusi-lab4-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 30 minutes ago Up 10 minutes (healthy) 127.0.0.1:8080-8082->8080-8082/tcp
mtusi-lab4-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 31 minutes ago Up 10 minutes (healthy) 5432/tcp
mtusi-lab4-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 31 minutes ago Up 10 minutes (healthy) 6379/tcp
mtusi-lab4-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z "/usr/bin/docker-ent…" s3 31 minutes ago Up 3 minutes (healthy) 9000/tcp
[exit 0]
$ docker compose --env-file .env config --images
pgsty/mc:RELEASE.2026-09-16T00-00-00Z
mtusi-messenger:lab4
postgres:16.4-alpine
haproxy:3.0.5-alpine
redis:7.4.1-alpine
mtusi-messenger:lab4
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]
+62
View File
@@ -0,0 +1,62 @@
# student-tests
# date: 2026-10-29T19:34:17 commit: no-git
$ 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 - 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)
25 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]
+378
View File
@@ -0,0 +1,378 @@
{
"file_bytes": 10026738,
"concurrency": 10,
"rounds": 3,
"uploads": 30,
"status_counts": {
"201": 30
},
"sha256_ok": 30,
"instances": [
"3b090ba3d3a9",
"807f1011fecb"
],
"elapsed_s": 9.54,
"throughput_MiB_s": 30.1,
"latency_s": {
"p50": 2.86,
"max": 3.47
},
"memory_MiB": {
"idle": {
"807f1011fecb": {
"usage": 75.3,
"anon": 70.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 74.7,
"anon": 69.9,
"peak": 214.0
}
},
"sampled_peak": {
"807f1011fecb": {
"usage": 122.8,
"anon": 90.3
},
"3b090ba3d3a9": {
"usage": 128.2,
"anon": 91.1
}
},
"after": {
"807f1011fecb": {
"usage": 84.4,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.7,
"anon": 79.0,
"peak": 214.0
}
},
"max_growth_usage": 53.5,
"max_growth_anon": 21.2,
"cgroup_peak_after": {
"807f1011fecb": 214.2,
"3b090ba3d3a9": 214.0
}
},
"container_limit_MiB": 256,
"samples": 24,
"raw_samples": [
{
"t": 0.28,
"807f1011fecb": {
"usage": 76.4,
"anon": 72.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 75.6,
"anon": 72.2,
"peak": 214.0
}
},
{
"t": 0.95,
"807f1011fecb": {
"usage": 79.7,
"anon": 75.8,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 77.0,
"anon": 73.7,
"peak": 214.0
}
},
{
"t": 1.56,
"807f1011fecb": {
"usage": 90.8,
"anon": 83.6,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 89.4,
"anon": 73.5,
"peak": 214.0
}
},
{
"t": 2.16,
"807f1011fecb": {
"usage": 102.2,
"anon": 87.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 98.1,
"anon": 74.3,
"peak": 214.0
}
},
{
"t": 2.75,
"807f1011fecb": {
"usage": 114.1,
"anon": 90.3,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 119.8,
"anon": 87.8,
"peak": 214.0
}
},
{
"t": 3.24,
"807f1011fecb": {
"usage": 116.8,
"anon": 76.8,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 95.9,
"anon": 91.1,
"peak": 214.0
}
},
{
"t": 3.78,
"807f1011fecb": {
"usage": 85.1,
"anon": 79.5,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 87.1,
"anon": 82.0,
"peak": 214.0
}
},
{
"t": 4.35,
"807f1011fecb": {
"usage": 87.3,
"anon": 81.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 88.4,
"anon": 82.9,
"peak": 214.0
}
},
{
"t": 4.86,
"807f1011fecb": {
"usage": 87.4,
"anon": 81.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 84.9,
"anon": 78.4,
"peak": 214.0
}
},
{
"t": 5.37,
"807f1011fecb": {
"usage": 100.5,
"anon": 76.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 101.5,
"anon": 78.7,
"peak": 214.0
}
},
{
"t": 5.84,
"807f1011fecb": {
"usage": 120.9,
"anon": 78.8,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 128.2,
"anon": 78.8,
"peak": 214.0
}
},
{
"t": 6.24,
"807f1011fecb": {
"usage": 120.8,
"anon": 78.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 119.8,
"anon": 78.7,
"peak": 214.0
}
},
{
"t": 6.86,
"807f1011fecb": {
"usage": 88.0,
"anon": 82.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 87.8,
"anon": 83.3,
"peak": 214.0
}
},
{
"t": 7.46,
"807f1011fecb": {
"usage": 89.9,
"anon": 83.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 89.3,
"anon": 83.2,
"peak": 214.0
}
},
{
"t": 8.05,
"807f1011fecb": {
"usage": 99.3,
"anon": 83.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 95.9,
"anon": 78.9,
"peak": 214.0
}
},
{
"t": 8.76,
"807f1011fecb": {
"usage": 111.1,
"anon": 88.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 109.8,
"anon": 88.0,
"peak": 214.0
}
},
{
"t": 9.26,
"807f1011fecb": {
"usage": 122.8,
"anon": 90.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 121.4,
"anon": 89.0,
"peak": 214.0
}
},
{
"t": 9.66,
"807f1011fecb": {
"usage": 84.6,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 84.1,
"anon": 79.1,
"peak": 214.0
}
},
{
"t": 10.0,
"807f1011fecb": {
"usage": 84.6,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 84.0,
"anon": 79.1,
"peak": 214.0
}
},
{
"t": 10.34,
"807f1011fecb": {
"usage": 84.6,
"anon": 79.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.9,
"anon": 79.1,
"peak": 214.0
}
},
{
"t": 10.68,
"807f1011fecb": {
"usage": 84.5,
"anon": 79.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.6,
"anon": 79.0,
"peak": 214.0
}
},
{
"t": 11.0,
"807f1011fecb": {
"usage": 84.5,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.9,
"anon": 79.0,
"peak": 214.0
}
},
{
"t": 11.34,
"807f1011fecb": {
"usage": 84.6,
"anon": 79.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.8,
"anon": 79.1,
"peak": 214.0
}
},
{
"t": 11.69,
"807f1011fecb": {
"usage": 84.4,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 84.0,
"anon": 79.1,
"peak": 214.0
}
}
]
}
+599
View File
@@ -0,0 +1,599 @@
{
"file_bytes": 10026844,
"concurrency": 20,
"rounds": 3,
"uploads": 60,
"status_counts": {
"201": 60
},
"sha256_ok": 60,
"instances": [
"3b090ba3d3a9",
"807f1011fecb"
],
"elapsed_s": 20.12,
"throughput_MiB_s": 28.5,
"latency_s": {
"p50": 5.39,
"max": 7.81
},
"memory_MiB": {
"idle": {
"807f1011fecb": {
"usage": 84.5,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.8,
"anon": 79.0,
"peak": 214.0
}
},
"sampled_peak": {
"807f1011fecb": {
"usage": 156.0,
"anon": 104.2
},
"3b090ba3d3a9": {
"usage": 156.7,
"anon": 105.5
}
},
"after": {
"807f1011fecb": {
"usage": 92.1,
"anon": 86.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.2,
"anon": 86.4,
"peak": 214.0
}
},
"max_growth_usage": 72.9,
"max_growth_anon": 26.5,
"cgroup_peak_after": {
"807f1011fecb": 214.2,
"3b090ba3d3a9": 214.0
}
},
"container_limit_MiB": 256,
"samples": 41,
"raw_samples": [
{
"t": 0.36,
"807f1011fecb": {
"usage": 87.5,
"anon": 82.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 85.8,
"anon": 80.8,
"peak": 214.0
}
},
{
"t": 0.88,
"807f1011fecb": {
"usage": 92.2,
"anon": 86.3,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 90.6,
"anon": 86.0,
"peak": 214.0
}
},
{
"t": 1.54,
"807f1011fecb": {
"usage": 93.9,
"anon": 87.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 92.6,
"anon": 85.9,
"peak": 214.0
}
},
{
"t": 2.05,
"807f1011fecb": {
"usage": 95.7,
"anon": 88.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 93.5,
"anon": 86.0,
"peak": 214.0
}
},
{
"t": 2.64,
"807f1011fecb": {
"usage": 92.2,
"anon": 83.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 93.6,
"anon": 86.1,
"peak": 214.0
}
},
{
"t": 3.15,
"807f1011fecb": {
"usage": 109.2,
"anon": 83.8,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 113.5,
"anon": 86.2,
"peak": 214.0
}
},
{
"t": 3.83,
"807f1011fecb": {
"usage": 115.8,
"anon": 84.8,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 115.0,
"anon": 86.0,
"peak": 214.0
}
},
{
"t": 4.65,
"807f1011fecb": {
"usage": 123.6,
"anon": 95.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 126.9,
"anon": 95.6,
"peak": 214.0
}
},
{
"t": 5.45,
"807f1011fecb": {
"usage": 131.5,
"anon": 97.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 127.2,
"anon": 97.3,
"peak": 214.0
}
},
{
"t": 6.17,
"807f1011fecb": {
"usage": 122.2,
"anon": 98.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 107.9,
"anon": 86.2,
"peak": 214.0
}
},
{
"t": 7.05,
"807f1011fecb": {
"usage": 90.6,
"anon": 86.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 86.8,
"anon": 82.0,
"peak": 214.0
}
},
{
"t": 7.8,
"807f1011fecb": {
"usage": 91.8,
"anon": 86.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 88.4,
"anon": 84.9,
"peak": 214.0
}
},
{
"t": 8.27,
"807f1011fecb": {
"usage": 93.0,
"anon": 85.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.8,
"anon": 85.8,
"peak": 214.0
}
},
{
"t": 8.75,
"807f1011fecb": {
"usage": 95.9,
"anon": 88.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 93.0,
"anon": 86.8,
"peak": 214.0
}
},
{
"t": 9.26,
"807f1011fecb": {
"usage": 97.0,
"anon": 89.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 95.2,
"anon": 87.8,
"peak": 214.0
}
},
{
"t": 9.74,
"807f1011fecb": {
"usage": 100.2,
"anon": 84.6,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 89.6,
"anon": 80.3,
"peak": 214.0
}
},
{
"t": 10.24,
"807f1011fecb": {
"usage": 117.3,
"anon": 84.6,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 105.5,
"anon": 80.3,
"peak": 214.0
}
},
{
"t": 10.74,
"807f1011fecb": {
"usage": 129.3,
"anon": 86.5,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 125.0,
"anon": 82.2,
"peak": 214.0
}
},
{
"t": 11.34,
"807f1011fecb": {
"usage": 141.8,
"anon": 89.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 135.6,
"anon": 86.4,
"peak": 214.0
}
},
{
"t": 12.14,
"807f1011fecb": {
"usage": 145.7,
"anon": 99.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 151.5,
"anon": 94.2,
"peak": 214.0
}
},
{
"t": 12.63,
"807f1011fecb": {
"usage": 155.6,
"anon": 86.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 156.7,
"anon": 96.7,
"peak": 214.0
}
},
{
"t": 12.97,
"807f1011fecb": {
"usage": 156.0,
"anon": 86.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 144.0,
"anon": 84.4,
"peak": 214.0
}
},
{
"t": 13.31,
"807f1011fecb": {
"usage": 155.8,
"anon": 86.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 143.9,
"anon": 84.4,
"peak": 214.0
}
},
{
"t": 13.65,
"807f1011fecb": {
"usage": 147.0,
"anon": 86.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 134.8,
"anon": 84.4,
"peak": 214.0
}
},
{
"t": 14.01,
"807f1011fecb": {
"usage": 137.7,
"anon": 86.7,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 116.6,
"anon": 84.4,
"peak": 214.0
}
},
{
"t": 14.55,
"807f1011fecb": {
"usage": 93.5,
"anon": 87.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 92.4,
"anon": 87.8,
"peak": 214.0
}
},
{
"t": 15.14,
"807f1011fecb": {
"usage": 98.1,
"anon": 91.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 98.0,
"anon": 92.3,
"peak": 214.0
}
},
{
"t": 15.77,
"807f1011fecb": {
"usage": 99.3,
"anon": 93.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 98.8,
"anon": 92.4,
"peak": 214.0
}
},
{
"t": 16.33,
"807f1011fecb": {
"usage": 101.0,
"anon": 93.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 100.2,
"anon": 92.8,
"peak": 214.0
}
},
{
"t": 16.93,
"807f1011fecb": {
"usage": 117.9,
"anon": 93.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 114.2,
"anon": 93.0,
"peak": 214.0
}
},
{
"t": 17.53,
"807f1011fecb": {
"usage": 133.7,
"anon": 98.9,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 126.9,
"anon": 92.9,
"peak": 214.0
}
},
{
"t": 18.34,
"807f1011fecb": {
"usage": 126.4,
"anon": 103.0,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 116.4,
"anon": 97.7,
"peak": 214.0
}
},
{
"t": 18.94,
"807f1011fecb": {
"usage": 143.1,
"anon": 104.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 139.2,
"anon": 104.1,
"peak": 214.0
}
},
{
"t": 19.64,
"807f1011fecb": {
"usage": 125.4,
"anon": 93.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 135.5,
"anon": 105.5,
"peak": 214.0
}
},
{
"t": 19.98,
"807f1011fecb": {
"usage": 126.2,
"anon": 93.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 116.3,
"anon": 93.1,
"peak": 214.0
}
},
{
"t": 20.32,
"807f1011fecb": {
"usage": 92.1,
"anon": 86.5,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.2,
"anon": 86.4,
"peak": 214.0
}
},
{
"t": 20.66,
"807f1011fecb": {
"usage": 92.1,
"anon": 86.5,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.6,
"anon": 86.4,
"peak": 214.0
}
},
{
"t": 20.99,
"807f1011fecb": {
"usage": 92.0,
"anon": 86.5,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.1,
"anon": 86.4,
"peak": 214.0
}
},
{
"t": 21.34,
"807f1011fecb": {
"usage": 92.1,
"anon": 86.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.4,
"anon": 86.4,
"peak": 214.0
}
},
{
"t": 21.66,
"807f1011fecb": {
"usage": 91.9,
"anon": 86.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.4,
"anon": 86.4,
"peak": 214.0
}
},
{
"t": 21.99,
"807f1011fecb": {
"usage": 91.9,
"anon": 86.5,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.2,
"anon": 86.4,
"peak": 214.0
}
}
]
}
+156
View File
@@ -0,0 +1,156 @@
# upload-memory
# date: 2026-10-29T19:38:36 commit: no-git
$ 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: 10026738 bytes (9.56 MiB), sha256 56a8ce1a2d78…
idle MiB: {'807f1011fecb': {'usage': 75.3, 'anon': 70.2, 'peak': 214.2}, '3b090ba3d3a9': {'usage': 74.7, 'anon': 69.9, 'peak': 214.0}}
{
"file_bytes": 10026738,
"concurrency": 10,
"rounds": 3,
"uploads": 30,
"status_counts": {
"201": 30
},
"sha256_ok": 30,
"instances": [
"3b090ba3d3a9",
"807f1011fecb"
],
"elapsed_s": 9.54,
"throughput_MiB_s": 30.1,
"latency_s": {
"p50": 2.86,
"max": 3.47
},
"memory_MiB": {
"idle": {
"807f1011fecb": {
"usage": 75.3,
"anon": 70.2,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 74.7,
"anon": 69.9,
"peak": 214.0
}
},
"sampled_peak": {
"807f1011fecb": {
"usage": 122.8,
"anon": 90.3
},
"3b090ba3d3a9": {
"usage": 128.2,
"anon": 91.1
}
},
"after": {
"807f1011fecb": {
"usage": 84.4,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.7,
"anon": 79.0,
"peak": 214.0
}
},
"max_growth_usage": 53.5,
"max_growth_anon": 21.2,
"cgroup_peak_after": {
"807f1011fecb": 214.2,
"3b090ba3d3a9": 214.0
}
},
"container_limit_MiB": 256
}
ok - download af982c40 sha256 matches
ok - download 8f84d5ce sha256 matches
ok - download 29e19f9a sha256 matches
ok - all 30 uploads -> 201
ok - sha256 of every upload matches
ok - peak growth per replica 53.5 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: 10026844 bytes (9.56 MiB), sha256 5f839924b002…
idle MiB: {'807f1011fecb': {'usage': 84.5, 'anon': 79.1, 'peak': 214.2}, '3b090ba3d3a9': {'usage': 83.8, 'anon': 79.0, 'peak': 214.0}}
{
"file_bytes": 10026844,
"concurrency": 20,
"rounds": 3,
"uploads": 60,
"status_counts": {
"201": 60
},
"sha256_ok": 60,
"instances": [
"3b090ba3d3a9",
"807f1011fecb"
],
"elapsed_s": 20.12,
"throughput_MiB_s": 28.5,
"latency_s": {
"p50": 5.39,
"max": 7.81
},
"memory_MiB": {
"idle": {
"807f1011fecb": {
"usage": 84.5,
"anon": 79.1,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 83.8,
"anon": 79.0,
"peak": 214.0
}
},
"sampled_peak": {
"807f1011fecb": {
"usage": 156.0,
"anon": 104.2
},
"3b090ba3d3a9": {
"usage": 156.7,
"anon": 105.5
}
},
"after": {
"807f1011fecb": {
"usage": 92.1,
"anon": 86.4,
"peak": 214.2
},
"3b090ba3d3a9": {
"usage": 91.2,
"anon": 86.4,
"peak": 214.0
}
},
"max_growth_usage": 72.9,
"max_growth_anon": 26.5,
"cgroup_peak_after": {
"807f1011fecb": 214.2,
"3b090ba3d3a9": 214.0
}
},
"container_limit_MiB": 256
}
ok - download 86ee3302 sha256 matches
ok - download 4566fa4d sha256 matches
ok - download e1a5b504 sha256 matches
ok - all 60 uploads -> 201
ok - sha256 of every upload matches
ok - peak growth per replica 72.9 MiB < 100 MiB (naive buffering: ≥ 10 × 9.6 MiB × 2)
saved evidence/upload-memory-20.json
6 passed, 0 failed
[exit 0]