Record level 3 evidence and fill in the report

Every grade 3 item of lab 5 is proven on a stand raised from empty
volumes at fe26938: the public smoke passes with 202 queued and a real
256x160 JPEG thumbnail; the suite runs its six grade 3 scenarios and
eight invariants green, including worker down with both API replicas,
the relay and the broker restarted while the job stays in the queue,
a redelivered finished job that changes nothing, an S3 outage that
recovers on attempt 2 and five transient failures that end in
retry_exhausted; the stand evidence shows the queued job with
delivery mode 2, the job id as message id and exactly the contract
fields, 409 before ready and a clean SIGTERM of the relay and the
worker; persistence restarts all eight services with their volumes,
failover keeps 134 writes without errors, and the lab 4 scenarios,
S3 checks, upload faults and container policy still pass.

The report describes the clean clone start, the processes and the
source of truth, what is stored at the moment of 202, the outbox and
relay, the claim, fencing and ack order of the worker, the retry
policy, the failure windows, the broker topology and permissions, the
roles table and the mapping of .env.example.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Artyom
2026-10-29 01:31:07 +03:00
co-authored by Claude Opus 5.5
parent fe2693870e
commit a55bc716c4
17 changed files with 1033 additions and 18 deletions
+14
View File
@@ -0,0 +1,14 @@
date: 2026-10-28T22:23:58Z commit: fe26938
$ make check
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ make validate PYTHON=<venv с requirements-dev.txt>
.venv-validate/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
$ make lint
.venv/bin/ruff check src student-tests scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
154 files already formatted
.venv/bin/ty check src student-tests
All checks passed!
+57
View File
@@ -0,0 +1,57 @@
date: 2026-10-28T22:23:55Z commit: fe26938
host: Apple M4 Max, 16 CPU, 48 GiB RAM, macOS 15.1
docker: 28.3.2, VM: 16 CPU, 8217190400 bytes
compose: 2.38.2-desktop.1
images:
image: ${API_IMAGE:-mtusi-messenger:lab5}
image: ${API_IMAGE:-mtusi-messenger:lab5}
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
image: rustfs/rustfs:1.0.4@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
image: rabbitmq:4.1.8-management-alpine@sha256:54ef5ff505352c1beef05a97ee9bd6ab95b3559a76629ba0119b1d63d8d6e4b2
image: grafana/k6:2.3.0@sha256:2dd4756ec6e14e62778916e1eb850108e4b499304c02df56760fa0bdb0fba0b8
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder
COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime
python in image: Python 3.14.7
haproxy: HAProxy version 3.2.26-3e0f11a 2026/10/14 - https://haproxy.org/
rustfs: rustfs 1.0.4
rabbitmq: 4.1.8
packages (uv.lock):
fastapi 0.141.1
uvicorn 0.54.0
uvicorn-worker 0.4.0
gunicorn 26.2.0
asyncpg 0.32.0
argon2-cffi 25.1.0
pydantic 2.13.5
pydantic-settings 2.15.0
dishka 1.10.1
structlog 26.1.0
redis 8.1.0
aiobotocore 3.10.0
botocore 1.43.117
aiohttp 3.14.5
pillow 13.0.0
faststream 0.7.8
aio-pika 10.2.1
aiormq 7.2.4
dishka-faststream 0.7.0
process users (service uid command):
api 10001 python
broker 100 beam.smp
broker 100 epmd
broker 100 erl_child_setup
broker 100 inet_gethost
broker 100 sh
lb 99 haproxy
postgres 70 postgres
relay 10001 docker-init
relay 10001 python
s3 10001 rustfs
valkey 999 tini
valkey 999 valkey-server
worker 10001 docker-init
worker 10001 python
+10
View File
@@ -0,0 +1,10 @@
{
"ok": true,
"scenario": "failover-upload",
"upload_instance": "db66b246dcf8",
"download_instance": "6f688eb249b1",
"sha256_equal": true,
"hook_seconds": 2.807,
"download_ok_after_seconds": 2.873,
"restored": true
}
+38
View File
@@ -0,0 +1,38 @@
date: 2026-10-28T22:22:11Z commit: fe26938
== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt
6f688eb249b1 running started=2026-10-28T22:22:05.423248042Z finished=2026-10-28T22:21:58.379410261Z
db66b246dcf8 running started=2026-10-28T22:22:05.372051334Z finished=2026-10-28T22:21:58.358450386Z
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:18085"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 134, "failed_attempts": 0, "first_recovery_seconds": 2.852}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
== after: api replicas
6f688eb249b1 running started=2026-10-28T22:22:05.423248042Z finished=2026-10-28T22:21:58.379410261Z
db66b246dcf8 exited started=2026-10-28T22:22:05.372051334Z finished=2026-10-28T22:22:15.636566713Z
== stopped replica: db66b246dcf8; shutdown: signal, drain window with readiness 503, close, exit
{"event":"Handling signal: term","level":"info","ts":"2026-10-28T22:22:13.137381Z"}
{"event":"Draining for 2.0 s","level":"info","ts":"2026-10-28T22:22:13.153115Z"}
{"event":"Draining for 2.0 s","level":"info","ts":"2026-10-28T22:22:13.199627Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"24da035dd1a4415c92593374018243cf","duration_ms":2.055,"event":"request.handled","level":"info","ts":"2026-10-28T22:22:13.995688Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"13aaefddf6b044158fbdafb4ebd4e8a8","duration_ms":0.714,"event":"request.handled","level":"info","ts":"2026-10-28T22:22:14.498227Z"}
{"event":"Shutting down","level":"info","ts":"2026-10-28T22:22:15.159499Z"}
{"event":"Shutting down","level":"info","ts":"2026-10-28T22:22:15.203678Z"}
{"event":"service.stopped","level":"info","ts":"2026-10-28T22:22:15.265766Z"}
{"event":"Finished server process [7]","level":"info","ts":"2026-10-28T22:22:15.266054Z"}
{"event":"service.stopped","level":"info","ts":"2026-10-28T22:22:15.310366Z"}
{"event":"Finished server process [8]","level":"info","ts":"2026-10-28T22:22:15.310673Z"}
{"event":"Worker (pid:7) was sent SIGTERM!","level":"info","ts":"2026-10-28T22:22:15.365320Z"}
{"event":"Worker (pid:8) was sent SIGTERM!","level":"info","ts":"2026-10-28T22:22:15.365493Z"}
{"event":"Shutting down: Master","level":"info","ts":"2026-10-28T22:22:15.467387Z"}
$ scripts/restore.sh
Container mtusi2026lab5-api-1 Running
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-api-2 Started
Container mtusi2026lab5-api-2 Waiting
Container mtusi2026lab5-api-1 Waiting
Container mtusi2026lab5-api-2 Healthy
Container mtusi2026lab5-api-1 Healthy
== after restore
6f688eb249b1 running started=2026-10-28T22:22:05.423248042Z finished=2026-10-28T22:21:58.379410261Z
db66b246dcf8 running started=2026-10-28T22:22:28.448846553Z finished=2026-10-28T22:22:15.636566713Z
+254
View File
@@ -0,0 +1,254 @@
{
"suite": "lab5-pipeline-idempotency",
"started_at": "2026-10-28T22:20:16.079560Z",
"config": {
"base_url": "http://localhost:18085",
"level": 3,
"only": "",
"expect_variants": "thumbnail",
"max_attempts": 5,
"stall_seconds": 15.0,
"compose": "docker compose",
"compose_faults": "docker compose -f compose.yaml -f infra/compose.faults.yaml"
},
"invariants": [
{
"id": "terminal",
"statement": "every 202 reaches its expected terminal state",
"result": "PASS",
"details": {
"accepted": 5
}
},
{
"id": "single_effect",
"statement": "one variant set per (attachment_id, pipeline_version, variant)",
"result": "PASS",
"details": {
"rows": 0
}
},
{
"id": "no_ready_rollback",
"statement": "ready never returns to queued or processing",
"result": "PASS",
"details": {
"traced": 5
}
},
{
"id": "monotonic_publication",
"statement": "published_version only moves forward",
"result": "PASS",
"details": {
"sampled": 2
}
},
{
"id": "bytes_match_metadata",
"statement": "sha256, size and real dimensions match served bytes",
"result": "PASS",
"details": {
"verified": 4
}
},
{
"id": "bounded_attempts",
"statement": "attempt <= JOB_MAX_ATTEMPTS",
"result": "PASS",
"details": {
"rows": 0
}
},
{
"id": "no_orphans",
"statement": "no pending outbox, messages, dead letters, staging, objects",
"result": "PASS",
"details": {
"queues": {
"attachments.process": [
0,
0
],
"attachments.process.dlq": [
0,
0
]
},
"s3": "SKIP: --s3-list is not set"
}
},
{
"id": "no_lost_202",
"statement": "every 202 is present in PostgreSQL and the API",
"result": "PASS",
"details": {
"accepted": 5
}
}
],
"scenarios": [
{
"name": "smoke_pipeline",
"level": 3,
"window": "upload, ready, variants match metadata",
"seconds": 0.3,
"result": "PASS",
"observed": {
"attachment_id": "01a18499-a3b4-71f7-9116-e01ab2e3927b",
"variants": [
"thumbnail"
]
}
},
{
"name": "worker_down_broker_restart",
"level": 3,
"window": "worker down, API and broker restart",
"seconds": 25.2,
"result": "PASS",
"observed": {
"attachment_id": "01a18499-a689-742f-9c5c-bc6196e95b17",
"timeline": [
{
"at": "2026-10-28T22:20:24.579204Z",
"step": "worker stopped"
},
{
"at": "2026-10-28T22:20:24.595477Z",
"step": "upload 202 queued",
"attachment_id": "01a18499-a689-742f-9c5c-bc6196e95b17"
},
{
"at": "2026-10-28T22:20:24.599071Z",
"step": "content 409 while queued"
},
{
"at": "2026-10-28T22:20:24.619147Z",
"step": "message with attachment 201, other messages work",
"message_id": "01a18499-a698-7776-9a20-eacea53325fe"
},
{
"at": "2026-10-28T22:20:31.645448Z",
"step": "job is in the broker queue",
"queues": {
"attachments.process": [
1,
0
],
"attachments.process.dlq": [
0,
0
]
}
},
{
"at": "2026-10-28T22:20:37.799903Z",
"step": "API replicas and relay restarted"
},
{
"at": "2026-10-28T22:20:46.499917Z",
"step": "broker restarted with its volume, job survived",
"queues": {
"attachments.process": [
1,
0
],
"attachments.process.dlq": [
0,
0
]
}
},
{
"at": "2026-10-28T22:20:49.240721Z",
"step": "worker started"
},
{
"at": "2026-10-28T22:20:49.423263Z",
"step": "ready",
"variants": [
"thumbnail"
]
}
]
}
},
{
"name": "duplicate_after_ready",
"level": 3,
"window": "redelivery of a finished job",
"seconds": 3.9,
"result": "PASS",
"observed": {
"attachment_id": "01a1849a-0796-74ec-9ed8-4fdce40fa325",
"events": [
{
"kind": "enqueued",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "done",
"attempt": 1
},
{
"kind": "duplicate_noop",
"attempt": 1
}
]
}
},
{
"name": "poison_image",
"level": 3,
"window": "permanent error without retries",
"seconds": 0.1,
"result": "PASS",
"observed": {
"rejected_by_api": 415
}
},
{
"name": "s3_outage_recovers",
"level": 3,
"window": "transient error with retry",
"seconds": 13.8,
"result": "PASS",
"observed": {
"attachment_id": "01a1849a-18c4-7330-b1d6-a596a0e473c1",
"jobs": [
{
"job_id": "01a1849a-18cf-7463-b86e-697e4a60189d",
"pipeline_version": 1,
"status": "done",
"attempt": 2
}
]
}
},
{
"name": "retry_exhausted",
"level": 3,
"window": "transient error until JOB_MAX_ATTEMPTS",
"seconds": 22.9,
"result": "PASS",
"observed": {
"attachment_id": "01a1849a-5ba2-759c-8166-8c6061753c4b",
"jobs": [
{
"job_id": "01a1849a-5bba-75f8-99bc-cdcfe0dc84d8",
"pipeline_version": 1,
"status": "failed",
"attempt": 5
}
]
}
}
],
"result": "PASS",
"finished_at": "2026-10-28T22:21:35.933583Z"
}
+31
View File
@@ -0,0 +1,31 @@
date: 2026-10-28T22:22:59Z
$ docker compose --profile bench --profile tools config --format json (declared)
service cpus/mem ports secrets volumes networks ro
-------- ---------- ------------------------------- ----------------------------------------------------------------------------------------------------------------------- ----------- ---------------------- -----
api 1/512MiB - cache_url,cursor_secret,database_url,s3_access_key_id,s3_secret_access_key - backend(internal) true
broker 1/512MiB 127.0.0.1:25672 rabbitmq_ops_password,rabbitmq_users broker-data backend(internal),edge true
k6 2/512MiB - - - edge false
lb 1/128MiB 127.0.0.1:18085,127.0.0.1:25085 - - backend(internal),edge true
migrate 0.5/256MiB - database_url - backend(internal) false
postgres 2/1024MiB - postgres_password pgdata backend(internal) false
relay 0.5/192MiB - broker_url_api,database_url,s3_access_key_id,s3_secret_access_key - backend(internal) true
s3 1/512MiB - s3_root_password,s3_root_user s3data backend(internal) true
s3-cli 0.5/64MiB - s3_access_key_id,s3_root_password,s3_root_user,s3_secret_access_key,s3_worker_access_key_id,s3_worker_secret_access_key - backend(internal) true
s3-init 0.5/64MiB - s3_access_key_id,s3_root_password,s3_root_user,s3_secret_access_key,s3_worker_access_key_id,s3_worker_secret_access_key - backend(internal) true
valkey 0.5/128MiB - valkey.conf valkeydata backend(internal) false
worker 2/768MiB - broker_url_worker,database_url,s3_worker_access_key_id,s3_worker_secret_access_key - backend(internal) true
$ docker inspect (running containers: hostname = X-Instance-Id, applied limits)
service hostname cpus memory published
-------- ------------ ---- ------- ---------------------------------------------------
api 6f688eb249b1 1 512MiB
api db66b246dcf8 1 512MiB
broker broker 1 512MiB 127.0.0.1:25672->15672/tcp
lb d708a0029059 1 128MiB 127.0.0.1:18085->8080/tcp,127.0.0.1:25085->8404/tcp
postgres e7a6e449eabf 2 1024MiB
relay 0885d6359cd9 0.5 192MiB
s3 b4c9e833e654 1 512MiB
valkey 49888ec3e02e 0.5 128MiB
worker 7ad814af7027 2 768MiB
PASS: limits, ports, secrets, volumes and networks match the policy
+28
View File
@@ -0,0 +1,28 @@
date: 2026-10-28T22:21:54Z commit: fe26938
== before: service hostname StartedAt status
api 6f688eb249b1 2026-10-28T22:20:34.396543083Z running
api db66b246dcf8 2026-10-28T22:20:34.521180916Z running
broker broker 2026-10-28T22:20:39.316655877Z running
lb d708a0029059 2026-10-28T22:19:55.27440126Z running
migrate 38b5310e7c7c 2026-10-28T22:20:00.936185262Z exited
postgres e7a6e449eabf 2026-10-28T22:19:55.32886151Z running
relay 0885d6359cd9 2026-10-28T22:21:39.877494461Z running
s3 b4c9e833e654 2026-10-28T22:21:01.413311013Z running
s3-init 5ef24dcebc29 2026-10-28T22:20:00.938049221Z exited
valkey 49888ec3e02e 2026-10-28T22:19:55.328408801Z running
worker 7ad814af7027 2026-10-28T22:21:42.661373295Z running
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:18085"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
== after: service hostname StartedAt status
api 6f688eb249b1 2026-10-28T22:22:05.423248042Z running
api db66b246dcf8 2026-10-28T22:22:05.372051334Z running
broker broker 2026-10-28T22:21:59.97632722Z running
lb d708a0029059 2026-10-28T22:22:00.29338672Z running
migrate 38b5310e7c7c 2026-10-28T22:22:04.304560666Z exited
postgres e7a6e449eabf 2026-10-28T22:21:58.878794886Z running
relay 0885d6359cd9 2026-10-28T22:22:05.376045584Z running
s3 b4c9e833e654 2026-10-28T22:21:58.777473761Z running
s3-init 5ef24dcebc29 2026-10-28T22:22:04.305438708Z exited
valkey 49888ec3e02e 2026-10-28T22:21:58.834801636Z running
worker 7ad814af7027 2026-10-28T22:22:05.375153375Z running
+33
View File
@@ -0,0 +1,33 @@
date: 2026-10-28T22:21:36Z
$ docker compose stop -t 10 worker -> 0.5 s, exit code 0
upload -> 202 status=queued id=01a1849a-c0cb-75cb-8da2-32e2345745c8
GET content?variant=original while worker is stopped -> 409
GET content?variant=thumbnail while worker is stopped -> 409
$ rabbitmqctl list_queues -p messenger name messages_ready messages_unacknowledged
name messages_ready messages_unacknowledged
attachments.process 1 0
attachments.process.dlq 0 0
$ rabbitmqadmin get messages -q attachments.process -a ack_requeue_true
+---------------+-------------+-------------+-----------------------+---------------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------+
| payload_bytes | redelivered | exchange | routing_key | message_count | properties | payload | payload_encoding |
+---------------+-------------+-------------+-----------------------+---------------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------+
| 243 | false | attachments | attachment.process.v1 | 0 | app_id: "faststream-0.7.8" | {"type": "attachment.process.v1", "job_id": "01a1849a-c0d7-76df-9824-4555c4e9789b", "attempt": 1, "created_at": "2026-10-28T22:21:36.855941Z", "attachment_id": "01a1849a-c0cb-75cb-8da2-32e2345745c8", "schema_version": 1, "pipeline_version": 1} | string |
| | | | | | content_type: "application/json" | | |
| | | | | | correlation_id: "9a019e51-100d-4c50-ba7f-d75aa580dd18" | | |
| | | | | | delivery_mode: 2 | | |
| | | | | | headers: {} | | |
| | | | | | message_id: "01a1849a-c0d7-76df-9824-4555c4e9789b" | | |
| | | | | | priority: 0 | | |
| | | | | | timestamp: 1793226097 | | |
| | | | | | type: "attachment.process.v1" | | |
| | | | | | | | |
+---------------+-------------+-------------+-----------------------+---------------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------+
payload keys: ['attachment_id', 'attempt', 'created_at', 'job_id', 'pipeline_version', 'schema_version', 'type']
$ docker compose stop -t 10 relay -> 0.5 s, exit code 0
$ docker compose up -d --no-deps --wait relay -> healthy
$ docker compose up -d --no-deps --wait worker -> healthy
after worker start -> status=ready variants=[('thumbnail', 256, 160)]
name messages_ready messages_unacknowledged
attachments.process 0 0
attachments.process.dlq 0 0
PASS: pipeline stand evidence
+39
View File
@@ -0,0 +1,39 @@
{
"ok": true,
"scenario": "s3-outage",
"during_outage": {
"upload": {
"status": 503,
"seconds": 4.511,
"instance": "db66b246dcf8"
},
"metadata": {
"status": 200,
"seconds": 0.004,
"instance": "6f688eb249b1"
},
"download": {
"status": 503,
"seconds": 4.674,
"instance": "db66b246dcf8"
},
"text_message": {
"status": 201,
"seconds": 0.006,
"instance": "6f688eb249b1"
},
"health_ready": {
"status": 200,
"seconds": 0.003,
"instance": "db66b246dcf8"
}
},
"expected": {
"upload": 503,
"download": 503,
"text_message": 201
},
"as_expected": true,
"s3_back_healthy_seconds": 5.741,
"download_after_recovery": "sha256 equal"
}
+95
View File
@@ -0,0 +1,95 @@
== 2026-10-28T22:22:55Z S3 privacy and bootstrap checks
PASS s3: опубликованные host-порты: нет
PASS s3: консоль :9001 внутри контейнера: 000
PASS s3-init: повторный запуск 1: 0
PASS s3-init: повторный запуск 2: 0
PASS s3-init: состояние IAM/bucket не изменилось: same
PASS api: PutObject: allow
PASS api: HeadObject: allow
PASS api: GetObject: allow
PASS api: ListBucket: allow
PASS api: CreateBucket: deny
PASS api: DeleteBucket: deny
PASS api: PutBucketPolicy (public): deny
PASS api: PutBucketLifecycle: deny
PASS api: admin ListUsers: deny
PASS api: PutObject в чужой bucket: deny
PASS api: ListBucket чужого bucket: deny
PASS anonymous: HeadObject: deny
PASS anonymous: ListBucket: deny
PASS anonymous: PutObject: deny
PASS anonymous: прямой HTTP GET объекта из отдельного контейнера: 403
PASS bucket: anonymous policy: private
PASS api: DeleteObject: allow
PASS s3: консоль :9001 из отдельного контейнера сети стенда: connection refused
== IAM/bucket snapshot (без секретов)
{
"items": [
{
"key": "messenger-attachments",
"last_modified": "2026-10-28T22:20:01Z",
"is_dir": true
}
],
"truncated": false
}
{
"path": "root/messenger-attachments",
"permission": "private"
}
{
"name": "messenger-api",
"policy": {
"policy": {
"Statement": [
{
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:AbortMultipartUpload",
"s3:ListMultipartUploadParts"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::messenger-attachments/*"
],
"Sid": "MessengerApiObjects"
},
{
"Action": [
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:GetBucketLocation"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::messenger-attachments"
],
"Sid": "MessengerApiBucket"
}
],
"Version": "2012-10-17"
},
"policy_name": "messenger-api",
}
}
{
"accessKey": "<api-key>",
"status": "enabled",
"policies": [
"messenger-api"
],
"memberOf": []
}
{
"rules": [
{
"id": "abort-incomplete-uploads",
"status": "Enabled",
"prefix": "",
"abortIncompleteMultipartUploadDays": 1
}
]
}
RESULT: PASS
+4
View File
@@ -0,0 +1,4 @@
date: 2026-10-28T22:20:05Z commit: fe26938 BASE_URL=http://localhost:18085
$ make test
python3 tests/smoke.py --base-url "http://localhost:18085"
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
+39
View File
@@ -0,0 +1,39 @@
date: 2026-10-28T22:23:55Z commit: fe26938
$ docker compose --env-file .env config --quiet && echo valid
valid
$ docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'
api mtusi2026lab5-api-1 Up 45 seconds (healthy)
api mtusi2026lab5-api-2 Up 42 seconds (healthy)
broker mtusi2026lab5-broker-1 Up About a minute (healthy) 127.0.0.1:25672->15672/tcp
lb mtusi2026lab5-lb-1 Up About a minute (healthy) 127.0.0.1:18085->8080/tcp, 127.0.0.1:25085->8404/tcp
postgres mtusi2026lab5-postgres-1 Up About a minute (healthy)
relay mtusi2026lab5-relay-1 Up About a minute (healthy)
s3 mtusi2026lab5-s3-1 Up About a minute (healthy)
valkey mtusi2026lab5-valkey-1 Up About a minute (healthy)
worker mtusi2026lab5-worker-1 Up About a minute (healthy)
$ docker compose config | grep -c container_name
0
$ docker port <каждая реплика api> # реплики не публикуют порт
6f688eb249b1: []
db66b246dcf8: []
$ docker inspect: hostname = X-Instance-Id, сети, лимиты CPU (nano) и памяти
api 6f688eb249b1 /mtusi2026lab5-api-1 nets=mtusi2026lab5_backend, cpus=1000000000 mem=536870912 user=10001:10001 ro=true
api db66b246dcf8 /mtusi2026lab5-api-2 nets=mtusi2026lab5_backend, cpus=1000000000 mem=536870912 user=10001:10001 ro=true
broker broker /mtusi2026lab5-broker-1 nets=mtusi2026lab5_backend,mtusi2026lab5_edge, cpus=1000000000 mem=536870912 user=100:101 ro=true
lb d708a0029059 /mtusi2026lab5-lb-1 nets=mtusi2026lab5_backend,mtusi2026lab5_edge, cpus=1000000000 mem=134217728 user=haproxy ro=true
postgres e7a6e449eabf /mtusi2026lab5-postgres-1 nets=mtusi2026lab5_backend, cpus=2000000000 mem=1073741824 user=70:70 ro=false
relay 0885d6359cd9 /mtusi2026lab5-relay-1 nets=mtusi2026lab5_backend, cpus=500000000 mem=201326592 user=10001:10001 ro=true
s3 b4c9e833e654 /mtusi2026lab5-s3-1 nets=mtusi2026lab5_backend, cpus=1000000000 mem=536870912 user=rustfs ro=true
valkey 49888ec3e02e /mtusi2026lab5-valkey-1 nets=mtusi2026lab5_backend, cpus=500000000 mem=134217728 user=999:1000 ro=false
worker 7ad814af7027 /mtusi2026lab5-worker-1 nets=mtusi2026lab5_backend, cpus=2000000000 mem=805306368 user=10001:10001 ro=true
$ curl LB stats: backend api, server status check
api1 UP L7OK 200
api2 UP L7OK 200
BACKEND UP
$ for i in 1..6: curl -D - http://127.0.0.1:18085/health/live | X-Instance-Id
x-instance-id: 6f688eb249b1
x-instance-id: db66b246dcf8
x-instance-id: 6f688eb249b1
x-instance-id: db66b246dcf8
x-instance-id: 6f688eb249b1
x-instance-id: db66b246dcf8
+10
View File
@@ -0,0 +1,10 @@
date: 2026-10-28T22:24:03Z commit: fe26938
$ make student-test
.venv/bin/pytest
........................................................................ [ 18%]
........................................................................ [ 36%]
........................................................................ [ 55%]
........................................................................ [ 73%]
........................................................................ [ 92%]
.............................. [100%]
390 passed, 15 deselected in 65.12s (0:01:05)
+28
View File
@@ -0,0 +1,28 @@
date: 2026-10-28T22:20:06Z commit: fe26938
$ rabbitmqctl list_queues -p messenger name type durable policy messages
name type durable policy messages
attachments.process quorum true attachments-process 0
attachments.process.dlq quorum true attachments-dlq 0
$ rabbitmqctl list_consumers -p messenger
queue_name ack_required prefetch_count
attachments.process true 2
$ rabbitmqctl list_permissions -p messenger
user configure write read
messenger-worker ^$ ^$ ^attachments\.process$
messenger-api ^$ ^attachments$ ^$
messenger-ops .* .* .*
$ rabbitmqctl list_users
user tags
messenger-api []
messenger-worker []
messenger-ops [administrator]
$ docker compose ps
api Up 8 seconds (healthy)
api Up 8 seconds (healthy)
broker Up 14 seconds (healthy) 127.0.0.1:25672->15672/tcp
lb Up 14 seconds (healthy) 127.0.0.1:18085->8080/tcp, 127.0.0.1:25085->8404/tcp
postgres Up 14 seconds (healthy)
relay Up 8 seconds (healthy)
s3 Up 14 seconds (healthy)
valkey Up 14 seconds (healthy)
worker Up 8 seconds (healthy)
+57
View File
@@ -0,0 +1,57 @@
date: 2026-10-28T22:23:04Z commit: fe26938 BASE_URL=http://localhost:18085
============================= test session starts ==============================
collected 5 items
student-tests/stack/test_attachment_faults.py 10 MiB + 1 с Content-Length, тело не отправлено: 413
10 MiB + 1 chunked: 413
PNG 100000×100000 (бомба): 413
PNG 8001×5000: 413
обрезанный PNG: 415
обрезанный JPEG: 415
JPEG как image/png: 415
GIF как image/png: 415
WebP как image/png: 415
текст как image/png: 415
PNG как image/jpeg: 415
пустое тело: 415
application/octet-stream: 415
без Content-Type: 415
filename='../a.png': 400
filename='a/b.png': 400
filename='a\\b.png': 400
filename='a\x00.png': 400
filename='a\x01.png': 400
filename='a\x7f.png': 400
filename='': 400
filename=' ': 400
filename='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: 400
filename=None: 400
посторонний: upload в чужой чат: 404
посторонний: метаданные: 404
посторонний: /content: 404
посторонний: ссылка на чужое вложение: 404
вложение другого чата: 404
неизвестное вложение: 404
11 вложений: 400
повтор вложения: 400
невалидный UUID: 400
пустой текст без вложений: 400
невалидный id вложения: 400
variant=preview: 400
строк вложений в чате: 2 (= ответов 202); ответов в журнале реплик: 54, из них 5xx: 0
.отказ COMMIT после записи объекта: 503 unavailable
сразу после ответа: строка нет, объект HEAD 404
журнал: audit.attachment_discarded reason=compensation
.реплика 6f688eb249b1 убита между PUT и COMMIT, клиент получил 502
реплика db66b246dcf8 убита между PUT и COMMIT, клиент получил 502
остаток после падения: строка pending, объект HEAD 200
остаток после падения: строка pending, объект HEAD 200
старше grace: строка убрана через 24.4 с, объект HEAD 404
моложе grace: строка pending, объект HEAD 200
тот же после сдвига: убран через 3.0 с, объект HEAD 404
готовое вложение в сообщении со сдвинутым created_at скачивается, SHA-256 совпадает
.обрыв после 256 KiB из 5 MiB: статус в журнале реплики [400], намерение None
.тело зависло после 1 KiB: 503 unavailable за 8.00 с
.
============================== 5 passed in 48.80s ==============================