forked from mtusi2026/mtusi2026lab5
ЛР 5 — БВТ2302 — Лебедев — на 5
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# 2026-11-21T15:23:04Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc run --rm --no-deps broker-init
|
||||
Container mtusi-lab5-broker-init-run-2468164139ff Creating
|
||||
Container mtusi-lab5-broker-init-run-2468164139ff Created
|
||||
{"ts": "2026-11-21T15:23:06Z", "level": "warning", "logger": "messenger.broker", "msg": "broker disconnected"}
|
||||
{"created": {"stream": false, "consumer": false}, "stream": {"name": "ATTACHMENT_JOBS", "subjects": ["attachments.process.v1"], "storage": "file", "retention": "workqueue", "duplicate_window_s": 120.0, "max_msgs": 100000, "messages": 0}, "consumer": {"durable": "attachment-workers", "ack_policy": "explicit", "ack_wait_s": 20.0, "max_ack_pending": 16, "max_deliver": -1}}
|
||||
exit=0
|
||||
@@ -0,0 +1,5 @@
|
||||
# 2026-11-21T15:23:04Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc logs --no-log-prefix broker-init
|
||||
{"ts": "2026-11-21T15:22:50Z", "level": "warning", "logger": "messenger.broker", "msg": "broker disconnected"}
|
||||
{"created": {"stream": true, "consumer": true}, "stream": {"name": "ATTACHMENT_JOBS", "subjects": ["attachments.process.v1"], "storage": "file", "retention": "workqueue", "duplicate_window_s": 120.0, "max_msgs": 100000, "messages": 0}, "consumer": {"durable": "attachment-workers", "ack_policy": "explicit", "ack_wait_s": 20.0, "max_ack_pending": 16, "max_deliver": -1}}
|
||||
exit=0
|
||||
@@ -0,0 +1,4 @@
|
||||
# 2026-11-21T15:40:37Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc exec -T api python -m messenger stats
|
||||
{"instance_id":"api-0a443c56","version":"dev","ready":true,"draining":false,"app":{"requests":1529,"inflight":0,"idempotent_replays":0,"idempotency_conflicts":0,"uploads_ok":108,"uploads_rejected":15,"uploads_failed":1,"compensations":16,"janitor_removed":0,"outbox_published":124},"memory":{"peak_rss_kib":97668,"rss_kib":65060},"uploads_in_flight":0,"cache":{"hits":485,"misses":8,"errors":2},"pool":{"connections_num":17,"requests_num":3674,"requests_queued":28,"connections_ms":121,"requests_wait_ms":43334,"usage_ms":9324,"connections_lost":2,"connections_errors":12,"requests_errors":13,"pool_min":1,"pool_max":10,"pool_size":3,"pool_available":3,"requests_waiting":0},"broker":{"connected":true,"stream_messages":0,"consumer_pending":0,"ack_pending":0,"redelivered":0}}
|
||||
exit=0
|
||||
@@ -0,0 +1,33 @@
|
||||
# 2026-11-21T15:23:34Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/defense_demo.py
|
||||
15:23:35.314 0 chat 4dcdb279-2424-4565-860f-900398e2132e, users alice/bob (tokens not shown)
|
||||
15:23:36.054 0 mtusi-lab5-api-1 running started=2026-11-21T15:22:56.56987807Z pid=13005
|
||||
15:23:36.054 0 mtusi-lab5-api-2 running started=2026-11-21T15:22:57.106877278Z pid=13141
|
||||
15:23:36.054 0 mtusi-lab5-worker-1 running started=2026-11-21T15:22:56.311098593Z pid=12928
|
||||
15:23:36.054 0 mtusi-lab5-worker-2 running started=2026-11-21T15:22:56.134737576Z pid=12864
|
||||
15:23:36.054 0 mtusi-lab5-nats-1 running started=2026-11-21T15:22:44.137358777Z pid=11928
|
||||
15:23:36.054 2 stop worker: docker compose --env-file .env stop worker
|
||||
15:23:36.977 2 mtusi-lab5-worker-1 exited started=2026-11-21T15:22:56.311098593Z pid=0
|
||||
15:23:36.977 2 mtusi-lab5-worker-2 exited started=2026-11-21T15:22:56.134737576Z pid=0
|
||||
15:23:37.015 2 POST /chats/4dcdb279-2424-4565-860f-900398e2132e/attachments → 202, attachment_id=231b3167-1dfb-4345-afbb-6a975d962b9a status=queued
|
||||
15:23:37.599 2 job_id=9b6b0860-1c02-4b03-adca-415a8e38091b pipeline_version=1 attempt=1 status=queued
|
||||
15:23:37.604 2 GET /attachments/231b3167-1dfb-4345-afbb-6a975d962b9a/content → 409 (conflict)
|
||||
15:23:37.612 2 POST message with queued attachment → 201, message_id=db2f3a6f-a88d-4941-b9d7-49079fbd8879
|
||||
15:23:37.619 2 POST plain message (bob) → 201, message_id=d67bb40a-754f-40ca-893a-cc157aeb568b; history works while worker is down
|
||||
15:23:38.137 2 job published to JetStream: stream_seq=19 (outbox → relay → publish ack)
|
||||
15:23:38.137 3 restart broker (volume natsdata kept) and API replicas: restart nats; restart api
|
||||
15:23:43.631 3 mtusi-lab5-api-1 running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
15:23:43.631 3 mtusi-lab5-api-2 running started=2026-11-21T15:23:42.381599065Z pid=17610
|
||||
15:23:43.631 3 mtusi-lab5-nats-1 running started=2026-11-21T15:23:38.427620937Z pid=17213
|
||||
15:23:43.636 3 after restart: attachment 231b3167-1dfb-4345-afbb-6a975d962b9a status=queued (job survived in PostgreSQL + JetStream)
|
||||
15:23:43.636 3 start worker: docker compose --env-file .env start worker
|
||||
15:23:47.792 3 attachment 231b3167-1dfb-4345-afbb-6a975d962b9a status=ready 1.0s after worker start; variants=['crop 128x128', 'optimized 320x200', 'thumbnail 256x160']
|
||||
15:23:47.901 3 original sha256=c12fddfbf426021c… (= uploaded), thumbnail JPEG (256, 160)
|
||||
15:23:48.432 log 15:23:37.012 enqueued attempt=1 token=None {'outbox_id': 14}
|
||||
15:23:48.432 log 15:23:37.018 published attempt=1 token=None {'relay': 'api-api-cddd41bd', 'duplicate': False, 'outbox_id': 14, 'stream_seq': 19}
|
||||
15:23:48.432 log 15:23:47.045 claimed attempt=1 token=14 {'claims': 1}
|
||||
15:23:48.432 log 15:23:47.335 committed attempt=1 token=14 {'variants': ['crop', 'optimized', 'thumbnail']}
|
||||
15:23:48.432 log 15:23:47.335 published_version_changed attempt=1 token=14 {'to': 1, 'from': None}
|
||||
15:23:48.432 log 15:23:47.341 staging_cleaned attempt=1 token=None {'after': 'ready'}
|
||||
PASS: defense scenario (worker down → 202 → 409 → restart API+broker → worker → ready)
|
||||
exit=0
|
||||
@@ -0,0 +1,6 @@
|
||||
# 2026-11-21T15:24:25Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url http://127.0.0.1:8080
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 138, "failed_attempts": 0, "first_recovery_seconds": 5.074}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
exit=0
|
||||
@@ -0,0 +1,6 @@
|
||||
# 2026-11-21T15:24:50Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url http://127.0.0.1:8080
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 138, "failed_attempts": 0, "first_recovery_seconds": 5.232}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
exit=0
|
||||
@@ -0,0 +1,56 @@
|
||||
== 2026-11-21T15:24:28Z stop-one target=api-634d0596 container=mtusi-lab5-api-2
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:23:42.381599065Z pid=17610
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:22:56.867098647Z pid=13066
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:23:44.721197741Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:22:44.576252101Z pid=12114
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:23:44.329434152Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:23:38.427620937Z pid=17213
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:22:44.007733366Z pid=11858
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:22:44.423287844Z pid=12054
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:22:44.280344188Z pid=11992
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:23:44.506230695Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:23:46.557114723Z pid=18276
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:23:46.419050579Z pid=18221
|
||||
== 2026-11-21T15:24:32Z after stop
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=exited started=2026-11-21T15:23:42.381599065Z pid=0
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:22:56.867098647Z pid=13066
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:23:44.721197741Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:22:44.576252101Z pid=12114
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:23:44.329434152Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:23:38.427620937Z pid=17213
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:22:44.007733366Z pid=11858
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:22:44.423287844Z pid=12054
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:22:44.280344188Z pid=11992
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:23:44.506230695Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:23:46.557114723Z pid=18276
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:23:46.419050579Z pid=18221
|
||||
== 2026-11-21T15:24:52Z stop-one target=api-2d2d52e3 container=mtusi-lab5-api-2
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:24:43.359366441Z pid=23362
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:22:56.867098647Z pid=13066
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:23:44.721197741Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:22:44.576252101Z pid=12114
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:23:44.329434152Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:23:38.427620937Z pid=17213
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:22:44.007733366Z pid=11858
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:22:44.423287844Z pid=12054
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:22:44.280344188Z pid=11992
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:23:44.506230695Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:23:46.557114723Z pid=18276
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:23:46.419050579Z pid=18221
|
||||
== 2026-11-21T15:24:57Z after stop
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=exited started=2026-11-21T15:24:43.359366441Z pid=0
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:22:56.867098647Z pid=13066
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:23:44.721197741Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:22:44.576252101Z pid=12114
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:23:44.329434152Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:23:38.427620937Z pid=17213
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:22:44.007733366Z pid=11858
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:22:44.423287844Z pid=12054
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:22:44.280344188Z pid=11992
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:23:44.506230695Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:23:46.557114723Z pid=18276
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:23:46.419050579Z pid=18221
|
||||
@@ -0,0 +1,9 @@
|
||||
# 2026-11-21T15:23:07Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ sh -c for i in 1 2 3 4 5 6; do curl -s -o /dev/null -D - http://127.0.0.1:8080/health/live | grep -i x-instance-id; done
|
||||
x-instance-id: api-cddd41bd
|
||||
x-instance-id: api-8d3b59a5
|
||||
x-instance-id: api-cddd41bd
|
||||
x-instance-id: api-8d3b59a5
|
||||
x-instance-id: api-cddd41bd
|
||||
x-instance-id: api-8d3b59a5
|
||||
exit=0
|
||||
@@ -0,0 +1,44 @@
|
||||
# 2026-11-21T15:40:33Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc exec -T api python -m messenger jobs failed --limit 20
|
||||
{
|
||||
"failed": [
|
||||
{
|
||||
"job_id": "789c4916-7728-4f0f-a6d6-18981a676bc1",
|
||||
"attachment_id": "f5c5b9ad-f456-4b65-8f00-5d60ded882f8",
|
||||
"pipeline_version": 1,
|
||||
"error_code": "invalid_image",
|
||||
"error_detail": "OSError: broken data stream when reading image file",
|
||||
"attempt": 1,
|
||||
"claims": 1,
|
||||
"replays": 0,
|
||||
"failed_at": "2026-11-21 15:30:26.530405+00:00",
|
||||
"replayable": false
|
||||
},
|
||||
{
|
||||
"job_id": "027b6d97-513c-4b2f-b35a-4d652f958d10",
|
||||
"attachment_id": "fcb75f0f-0521-41a6-ae7d-624c158e4c90",
|
||||
"pipeline_version": 1,
|
||||
"error_code": "invalid_image",
|
||||
"error_detail": "OSError: broken data stream when reading image file",
|
||||
"attempt": 2,
|
||||
"claims": 1,
|
||||
"replays": 1,
|
||||
"failed_at": "2026-11-21 15:23:26.934919+00:00",
|
||||
"replayable": true
|
||||
},
|
||||
{
|
||||
"job_id": "c089979e-c157-4b53-9714-a5b15aa98df9",
|
||||
"attachment_id": "3be3e85b-48e7-45a4-a2cb-7e37c7282de5",
|
||||
"pipeline_version": 1,
|
||||
"error_code": "invalid_image",
|
||||
"error_detail": "OSError: broken data stream when reading image file",
|
||||
"attempt": 1,
|
||||
"claims": 1,
|
||||
"replays": 0,
|
||||
"failed_at": "2026-11-21 15:23:16.858569+00:00",
|
||||
"replayable": true
|
||||
}
|
||||
],
|
||||
"count": 3
|
||||
}
|
||||
exit=0
|
||||
@@ -0,0 +1,24 @@
|
||||
# 2026-11-21T15:40:34Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc exec -T api python -m messenger jobs invariants --settled --verify-bytes
|
||||
{
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 240,
|
||||
"jobs": 249,
|
||||
"variants": 735,
|
||||
"events": 1844,
|
||||
"job_status": {
|
||||
"failed": 3,
|
||||
"ready": 244,
|
||||
"superseded": 2
|
||||
},
|
||||
"attachment_status": {
|
||||
"failed": 3,
|
||||
"ready": 237
|
||||
},
|
||||
"s3_objects": 974
|
||||
}
|
||||
}
|
||||
exit=0
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 5,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.039,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 7619,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 253.639,
|
||||
"successful_latency_ms": {
|
||||
"p50": 13.377,
|
||||
"p95": 33.076,
|
||||
"p99": 53.67
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
# 2026-11-21T15:40:38Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 tests/load.py --base-url http://127.0.0.1:8080 --duration 30 --concurrency 4 --output evidence/load.json
|
||||
{
|
||||
"lab": 5,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.039,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 7619,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 253.639,
|
||||
"successful_latency_ms": {
|
||||
"p50": 13.377,
|
||||
"p95": 33.076,
|
||||
"p99": 53.67
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
exit=0
|
||||
@@ -0,0 +1,5 @@
|
||||
# 2026-11-21T15:23:07Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ make check
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
exit=0
|
||||
@@ -0,0 +1,6 @@
|
||||
# 2026-11-21T15:40:37Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc run --rm --no-deps migrate
|
||||
Container mtusi-lab5-migrate-run-96f08822935e Creating
|
||||
Container mtusi-lab5-migrate-run-96f08822935e Created
|
||||
{"applied": []}
|
||||
exit=0
|
||||
@@ -0,0 +1,18 @@
|
||||
# 2026-11-21T15:23:04Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ sh -c docker compose --env-file .env exec -T postgres psql -U messenger -d messenger -c 'SELECT version, left(checksum,12) AS checksum, applied_at FROM schema_migrations ORDER BY version'; docker compose --env-file .env logs --no-log-prefix migrate
|
||||
version | checksum | applied_at
|
||||
--------------------------------+--------------+-------------------------------
|
||||
0001_init | 64c1576d88cc | 2026-11-21 15:22:50.075369+00
|
||||
0002_cache_invalidation_outbox | fcebf1c9345a | 2026-11-21 15:22:50.07914+00
|
||||
0003_idempotency_keys | e2564612d780 | 2026-11-21 15:22:50.083301+00
|
||||
0004_attachments | 52090521af1b | 2026-11-21 15:22:50.104939+00
|
||||
0005_jobs | 34e5b9a70f4d | 2026-11-21 15:22:50.123839+00
|
||||
(5 rows)
|
||||
|
||||
{"ts": "2026-11-21T15:22:50Z", "level": "info", "logger": "messenger.db", "msg": "migration applied", "version": "0001_init"}
|
||||
{"ts": "2026-11-21T15:22:50Z", "level": "info", "logger": "messenger.db", "msg": "migration applied", "version": "0002_cache_invalidation_outbox"}
|
||||
{"ts": "2026-11-21T15:22:50Z", "level": "info", "logger": "messenger.db", "msg": "migration applied", "version": "0003_idempotency_keys"}
|
||||
{"ts": "2026-11-21T15:22:50Z", "level": "info", "logger": "messenger.db", "msg": "migration applied", "version": "0004_attachments"}
|
||||
{"ts": "2026-11-21T15:22:50Z", "level": "info", "logger": "messenger.db", "msg": "migration applied", "version": "0005_jobs"}
|
||||
{"applied": ["0001_init", "0002_cache_invalidation_outbox", "0003_idempotency_keys", "0004_attachments", "0005_jobs"]}
|
||||
exit=0
|
||||
@@ -0,0 +1,7 @@
|
||||
# 2026-11-21T15:23:06Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ sh -c for c in $(docker compose --env-file .env ps -q api worker); do docker inspect -f '{{.Name}} ReadonlyRootfs={{.HostConfig.ReadonlyRootfs}} Tmpfs={{json .HostConfig.Tmpfs}} Mounts={{range .Mounts}}{{.Type}}:{{.Destination}} {{end}}' $c; done
|
||||
/mtusi-lab5-api-1 ReadonlyRootfs=true Tmpfs={"/tmp":""} Mounts=bind:/run/secrets/broker_url bind:/run/secrets/cache_url bind:/run/secrets/database_url bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key
|
||||
/mtusi-lab5-api-2 ReadonlyRootfs=true Tmpfs={"/tmp":""} Mounts=bind:/run/secrets/broker_url bind:/run/secrets/cache_url bind:/run/secrets/database_url bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key
|
||||
/mtusi-lab5-worker-1 ReadonlyRootfs=true Tmpfs={"/tmp":""} Mounts=bind:/run/secrets/broker_url bind:/run/secrets/database_url bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key
|
||||
/mtusi-lab5-worker-2 ReadonlyRootfs=true Tmpfs={"/tmp":""} Mounts=bind:/run/secrets/broker_url bind:/run/secrets/database_url bind:/run/secrets/s3_access_key_id bind:/run/secrets/s3_secret_access_key
|
||||
exit=0
|
||||
@@ -0,0 +1,5 @@
|
||||
# 2026-11-21T15:25:14Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 tests/resilience.py --mode persistence --action-script scripts/restart.sh --base-url http://127.0.0.1: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
|
||||
@@ -0,0 +1,34 @@
|
||||
== 2026-11-21T15:25:16Z before restart
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:25:07.959187541Z pid=25826
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:22:56.867098647Z pid=13066
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:23:44.721197741Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:22:44.576252101Z pid=12114
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:23:44.329434152Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:23:38.427620937Z pid=17213
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:22:44.007733366Z pid=11858
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:22:44.423287844Z pid=12054
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:22:44.280344188Z pid=11992
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:23:44.506230695Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:23:46.557114723Z pid=18276
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:23:46.419050579Z pid=18221
|
||||
volume mtusi-lab5_natsdata
|
||||
volume mtusi-lab5_pgdata
|
||||
volume mtusi-lab5_s3data
|
||||
== 2026-11-21T15:26:02Z after restart
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:25:54.345126644Z pid=29854
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:25:54.53532924Z pid=29907
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:25:58.211275238Z pid=30413
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:25:59.610227125Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:26:02.057153476Z pid=31075
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:25:59.169787131Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:25:25.613039942Z pid=27831
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:25:25.704366414Z pid=27888
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:25:25.781990749Z pid=27961
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:25:30.606043897Z pid=28182
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:25:59.338677677Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:26:01.567013478Z pid=30940
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:26:01.354029337Z pid=30861
|
||||
volume mtusi-lab5_natsdata
|
||||
volume mtusi-lab5_pgdata
|
||||
volume mtusi-lab5_s3data
|
||||
@@ -0,0 +1,5 @@
|
||||
# 2026-11-21T15:24:43Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ ./scripts/start-replicas.sh
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:24:43.359366441Z pid=23362
|
||||
exit=0
|
||||
@@ -0,0 +1,5 @@
|
||||
# 2026-11-21T15:25:07Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ ./scripts/start-replicas.sh
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:23:42.265739366Z pid=17561
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:25:07.959187541Z pid=25826
|
||||
exit=0
|
||||
@@ -0,0 +1,4 @@
|
||||
# 2026-11-21T15:23:06Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc logs --no-log-prefix s3-init
|
||||
{"bucket": "messenger-attachments", "created": true, "checks": {"anonymous ListObjects": ["403", 403, true], "anonymous GetObject": ["403", 403, true], "anonymous PutObject": ["403", 403, true], "anonymous ListBuckets": ["403", 403, true], "api ListObjects own bucket": ["allowed", "allowed", true], "api CreateBucket": ["AccessDenied", "AccessDenied", true]}}
|
||||
exit=0
|
||||
@@ -0,0 +1,9 @@
|
||||
# 2026-11-21T15:23:06Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc exec -T api python -m messenger s3-check
|
||||
PASS anonymous ListObjects expected=403 got=403
|
||||
PASS anonymous GetObject expected=403 got=403
|
||||
PASS anonymous PutObject expected=403 got=403
|
||||
PASS anonymous ListBuckets expected=403 got=403
|
||||
PASS api ListObjects own bucket expected=allowed got=allowed
|
||||
PASS api CreateBucket expected=AccessDenied got=AccessDenied
|
||||
exit=0
|
||||
@@ -0,0 +1,4 @@
|
||||
# 2026-11-21T15:23:07Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 tests/smoke.py --base-url http://127.0.0.1:8080
|
||||
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
|
||||
exit=0
|
||||
@@ -0,0 +1,44 @@
|
||||
# 2026-11-21T15:23:02Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
docker 29.9.2
|
||||
Docker Compose version v5.6.1
|
||||
CONTAINER REPOSITORY TAG PLATFORM IMAGE ID SIZE CREATED
|
||||
mtusi-lab5-api-1 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-api-2 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-api-ttl-1 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-broker-init-1 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-lb-1 mtusi-local/haproxy 3.0 linux/amd64 c93e4aeed30e 42MB 2 weeks ago
|
||||
mtusi-lab5-migrate-1 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-nats-1 mtusi-local/nats 2.11.9 linux/amd64 60a41f94fec2 60.2MB 49 minutes ago
|
||||
mtusi-lab5-postgres-1 mtusi-local/postgres 16 linux/amd64 2f004dbde9b5 337MB 2 weeks ago
|
||||
mtusi-lab5-redis-1 mtusi-local/redis 7 linux/amd64 01c11b3e9bd0 37.1MB 2 weeks ago
|
||||
mtusi-lab5-s3-1 mtusi-local/seaweedfs 4.52 linux/amd64 97add7389e30 242MB 2 weeks ago
|
||||
mtusi-lab5-s3-init-1 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-worker-1 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
mtusi-lab5-worker-2 mtusi-lab5-api local linux/amd64 c5ae9931d229 2.66GB About a minute ago
|
||||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
||||
mtusi-lab5-api-1 mtusi-lab5-api:local "python -m messenger…" api 20 seconds ago Up 6 seconds (healthy) 8080/tcp
|
||||
mtusi-lab5-api-2 mtusi-lab5-api:local "python -m messenger…" api 20 seconds ago Up 6 seconds (healthy) 8080/tcp
|
||||
mtusi-lab5-api-ttl-1 mtusi-lab5-api:local "python -m messenger…" api-ttl 20 seconds ago Up 6 seconds (healthy) 8080/tcp
|
||||
mtusi-lab5-broker-init-1 mtusi-lab5-api:local "python -m messenger…" broker-init 20 seconds ago Exited (0) 13 seconds ago
|
||||
mtusi-lab5-lb-1 mtusi-local/haproxy:3.0 "haproxy -W -db -f /…" lb 20 seconds ago Up 18 seconds (healthy) 127.0.0.1:8080-8082->8080-8082/tcp, 127.0.0.1:8404->8404/tcp
|
||||
mtusi-lab5-migrate-1 mtusi-lab5-api:local "python -m messenger…" migrate 20 seconds ago Exited (0) 13 seconds ago
|
||||
mtusi-lab5-nats-1 mtusi-local/nats:2.11.9 "/usr/local/bin/nats…" nats 20 seconds ago Up 19 seconds (healthy)
|
||||
mtusi-lab5-postgres-1 mtusi-local/postgres:16 "docker-entrypoint.s…" postgres 20 seconds ago Up 19 seconds (healthy)
|
||||
mtusi-lab5-redis-1 mtusi-local/redis:7 "sh -c 'umask 077\npr…" redis 20 seconds ago Up 19 seconds (healthy)
|
||||
mtusi-lab5-s3-1 mtusi-local/seaweedfs:4.52 "/usr/bin/weed -logt…" s3 20 seconds ago Up 19 seconds (healthy)
|
||||
mtusi-lab5-s3-init-1 mtusi-lab5-api:local "python -m messenger…" s3-init 20 seconds ago Exited (0) 7 seconds ago
|
||||
mtusi-lab5-worker-1 mtusi-lab5-api:local "python -m messenger…" worker 20 seconds ago Up 7 seconds (healthy) 8080/tcp
|
||||
mtusi-lab5-worker-2 mtusi-lab5-api:local "python -m messenger…" worker 20 seconds ago Up 7 seconds (healthy) 8080/tcp
|
||||
api mtusi-lab5-api-1 status=running started=2026-11-21T15:22:56.56987807Z pid=13005
|
||||
api mtusi-lab5-api-2 status=running started=2026-11-21T15:22:57.106877278Z pid=13141
|
||||
api-ttl mtusi-lab5-api-ttl-1 status=running started=2026-11-21T15:22:56.867098647Z pid=13066
|
||||
broker-init mtusi-lab5-broker-init-1 status=exited started=2026-11-21T15:22:49.283392537Z pid=0
|
||||
lb mtusi-lab5-lb-1 status=running started=2026-11-21T15:22:44.576252101Z pid=12114
|
||||
migrate mtusi-lab5-migrate-1 status=exited started=2026-11-21T15:22:49.637569868Z pid=0
|
||||
nats mtusi-lab5-nats-1 status=running started=2026-11-21T15:22:44.137358777Z pid=11928
|
||||
postgres mtusi-lab5-postgres-1 status=running started=2026-11-21T15:22:44.007733366Z pid=11858
|
||||
redis mtusi-lab5-redis-1 status=running started=2026-11-21T15:22:44.423287844Z pid=12054
|
||||
s3 mtusi-lab5-s3-1 status=running started=2026-11-21T15:22:44.280344188Z pid=11992
|
||||
s3-init mtusi-lab5-s3-init-1 status=exited started=2026-11-21T15:22:54.424945871Z pid=0
|
||||
worker mtusi-lab5-worker-1 status=running started=2026-11-21T15:22:56.311098593Z pid=12928
|
||||
worker mtusi-lab5-worker-2 status=running started=2026-11-21T15:22:56.134737576Z pid=12864
|
||||
@@ -0,0 +1,23 @@
|
||||
# 2026-11-21T15:23:54Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_api.py
|
||||
## API, auth, validation, ACL, transactions (http://127.0.0.1:8080)
|
||||
PASS password stored only as scrypt KDF hash; User has no secret fields 0.69s
|
||||
PASS wrong password and unknown user: identical 401 + Basic challenge 1.30s
|
||||
PASS malformed Basic / Bearer on /auth/sessions / body on login 0.01s
|
||||
PASS password with ':' and non-ASCII UTF-8 works (RFC 7617) 0.62s
|
||||
PASS opaque 256-bit token, unique per login, DB stores only SHA-256 1.00s
|
||||
PASS only Bearer accepted; Basic and X-User-Id never authenticate 0.01s
|
||||
PASS logout revokes only the current session; repeat -> 401 1.13s
|
||||
PASS strict JSON validation -> 400 0.03s
|
||||
PASS message text: 4000 code points OK, 4001 / whitespace / sender_id -> 400 0.02s
|
||||
PASS SQL is parameterized: injection payloads stored verbatim 0.01s
|
||||
PASS ACL: outsider gets 404 everywhere (even for invalid body) 0.02s
|
||||
PASS create chat validation: duplicates, caller missing, unknown member 0.01s
|
||||
PASS compound create-chat rolls back on FK failure (no orphan chat) 0.71s chats before=6, failed insert left 0 rows
|
||||
PASS registration race: 20 parallel same username -> exactly one 201 4.19s 201x1, 409x19, rows=1
|
||||
PASS keyset pagination: 120 msgs, varying limit, no gaps/duplicates 0.84s 4 pages
|
||||
PASS chat list: only own chats, ordered, cursor bound to user 0.56s
|
||||
PASS read-after-write: confirmed message visible to next read 0.02s
|
||||
PASS unknown route 404 / wrong method 405 in error format 0.01s
|
||||
summary: 18 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,18 @@
|
||||
# 2026-11-21T15:23:48Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_attachments.py
|
||||
## attachments (http://127.0.0.1:8080)
|
||||
PASS valid PNG and JPEG: 202 queued → ready, byte-exact download by other member 1.63s
|
||||
PASS exactly-near limit (~10 MiB) accepted, Content-Length > limit -> 413 0.67s 10.00 MiB accepted
|
||||
PASS oversize rejected BEFORE body is read (early 413, socket) 0.02s HTTP/1.1 413 Content Too Large in 0.015s, 50 MiB never sent
|
||||
PASS pixel limit: 8000x6000 header -> 413 without decoding 0.08s 0.077s
|
||||
PASS decompression bomb: IDAT inflates beyond declared size -> 415 0.35s 65295-byte file claiming 64 MiB raw, rejected in 0.081s
|
||||
PASS corrupted images -> 415 (truncated, bad CRC, no EOI, garbage, empty) 0.18s 9 variants
|
||||
PASS MIME spoofing by Content-Type/filename -> 415 0.05s
|
||||
PASS dangerous/invalid filenames -> 400; filename never becomes a path 0.05s
|
||||
PASS missing/invalid Content-Length -> 400 (chunked upload is not accepted) 0.01s HTTP/1.1 400 Bad Request
|
||||
PASS ACL: outsider gets 404 for upload/metadata/content; anonymous 401 0.41s outsider 10 MiB upload rejected in 0.37s
|
||||
PASS variants (lab5): original/thumbnail/crop/optimized OK after ready, unknown -> 400 0.71s
|
||||
PASS message: foreign/unknown attachment_id -> 404, file of other chat -> 404, limits -> 400 0.13s
|
||||
PASS idempotency includes attachment_ids (replay same, conflict on change) 0.10s
|
||||
summary: 13 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,15 @@
|
||||
# 2026-11-21T15:24:22Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc run --rm --no-deps -T -v /home/claude/work5/mtusi2026lab5/student-tests:/app/student-tests:ro --entrypoint python api student-tests/test_cache_race.py
|
||||
Container mtusi-lab5-api-run-2e97b94809c6 Creating
|
||||
Container mtusi-lab5-api-run-2e97b94809c6 Created
|
||||
PASS read-through put makes entry readable
|
||||
PASS entry TTL capped by SESSION_CACHE_TTL_SECONDS pttl=59999ms
|
||||
PASS invalidate removes entry
|
||||
PASS late put after logout is refused by tombstone
|
||||
PASS tombstone outlives any cache entry pttl=74999ms
|
||||
PASS entry never outlives session expiry pttl=1199ms
|
||||
PASS expired session not served from cache
|
||||
cache unavailable; falling back to PostgreSQL
|
||||
PASS degraded mode: cache is not read until outbox drained
|
||||
summary: all passed
|
||||
exit=0
|
||||
@@ -0,0 +1,8 @@
|
||||
# 2026-11-21T15:24:13Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_expiry.py
|
||||
## session expiry, SESSION_TTL_SECONDS=2 (http://127.0.0.1:8081)
|
||||
PASS expires_at = now + SESSION_TTL_SECONDS 0.96s remaining 2.00s
|
||||
PASS token valid before expiry, 401 Bearer after (cache warmed) 4.42s
|
||||
PASS re-login after expiry issues a new valid session 4.43s
|
||||
summary: 3 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,7 @@
|
||||
# 2026-11-21T15:31:48Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_failures.py
|
||||
## dependency failures (http://127.0.0.1:8080)
|
||||
PASS Redis down: API bypasses cache via PostgreSQL, no anonymous trust 7.46s fallback latency 0.006s; outbox rows during outage=1, drained after recovery
|
||||
PASS PostgreSQL down: bounded 503 in error format; anonymous still 401 14.36s latency(s)={'ready': 1.51, 'post_message': 2.01, 'history': 2.0, 'login': 2.0, 'register': 2.0}; ready again in 2.0s
|
||||
summary: 2 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,14 @@
|
||||
# 2026-11-21T15:24:07Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_idempotency.py
|
||||
## idempotency across replicas (http://127.0.0.1:8080)
|
||||
PASS sequential replays: same 201 + same Message from different replicas 0.27s replicas=2, rows=1
|
||||
PASS 30 concurrent POSTs, same key + body, via LB -> exactly one message 0.84s per-replica responses {'api-634d0596': 16, 'api-113262fe': 14}, rows=1
|
||||
PASS concurrent same key, two different bodies -> one message, others 201-same or 409 0.85s 201x10, 409x10
|
||||
PASS after commit: different body -> 409; reordered/whitespace JSON -> replay 0.02s
|
||||
PASS scope: user + chat + key (same key elsewhere is independent) 0.03s
|
||||
PASS key format: missing/empty/129 chars/invalid -> 400; 128 chars ok 0.03s
|
||||
PASS failed attempt does not claim the key (400/404 not recorded) 0.02s
|
||||
PASS replay re-checks session and access 0.33s
|
||||
PASS key older than IDEMPOTENCY_TTL_SECONDS is reusable (24 h window) 0.50s
|
||||
summary: 9 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,14 @@
|
||||
# 2026-11-21T15:23:27Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ dc run --rm --no-deps -T -v /home/claude/work5/mtusi2026lab5/student-tests:/app/student-tests:ro --entrypoint python worker student-tests/test_imgproc.py
|
||||
Container mtusi-lab5-worker-run-077411778ce5 Creating
|
||||
Container mtusi-lab5-worker-run-077411778ce5 Created
|
||||
PASS fixture 320×200 → thumbnail 256×160, crop 128×128, optimized WebP 320×200 0.70s
|
||||
PASS rounding down and minimum 1 px: 3000×10 → 256×1, 1280×4 0.25s
|
||||
PASS EXIF orientation 6 applied (400×200 stored → 128×256); orientation tag not copied 0.31s
|
||||
PASS alpha composited on white for JPEG variants; WebP keeps alpha 0.42s
|
||||
PASS metadata removed: EXIF/XMP/ICC of the source are not in any variant 0.35s
|
||||
PASS deterministic output (same bytes on re-run) — basis of idempotent effect; v2 differs 0.91s
|
||||
PASS limits: pixels by header (413-class), memory (RLIMIT_AS), undecodable → permanent 1.35s too_large / resource_limit / invalid_image
|
||||
PASS worker wall-clock timeout kills the subprocess → transient (retry), not a hang 0.50s killed after 0.05s; undecodable → Permanent(invalid_image)
|
||||
summary: 8 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,19 @@
|
||||
# 2026-11-21T15:26:03Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_jobs_failures.py
|
||||
## pipeline failures (http://127.0.0.1:8080)
|
||||
PASS defense: worker stopped → 202 → 409 → message ok → restart API+broker (volumes kept) → worker → ready 22.57s attachment bc50ea5e: stream held 1→1 msgs across restart; ready 1.4s after worker start
|
||||
PASS broker down: upload still 202 (job durable in outbox), ready after broker returns 9.24s 202 with broker stopped; events ['enqueued', 'published', 'claimed']
|
||||
PASS crash between COMMIT and publish: relay of another process publishes, job reaches ready 7.42s api-fault (api-6fbb536e) died after COMMIT; published by relay worker-e1c56e52; events ['enqueued', 'published', 'claimed', 'committed', 'published_version_changed', 'staging_cleaned']
|
||||
PASS crash between publish ack and outbox mark: duplicate publish dropped by Nats-Msg-Id 10.12s second publish: duplicate=true, stream_seq=36; processed once
|
||||
PASS worker crash after claim, before any side effect → lease takeover → ready 22.66s ['enqueued', 'published', 'claimed', 'lease_takeover', 'committed', 'published_version_changed', 'staging_cleaned'] in 22.6s
|
||||
PASS worker crash after S3 writes, before COMMIT → takeover rewrites the same keys, one result 23.00s ['enqueued', 'published', 'claimed', 'lease_takeover', 'committed', 'published_version_changed', 'staging_cleaned'] in 22.8s; keys deterministic: ['crop.jpg', 'optimized.webp', 'thumbnail.jpg']
|
||||
PASS worker crash after COMMIT, before ack → redelivery is a no-op (duplicate_ignored) 21.47s ['enqueued', 'published', 'claimed', 'committed', 'published_version_changed', 'staging_cleaned', 'duplicate_ignored']
|
||||
PASS hung worker (event loop blocked 45 s) loses lease; takeover commits; zombie commit is fenced 46.74s claimed t37 → takeover t38 → committed t38; zombie (t37) → lease_lost
|
||||
PASS long but alive job (35 s > lease 20 s): heartbeat keeps the lease, no takeover, no duplicate 36.82s ready after 36.8s, ['enqueued', 'published', 'claimed', 'committed', 'published_version_changed', 'staging_cleaned']
|
||||
PASS transient errors: retry with backoff + jitter (2 failures), then ready 6.23s delays 1.79s, 3.08s (windows [1,2], [2,4]); actual gaps [1.81, 3.19]; attempts [1, 2, 3]
|
||||
PASS retries exhausted → failed retry_exhausted (in registry) → operator replay → ready 29.16s 5 attempts → retry_exhausted; replay (attempt 6) → ready
|
||||
PASS processing with expired lease and LOST message → reaper requeues → ready 7.64s purged 1 stream msgs; ['claimed', 'committed', 'published_version_changed', 'staging_cleaned']
|
||||
PASS bounded concurrency: never more than replicas × WORKER_CONCURRENCY jobs in processing 14.23s 8 jobs × ~4 s: peak concurrency 4 (limit 4), wall 9.5s
|
||||
PASS staging removed after ready; failed staging kept until retention, then replay refuses honestly 12.24s ready: staging gone, originals/ present; failed: staging kept, removed after retention; replay refused
|
||||
summary: 14 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,13 @@
|
||||
# 2026-11-21T15:23:11Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_pipeline.py
|
||||
## attachment pipeline (http://127.0.0.1:8080)
|
||||
PASS upload → 202 queued snapshot, then ready; original byte-exact; three variants by contract 0.98s ready 0.93s after 202; thumbnail 256×160, crop 128×128, optimized 320×200 WebP
|
||||
PASS big image: optimized fits 1280 without upscale, thumbnail rounds down 0.76s thumbnail 256x170, optimized 1280x852
|
||||
PASS EXIF orientation applied (stored 400×200, orientation 6 → 200×400); tiny image not upscaled 1.35s
|
||||
PASS variant parameter: unknown → 400; default original; outsider → 404 0.66s
|
||||
PASS undecodable image → failed with safe error_code, no retries; content 409; cannot attach (409) 1.70s events ['enqueued', 'published', 'claimed', 'failed']; listed in failed registry
|
||||
PASS queued/processing attachment can be attached to a message right away 0.68s
|
||||
PASS duplicate deliveries of a finished job are no-ops (5 raw duplicates) 5.51s committed ×1, duplicate_ignored ×5, metadata unchanged
|
||||
PASS replay is safe: ready → noop; failed (permanent) → re-executed once, failed again 3.23s ready: noop; failed: replayed (audit by student) → failed again (permanent error)
|
||||
summary: 8 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,10 @@
|
||||
# 2026-11-21T15:30:34Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_storage_failures.py
|
||||
## object storage failures (http://127.0.0.1:8080)
|
||||
PASS bucket is private outside API: anonymous GET/LIST/PUT denied, API key limited 3.88s anon GET 403; s3-check 6/6 PASS
|
||||
PASS S3 down: upload/download 503 fast, text messages and readiness keep working 29.65s 503 in 0.01s/0.01s; after start: reads 4.3s, writes 23.5s
|
||||
PASS interrupted upload: no object and no intent left behind 7.94s objects 2, intents 1 — unchanged
|
||||
PASS uploads rejected at the very end (truncated PNG) leave no staging object (race regression) 7.29s 30 × 415 at finish(); staging objects 2 → 2
|
||||
PASS crash between staging PUT and DB COMMIT: intent recorded, janitor removes object after grace 24.42s orphan staging/e876e2a001f6… removed 13.7s after crash (grace 10 s)
|
||||
summary: 5 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,12 @@
|
||||
# 2026-11-21T15:32:11Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 student-tests/test_pipeline_idempotency.py
|
||||
## track 2: pipeline idempotency (http://127.0.0.1:8080)
|
||||
PASS D: 8 duplicate copies of one job delivered concurrently → one claim, one commit 29.42s 9 deliveries: claimed 1, committed 1, duplicate_ignored 8
|
||||
PASS R: reorder — stale attempts (1, 2) and a future one arrive DURING attempt 3 → ignored 22.35s during attempt 3: attempts 2, 1 → stale_ignored; 9 → stale_ignored(future) + term; one commit
|
||||
PASS C: crash before/after side effect, after COMMIT, hung worker — all reach one result 63.92s {'crash-before-s3': 'takeover', 'crash-after-s3': 'takeover', 'crash-after-commit': 'takeover', 'hang-40': 'takeover'}
|
||||
PASS V1: stale v1 job after v2 is published → superseded, no v1 side effects 19.62s v2 ready first; v1 → superseded at claim; variants only v2, pointer 2
|
||||
PASS V2: version race — slow v1 commits after v2 → pointer stays on v2 (no overwrite by older) 15.35s v1 finished after v2 → superseded at commit; pointer history [(None, 2)]
|
||||
PASS V3: redelivered v1 after v2 rollout and repeated reprocess are no-ops 5.99s v1 ready → v2 ready (pointer 1→2); 3 v1 duplicates ignored; reprocess v1/v2 again → noop
|
||||
PASS invariants I1–I7 hold for everything this suite produced (settled, bytes verified) 2.07s attachments 9, jobs 12 {'ready': 10, 'superseded': 2}, variants 33, events 92
|
||||
summary: 7 passed, 0 failed
|
||||
exit=0
|
||||
@@ -0,0 +1,72 @@
|
||||
# 2026-11-21T15:34:50Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 research/track2_chaos.py --seed 1 --uploads 60 --output evidence/track2/chaos-seed1.json
|
||||
{
|
||||
"seed": 1,
|
||||
"uploads_requested": 60,
|
||||
"counters": {
|
||||
"uploads_202": 60,
|
||||
"upload_errors": 0,
|
||||
"kills": 2,
|
||||
"duplicates_sent": 32,
|
||||
"stale_sent": 0,
|
||||
"reprocess_v2": 2,
|
||||
"v1_after_v2_sent": 4
|
||||
},
|
||||
"planned_faults": {
|
||||
"fault-crash-after-commit": 7,
|
||||
"fault-crash-after-s3": 6,
|
||||
"fault-crash-before-s3": 4,
|
||||
"fault-hang-30": 6,
|
||||
"fault-slow-3": 5,
|
||||
"fault-transient-1": 4,
|
||||
"fault-transient-2": 3,
|
||||
"none": 25
|
||||
},
|
||||
"chaos_seconds": 51.0,
|
||||
"settle_seconds": 61.9,
|
||||
"accepted_202": 60,
|
||||
"accepted_not_terminal": 0,
|
||||
"attachment_status": {
|
||||
"ready": "60"
|
||||
},
|
||||
"job_status": {
|
||||
"1:ready": "60",
|
||||
"2:ready": "2"
|
||||
},
|
||||
"events": {
|
||||
"claimed": "72",
|
||||
"committed": "62",
|
||||
"duplicate_ignored": "42",
|
||||
"enqueued": "62",
|
||||
"lease_lost": "6",
|
||||
"lease_takeover": "28",
|
||||
"published": "72",
|
||||
"published_version_changed": "62",
|
||||
"retry_scheduled": "10",
|
||||
"staging_cleaned": "60"
|
||||
},
|
||||
"enqueue_to_commit_seconds_v1": {
|
||||
"p50": 50.03,
|
||||
"p95": 89.43,
|
||||
"max": 96.38
|
||||
},
|
||||
"invariants": {
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 60,
|
||||
"jobs": 62,
|
||||
"variants": 186,
|
||||
"events": 476,
|
||||
"job_status": {
|
||||
"ready": 62
|
||||
},
|
||||
"attachment_status": {
|
||||
"ready": 60
|
||||
},
|
||||
"s3_objects": 482
|
||||
}
|
||||
}
|
||||
}
|
||||
exit=0
|
||||
@@ -0,0 +1,72 @@
|
||||
# 2026-11-21T15:37:01Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 research/track2_chaos.py --seed 2 --uploads 60 --output evidence/track2/chaos-seed2.json
|
||||
{
|
||||
"seed": 2,
|
||||
"uploads_requested": 60,
|
||||
"counters": {
|
||||
"uploads_202": 60,
|
||||
"upload_errors": 0,
|
||||
"kills": 3,
|
||||
"duplicates_sent": 21,
|
||||
"stale_sent": 0,
|
||||
"reprocess_v2": 3,
|
||||
"v1_after_v2_sent": 6
|
||||
},
|
||||
"planned_faults": {
|
||||
"fault-crash-after-commit": 4,
|
||||
"fault-crash-after-s3": 4,
|
||||
"fault-crash-before-s3": 4,
|
||||
"fault-hang-30": 3,
|
||||
"fault-slow-3": 7,
|
||||
"fault-transient-1": 10,
|
||||
"fault-transient-2": 4,
|
||||
"none": 24
|
||||
},
|
||||
"chaos_seconds": 48.8,
|
||||
"settle_seconds": 29.6,
|
||||
"accepted_202": 60,
|
||||
"accepted_not_terminal": 0,
|
||||
"attachment_status": {
|
||||
"ready": "60"
|
||||
},
|
||||
"job_status": {
|
||||
"1:ready": "60",
|
||||
"2:ready": "3"
|
||||
},
|
||||
"events": {
|
||||
"claimed": "82",
|
||||
"committed": "63",
|
||||
"duplicate_ignored": "30",
|
||||
"enqueued": "63",
|
||||
"lease_lost": "2",
|
||||
"lease_takeover": "23",
|
||||
"published": "82",
|
||||
"published_version_changed": "63",
|
||||
"retry_scheduled": "19",
|
||||
"staging_cleaned": "60"
|
||||
},
|
||||
"enqueue_to_commit_seconds_v1": {
|
||||
"p50": 16.65,
|
||||
"p95": 43.33,
|
||||
"max": 49.18
|
||||
},
|
||||
"invariants": {
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 60,
|
||||
"jobs": 63,
|
||||
"variants": 189,
|
||||
"events": 483,
|
||||
"job_status": {
|
||||
"ready": 63
|
||||
},
|
||||
"attachment_status": {
|
||||
"ready": 60
|
||||
},
|
||||
"s3_objects": 731
|
||||
}
|
||||
}
|
||||
}
|
||||
exit=0
|
||||
@@ -0,0 +1,72 @@
|
||||
# 2026-11-21T15:38:38Z commit=n/a host=Linux 6.18.44-fc-v726 x86_64 cpus=2
|
||||
$ python3 research/track2_chaos.py --seed 3 --uploads 60 --output evidence/track2/chaos-seed3.json
|
||||
{
|
||||
"seed": 3,
|
||||
"uploads_requested": 60,
|
||||
"counters": {
|
||||
"uploads_202": 60,
|
||||
"upload_errors": 0,
|
||||
"kills": 3,
|
||||
"duplicates_sent": 27,
|
||||
"stale_sent": 3,
|
||||
"reprocess_v2": 1,
|
||||
"v1_after_v2_sent": 2
|
||||
},
|
||||
"planned_faults": {
|
||||
"fault-crash-after-commit": 8,
|
||||
"fault-crash-after-s3": 9,
|
||||
"fault-crash-before-s3": 5,
|
||||
"fault-hang-30": 5,
|
||||
"fault-slow-3": 2,
|
||||
"fault-transient-1": 5,
|
||||
"none": 26
|
||||
},
|
||||
"chaos_seconds": 60.7,
|
||||
"settle_seconds": 37.6,
|
||||
"accepted_202": 60,
|
||||
"accepted_not_terminal": 0,
|
||||
"attachment_status": {
|
||||
"ready": "60"
|
||||
},
|
||||
"job_status": {
|
||||
"1:ready": "60",
|
||||
"2:ready": "1"
|
||||
},
|
||||
"events": {
|
||||
"claimed": "66",
|
||||
"committed": "61",
|
||||
"duplicate_ignored": "35",
|
||||
"enqueued": "61",
|
||||
"lease_lost": "1",
|
||||
"lease_takeover": "28",
|
||||
"published": "66",
|
||||
"published_version_changed": "61",
|
||||
"retry_scheduled": "5",
|
||||
"staging_cleaned": "60",
|
||||
"stale_ignored": "1"
|
||||
},
|
||||
"enqueue_to_commit_seconds_v1": {
|
||||
"p50": 22.88,
|
||||
"p95": 53.96,
|
||||
"max": 91.27
|
||||
},
|
||||
"invariants": {
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 60,
|
||||
"jobs": 61,
|
||||
"variants": 183,
|
||||
"events": 445,
|
||||
"job_status": {
|
||||
"ready": 61
|
||||
},
|
||||
"attachment_status": {
|
||||
"ready": 60
|
||||
},
|
||||
"s3_objects": 974
|
||||
}
|
||||
}
|
||||
}
|
||||
exit=0
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"seed": 1,
|
||||
"uploads_requested": 60,
|
||||
"counters": {
|
||||
"uploads_202": 60,
|
||||
"upload_errors": 0,
|
||||
"kills": 2,
|
||||
"duplicates_sent": 32,
|
||||
"stale_sent": 0,
|
||||
"reprocess_v2": 2,
|
||||
"v1_after_v2_sent": 4
|
||||
},
|
||||
"planned_faults": {
|
||||
"fault-crash-after-commit": 7,
|
||||
"fault-crash-after-s3": 6,
|
||||
"fault-crash-before-s3": 4,
|
||||
"fault-hang-30": 6,
|
||||
"fault-slow-3": 5,
|
||||
"fault-transient-1": 4,
|
||||
"fault-transient-2": 3,
|
||||
"none": 25
|
||||
},
|
||||
"chaos_seconds": 51.0,
|
||||
"settle_seconds": 61.9,
|
||||
"accepted_202": 60,
|
||||
"accepted_not_terminal": 0,
|
||||
"attachment_status": {
|
||||
"ready": "60"
|
||||
},
|
||||
"job_status": {
|
||||
"1:ready": "60",
|
||||
"2:ready": "2"
|
||||
},
|
||||
"events": {
|
||||
"claimed": "72",
|
||||
"committed": "62",
|
||||
"duplicate_ignored": "42",
|
||||
"enqueued": "62",
|
||||
"lease_lost": "6",
|
||||
"lease_takeover": "28",
|
||||
"published": "72",
|
||||
"published_version_changed": "62",
|
||||
"retry_scheduled": "10",
|
||||
"staging_cleaned": "60"
|
||||
},
|
||||
"enqueue_to_commit_seconds_v1": {
|
||||
"p50": 50.03,
|
||||
"p95": 89.43,
|
||||
"max": 96.38
|
||||
},
|
||||
"invariants": {
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 60,
|
||||
"jobs": 62,
|
||||
"variants": 186,
|
||||
"events": 476,
|
||||
"job_status": {
|
||||
"ready": 62
|
||||
},
|
||||
"attachment_status": {
|
||||
"ready": 60
|
||||
},
|
||||
"s3_objects": 482
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"seed": 2,
|
||||
"uploads_requested": 60,
|
||||
"counters": {
|
||||
"uploads_202": 60,
|
||||
"upload_errors": 0,
|
||||
"kills": 3,
|
||||
"duplicates_sent": 21,
|
||||
"stale_sent": 0,
|
||||
"reprocess_v2": 3,
|
||||
"v1_after_v2_sent": 6
|
||||
},
|
||||
"planned_faults": {
|
||||
"fault-crash-after-commit": 4,
|
||||
"fault-crash-after-s3": 4,
|
||||
"fault-crash-before-s3": 4,
|
||||
"fault-hang-30": 3,
|
||||
"fault-slow-3": 7,
|
||||
"fault-transient-1": 10,
|
||||
"fault-transient-2": 4,
|
||||
"none": 24
|
||||
},
|
||||
"chaos_seconds": 48.8,
|
||||
"settle_seconds": 29.6,
|
||||
"accepted_202": 60,
|
||||
"accepted_not_terminal": 0,
|
||||
"attachment_status": {
|
||||
"ready": "60"
|
||||
},
|
||||
"job_status": {
|
||||
"1:ready": "60",
|
||||
"2:ready": "3"
|
||||
},
|
||||
"events": {
|
||||
"claimed": "82",
|
||||
"committed": "63",
|
||||
"duplicate_ignored": "30",
|
||||
"enqueued": "63",
|
||||
"lease_lost": "2",
|
||||
"lease_takeover": "23",
|
||||
"published": "82",
|
||||
"published_version_changed": "63",
|
||||
"retry_scheduled": "19",
|
||||
"staging_cleaned": "60"
|
||||
},
|
||||
"enqueue_to_commit_seconds_v1": {
|
||||
"p50": 16.65,
|
||||
"p95": 43.33,
|
||||
"max": 49.18
|
||||
},
|
||||
"invariants": {
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 60,
|
||||
"jobs": 63,
|
||||
"variants": 189,
|
||||
"events": 483,
|
||||
"job_status": {
|
||||
"ready": 63
|
||||
},
|
||||
"attachment_status": {
|
||||
"ready": 60
|
||||
},
|
||||
"s3_objects": 731
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"seed": 3,
|
||||
"uploads_requested": 60,
|
||||
"counters": {
|
||||
"uploads_202": 60,
|
||||
"upload_errors": 0,
|
||||
"kills": 3,
|
||||
"duplicates_sent": 27,
|
||||
"stale_sent": 3,
|
||||
"reprocess_v2": 1,
|
||||
"v1_after_v2_sent": 2
|
||||
},
|
||||
"planned_faults": {
|
||||
"fault-crash-after-commit": 8,
|
||||
"fault-crash-after-s3": 9,
|
||||
"fault-crash-before-s3": 5,
|
||||
"fault-hang-30": 5,
|
||||
"fault-slow-3": 2,
|
||||
"fault-transient-1": 5,
|
||||
"none": 26
|
||||
},
|
||||
"chaos_seconds": 60.7,
|
||||
"settle_seconds": 37.6,
|
||||
"accepted_202": 60,
|
||||
"accepted_not_terminal": 0,
|
||||
"attachment_status": {
|
||||
"ready": "60"
|
||||
},
|
||||
"job_status": {
|
||||
"1:ready": "60",
|
||||
"2:ready": "1"
|
||||
},
|
||||
"events": {
|
||||
"claimed": "66",
|
||||
"committed": "61",
|
||||
"duplicate_ignored": "35",
|
||||
"enqueued": "61",
|
||||
"lease_lost": "1",
|
||||
"lease_takeover": "28",
|
||||
"published": "66",
|
||||
"published_version_changed": "61",
|
||||
"retry_scheduled": "5",
|
||||
"staging_cleaned": "60",
|
||||
"stale_ignored": "1"
|
||||
},
|
||||
"enqueue_to_commit_seconds_v1": {
|
||||
"p50": 22.88,
|
||||
"p95": 53.96,
|
||||
"max": 91.27
|
||||
},
|
||||
"invariants": {
|
||||
"ok": true,
|
||||
"violations": {},
|
||||
"violation_counts": {},
|
||||
"stats": {
|
||||
"attachments": 60,
|
||||
"jobs": 61,
|
||||
"variants": 183,
|
||||
"events": 445,
|
||||
"job_status": {
|
||||
"ready": 61
|
||||
},
|
||||
"attachment_status": {
|
||||
"ready": 60
|
||||
},
|
||||
"s3_objects": 974
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user