feat: ЛР 4 с хранением вложений в MinIO
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
# Результаты проверки lab4
|
||||
|
||||
Дата последней перепроверки: 2026-11-04. Стенд: Apple M4 Pro, 12 CPU cores, 24 GB RAM, Docker Desktop.
|
||||
|
||||
## Версии runtime
|
||||
|
||||
```text
|
||||
Python 3.13.15
|
||||
PostgreSQL 17.4
|
||||
Redis 7.4.2
|
||||
HAProxy 3.2.26
|
||||
MinIO RELEASE.2026-10-23T20-06-51Z (commit 76c06ff1d2cc844050fdeb1d54bf8fa70db72278)
|
||||
MinIO Client DEVELOPMENT.GOGET
|
||||
```
|
||||
|
||||
MinIO и MinIO Client взяты из Chainguard Images и закреплены в Compose по multi-arch OCI index digest.
|
||||
|
||||
## Контракт и smoke
|
||||
|
||||
```text
|
||||
$ make check
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
|
||||
$ make validate PYTHON=.venv/bin/python
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
|
||||
$ make test
|
||||
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
|
||||
```
|
||||
|
||||
## Негативные сценарии вложений
|
||||
|
||||
```text
|
||||
$ make test-attachments PYTHON=.venv/bin/python
|
||||
............ [100%]
|
||||
12 passed in 1.86s
|
||||
```
|
||||
|
||||
Проверены: превышение 10 MiB, повреждённое изображение, подмена MIME, превышение 40 млн пикселей до декодирования, опасные filename, доступ постороннего, attachment другого чата и семантика идемпотентности `attachment_ids`.
|
||||
|
||||
```text
|
||||
$ docker compose -f compose.tests.yaml run --rm --no-deps tests python -m pytest -q tests/test_attachment_compensation.py
|
||||
. [100%]
|
||||
1 passed
|
||||
```
|
||||
|
||||
Unit-тест внедряет ошибку сохранения метаданных после успешного S3 PUT и проверяет компенсационный DELETE того же object key.
|
||||
|
||||
Полный запуск в чистом изолированном Compose-проекте, включая миграции и bootstrap MinIO:
|
||||
|
||||
```text
|
||||
$ docker compose -p lab4-chainguard-tests -f compose.tests.yaml run --rm tests python -m pytest -q
|
||||
............. [100%]
|
||||
13 passed in 0.41s
|
||||
```
|
||||
|
||||
## Приватность и bootstrap
|
||||
|
||||
```text
|
||||
$ scripts/check-private-bucket.sh
|
||||
PASS: private bucket rejected anonymous request with HTTP 403
|
||||
```
|
||||
|
||||
MinIO root credentials получает только server/bootstrap. API использует отдельного пользователя с bucket-scoped policy. Host-порты S3 API и консоли не опубликованы. Bootstrap повторно завершался с code 0 при восстановлении API после failover и при restart стенда.
|
||||
|
||||
## Persistence и отказы
|
||||
|
||||
```text
|
||||
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
```
|
||||
|
||||
Hook перезапустил API, PostgreSQL, Redis и MinIO с сохранением named volumes.
|
||||
|
||||
```text
|
||||
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
{"observed_instances_before": 2, "successful_writes": 111, "failed_attempts": 1, "first_recovery_seconds": 2.333}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
```
|
||||
|
||||
```text
|
||||
$ make test-attachment-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
PASS: upload_instance=c18e79906d77 download_instance=662967386db9 recovery_seconds=3.912 failures=1 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
```
|
||||
|
||||
В последнем сценарии остановлена именно реплика из `X-Instance-Id` ответа upload. Download выполнен через другую реплику и совпал побайтно.
|
||||
|
||||
```text
|
||||
$ scripts/check-s3-outage.sh
|
||||
PASS: API readiness returned structured 503 while S3 was unavailable
|
||||
```
|
||||
|
||||
Скрипт автоматически восстановил MinIO и дождался готовности стенда.
|
||||
|
||||
## Cleanup
|
||||
|
||||
```text
|
||||
$ python -m app.tools.cleanup_orphans --dry-run --grace-seconds 60
|
||||
summary mode=dry-run known=164 removed=0 grace_seconds=60
|
||||
```
|
||||
|
||||
Dry-run не менял данные. Применение требует явного `--apply`; значения grace period меньше 60 секунд запрещены.
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"date": "2026-11-04",
|
||||
"profile": {
|
||||
"concurrency": 10,
|
||||
"uploads": 30,
|
||||
"file_size_bytes": 111817,
|
||||
"api_memory_limit_mib_each": 256
|
||||
},
|
||||
"result": {
|
||||
"successful_uploads": 30,
|
||||
"observed_api_instances": 2,
|
||||
"duration_seconds": 0.382,
|
||||
"max_latency_seconds": 0.3,
|
||||
"peak_memory_mib": {
|
||||
"api_replica_1": 68.5,
|
||||
"api_replica_2": 68.33
|
||||
}
|
||||
},
|
||||
"limitations": "Closed-loop profile with a small PNG; docker stats is sampled and may miss a shorter transient peak."
|
||||
}
|
||||
Reference in New Issue
Block a user