lab4: s3 attachments, private bucket, healthchecks, tests and report

This commit is contained in:
2026-11-03 00:35:32 +03:00
parent ec540a1a72
commit dfadf3eb7c
61 changed files with 2329 additions and 133 deletions
+9 -3
View File
@@ -1,5 +1,11 @@
# Доказательства
# Доказательства ЛР4
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
Результаты, которые уже лежали здесь при переносе из ЛР3, **относятся к ЛР3** и не подтверждают выполнение ЛР4.
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
Чтобы получить результаты именно для четвёртой работы, запустите `python scripts/check_grade4.py`,
`python scripts/experiment_uploads.py`, failover/persistence и приватность бакета. Сохраняйте фактический
вывод в файлы с суффиксом `-lab4`. Не выдумывайте PASS или замеры.
Для cleanup: `docker compose exec -T api1 python -m src.reconcile` (только просмотр),
и лишь после анализа `docker compose exec -T api1 python -m src.reconcile --apply`.
Объекты моложе одного часа не удаляются.
+8
View File
@@ -0,0 +1,8 @@
PASS: legacy lab2 bcrypt password still logs in
PASS: redis down -> live 200, ready/business 503, anonymous 401
PASS: postgres down -> live 200, ready/business 503, anonymous 401
PASS: UTF-8 Basic, long password and suffix verification
PASS: expired key can create one new message
PASS: SESSION_TTL_SECONDS=2 controls expires_at and token expiry
PASS: session/idempotency persisted across complete stand restart
PASS: migration preserved lab2 users/chats/active session
+1
View File
@@ -0,0 +1 @@
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+71
View File
@@ -0,0 +1,71 @@
{
"compose_cli": "2.40.3",
"configuration": "valid",
"runtime": "not executed: no Docker daemon",
"services": {
"api1": {
"image": "mtusi-lab3-api:local",
"cpus": 0.5,
"mem_limit": "268435456",
"ports": null,
"networks": {
"data": null,
"front": null
}
},
"api2": {
"image": "mtusi-lab3-api:local",
"cpus": 0.5,
"mem_limit": "268435456",
"ports": null,
"networks": {
"data": null,
"front": null
}
},
"db": {
"image": "postgres:16.4-alpine",
"cpus": 1,
"mem_limit": "536870912",
"ports": null,
"networks": {
"data": null
}
},
"lb": {
"image": "haproxy:3.0.5-alpine",
"cpus": 0.25,
"mem_limit": "134217728",
"ports": [
{
"mode": "ingress",
"host_ip": "127.0.0.1",
"target": 8080,
"published": "8080",
"protocol": "tcp"
}
],
"networks": {
"front": null
}
},
"migrate": {
"image": "mtusi-lab3-api:local",
"cpus": 0.5,
"mem_limit": "268435456",
"ports": null,
"networks": {
"data": null
}
},
"redis": {
"image": "redis:7.4.1-alpine",
"cpus": 0.25,
"mem_limit": "134217728",
"ports": null,
"networks": {
"data": null
}
}
}
}
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
OS: Linux-6.18.55-x86_64-with-glibc2.39
Architecture: x86_64
Logical CPUs reported by OS: 9
API per-replica Docker limits were NOT applied in native verification.
No dedicated CPU frequency/background workload control.
Docker daemon unavailable; Compose configuration only validated.
CPU affinity count: 9
fastapi==0.115.4
uvicorn==0.32.0
SQLAlchemy==2.0.36
asyncpg==0.30.0
redis==5.2.0
passlib==1.7.4
bcrypt==4.0.1
pydantic==2.14.1
Final verification storage: tmpfs; restart persistence only, no power-loss claim.
Initial generated lab2 messages: 10000.
+3
View File
@@ -0,0 +1,3 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 135, "failed_attempts": 0, "first_recovery_seconds": 0.118}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+3
View File
@@ -0,0 +1,3 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 7, "failed_attempts": 0, "first_recovery_seconds": 4.334}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+84
View File
@@ -0,0 +1,84 @@
[
{
"scenario": "stop-api1",
"concurrency": 4,
"elapsed_seconds": 8.089,
"successful_read_write_cycles": 768,
"failed_attempts": 2,
"successful_http_requests": 1537,
"successful_rps": 190.014,
"successful_cycles_per_second": 94.945,
"successful_cycles_during_action": 1,
"max_success_gap_seconds": 0.156,
"first_success_after_action_seconds": 0.048,
"latency_ms": {
"p50": 38.636,
"p95": 75.829,
"p99": 123.186
},
"instances_before": [
"1f5fa8139c4e:45",
"1f5fa8139c4e:46"
],
"instances_after": [
"1f5fa8139c4e:46"
],
"confirmed_messages_preserved": 769,
"note": "Closed-loop: one POST + one GET per cycle. RPS counts confirmed HTTP responses, including partial cycles. Latency covers successful cycles only. Recovery includes action duration."
},
{
"scenario": "stop-api2",
"concurrency": 4,
"elapsed_seconds": 8.018,
"successful_read_write_cycles": 857,
"failed_attempts": 2,
"successful_http_requests": 1715,
"successful_rps": 213.9,
"successful_cycles_per_second": 106.888,
"successful_cycles_during_action": 2,
"max_success_gap_seconds": 0.108,
"first_success_after_action_seconds": 0.045,
"latency_ms": {
"p50": 36.764,
"p95": 47.735,
"p99": 96.825
},
"instances_before": [
"1f5fa8139c4e:46",
"1f5fa8139c4e:92"
],
"instances_after": [
"1f5fa8139c4e:92"
],
"confirmed_messages_preserved": 858,
"note": "Closed-loop: one POST + one GET per cycle. RPS counts confirmed HTTP responses, including partial cycles. Latency covers successful cycles only. Recovery includes action duration."
},
{
"scenario": "rolling-update",
"concurrency": 4,
"elapsed_seconds": 10.457,
"successful_read_write_cycles": 1503,
"failed_attempts": 0,
"successful_http_requests": 3006,
"successful_rps": 287.465,
"successful_cycles_per_second": 143.732,
"successful_cycles_during_action": 248,
"max_success_gap_seconds": 0.152,
"first_success_after_action_seconds": 2.47,
"latency_ms": {
"p50": 23.296,
"p95": 48.574,
"p99": 126.866
},
"instances_before": [
"1f5fa8139c4e:103",
"1f5fa8139c4e:92"
],
"instances_after": [
"1f5fa8139c4e:114",
"1f5fa8139c4e:119"
],
"confirmed_messages_preserved": 1504,
"note": "Closed-loop: one POST + one GET per cycle. RPS counts confirmed HTTP responses, including partial cycles. Latency covers successful cycles only. Recovery includes action duration."
}
]
+84
View File
@@ -0,0 +1,84 @@
[
{
"scenario": "stop-api1",
"concurrency": 4,
"elapsed_seconds": 12.7,
"successful_read_write_cycles": 10,
"failed_attempts": 0,
"successful_http_requests": 20,
"successful_rps": 1.575,
"successful_cycles_per_second": 0.787,
"successful_cycles_during_action": 0,
"max_success_gap_seconds": 4.436,
"first_success_after_action_seconds": 7.464,
"latency_ms": {
"p50": 4134.395,
"p95": 5120.375,
"p99": 5120.375
},
"instances_before": [
"2365f2e82518:1",
"dee1b22b5bdc:1"
],
"instances_after": [
"2365f2e82518:1"
],
"confirmed_messages_preserved": 11,
"note": "Closed-loop: one POST + one GET per cycle. RPS counts confirmed HTTP responses, including partial cycles. Latency covers successful cycles only. Recovery includes action duration."
},
{
"scenario": "stop-api2",
"concurrency": 4,
"elapsed_seconds": 12.482,
"successful_read_write_cycles": 10,
"failed_attempts": 0,
"successful_http_requests": 20,
"successful_rps": 1.602,
"successful_cycles_per_second": 0.801,
"successful_cycles_during_action": 0,
"max_success_gap_seconds": 4.209,
"first_success_after_action_seconds": 7.283,
"latency_ms": {
"p50": 4135.329,
"p95": 5132.049,
"p99": 5132.049
},
"instances_before": [
"2365f2e82518:1",
"dee1b22b5bdc:1"
],
"instances_after": [
"dee1b22b5bdc:1"
],
"confirmed_messages_preserved": 11,
"note": "Closed-loop: one POST + one GET per cycle. RPS counts confirmed HTTP responses, including partial cycles. Latency covers successful cycles only. Recovery includes action duration."
},
{
"scenario": "rolling-update",
"concurrency": 4,
"elapsed_seconds": 46.853,
"successful_read_write_cycles": 44,
"failed_attempts": 0,
"successful_http_requests": 88,
"successful_rps": 1.878,
"successful_cycles_per_second": 0.939,
"successful_cycles_during_action": 32,
"max_success_gap_seconds": 4.373,
"first_success_after_action_seconds": 40.943,
"latency_ms": {
"p50": 4143.555,
"p95": 4483.856,
"p99": 5183.06
},
"instances_before": [
"2365f2e82518:1",
"dee1b22b5bdc:1"
],
"instances_after": [
"071fc584f61a:1",
"efcceb7ba40f:1"
],
"confirmed_messages_preserved": 45,
"note": "Closed-loop: one POST + one GET per cycle. RPS counts confirmed HTTP responses, including partial cycles. Latency covers successful cycles only. Recovery includes action duration."
}
]
+7
View File
@@ -0,0 +1,7 @@
Local static validation, 2026-11-02:
PASS: Python compileall src/scripts/tests/student-tests.
PASS: official offline scripts/check_contract.py.
PASS: Compose YAML parses; includes api1,api2,lb,db,redis,s3,s3_config,migrate.
PASS: sample PNG validation, corrupted image rejection, MIME spoof rejection, truncated PNG rejection.
PASS: 50 million pixel PNG is rejected by local image validation.
NOT RUN: Docker Compose, SeaweedFS real S3 connectivity, integration smoke, failover, persistence, 10-upload memory experiment.
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+2
View File
@@ -0,0 +1,2 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
[
{
"action": "SIGKILL api1",
"stopped_pid": 45,
"running": {
"postgres": 21,
"redis": 22,
"api1": 45,
"api2": 46,
"lb": 49
}
},
{
"action": "SIGKILL api2",
"stopped_pid": 46,
"running": {
"postgres": 21,
"redis": 22,
"api1": 92,
"api2": 46,
"lb": 49
}
},
{
"action": "rolling-update",
"running": {
"postgres": 21,
"redis": 22,
"api1": 114,
"api2": 119,
"lb": 49
}
}
]
+63
View File
@@ -0,0 +1,63 @@
[
{
"action": "stop-api1",
"before": {
"service": "api1",
"container": "dee1b22b5bdc",
"hostname": "dee1b22b5bdc",
"status": "running"
},
"after": {
"service": "api1",
"container": "dee1b22b5bdc",
"hostname": "dee1b22b5bdc",
"status": "exited"
}
},
{
"action": "stop-api2",
"before": {
"service": "api2",
"container": "2365f2e82518",
"hostname": "2365f2e82518",
"status": "running"
},
"after": {
"service": "api2",
"container": "2365f2e82518",
"hostname": "2365f2e82518",
"status": "exited"
}
},
{
"action": "rolling-update",
"before": [
{
"service": "api1",
"container": "dee1b22b5bdc",
"hostname": "dee1b22b5bdc",
"status": "running"
},
{
"service": "api2",
"container": "2365f2e82518",
"hostname": "2365f2e82518",
"status": "running"
}
],
"after": [
{
"service": "api1",
"container": "efcceb7ba40f",
"hostname": "efcceb7ba40f",
"status": "running"
},
{
"service": "api2",
"container": "071fc584f61a",
"hostname": "071fc584f61a",
"status": "running"
}
]
}
]
+57
View File
@@ -0,0 +1,57 @@
api1:
INFO: Started server process [35]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [35]
INFO: Started server process [45]
INFO: Started server process [92]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [92]
INFO: Started server process [114]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [114]
INFO: Started server process [152]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [152]
INFO: Started server process [186]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [186]
INFO: Started server process [219]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [219]
INFO: Started server process [226]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [226]
api2:
INFO: Started server process [46]
INFO: Started server process [103]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [103]
INFO: Started server process [119]
INFO: Started server process [130]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [130]
INFO: Started server process [154]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [154]
INFO: Started server process [188]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [188]
INFO: Started server process [220]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [220]
INFO: Started server process [227]
INFO: Shutting down
INFO: Application shutdown complete.
INFO: Finished server process [227]
+1
View File
@@ -0,0 +1 @@
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+3
View File
@@ -0,0 +1,3 @@
PASS: 12 concurrent requests across 2 replicas, one message
PASS: conflict, key scope, validation, access and revoked session
PASS: concurrent registration, exactly one 201 and one 409
+3
View File
@@ -0,0 +1,3 @@
PASS: 12 concurrent requests across 2 replicas, one message
PASS: conflict, key scope, validation, access and revoked session
PASS: concurrent registration, exactly one 201 and one 409
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
{
"concurrency": 10,
"file_bytes": 111817,
"completed": 10,
"median_latency_ms": 2142.51,
"api_peak_mem_mib_observed": 100.9,
"memory_samples": 4,
"instances": [
"8939b9a092a4:1",
"ef3f600f8c04:1"
]
}
Binary file not shown.