forked from mtusi2026/mtusi2026lab4
ЛР4
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
python student-tests/attachment_failover.py
|
||||
uploaded 111817 bytes, sha256 99ea7533c441f79c..., served by api replica ccaea065f01a
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 81410605dad3 running (healthy) 2026-10-22T14:19:42.319
|
||||
api ccaea065f01a running (healthy) 2026-10-22T14:19:42.001
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:06:53.419
|
||||
migrate 806265078f47 exited 2026-10-22T14:19:39.391
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T14:06:06.682
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T14:07:23.226
|
||||
s3-init 37fe53772dcb exited 2026-10-22T14:19:39.389
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T14:06:06.574
|
||||
stopped ccaea065f01a (docker stop); HAProxy: api1 UP, api2 DOWN
|
||||
downloaded 4 times through ['81410605dad3']: same SHA-256 as uploaded
|
||||
restored ccaea065f01a; HAProxy: api1 UP, api2 UP
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 81410605dad3 running (healthy) 2026-10-22T14:19:42.319
|
||||
api ccaea065f01a running (healthy) 2026-10-22T14:20:22.672
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:06:53.419
|
||||
migrate 806265078f47 exited 2026-10-22T14:19:39.391
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T14:06:06.682
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T14:07:23.226
|
||||
s3-init 37fe53772dcb exited 2026-10-22T14:19:39.389
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T14:06:06.574
|
||||
PASS: the replica that accepted the upload was stopped; another replica returned the same bytes (the original lives in S3, not on the replica)
|
||||
@@ -0,0 +1,2 @@
|
||||
python scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,32 @@
|
||||
docker compose --profile tools run --rm db-test
|
||||
Container mtusi-lab4-postgres-1 Running
|
||||
Container mtusi-lab4-postgres-1 Waiting
|
||||
Container mtusi-lab4-postgres-1 Healthy
|
||||
Container mtusi-lab4-db-test-run-6d3ffec3d33d Creating
|
||||
Container mtusi-lab4-db-test-run-6d3ffec3d33d Created
|
||||
test_concurrent_registration_has_one_winner (test_store.StoreIntegrationTest.test_concurrent_registration_has_one_winner) ...
|
||||
20 параллельных create_user: 1 создан, 19 получили Conflict (409)
|
||||
ok
|
||||
test_concurrent_same_idempotency_key_creates_one_row (test_store.StoreIntegrationTest.test_concurrent_same_idempotency_key_creates_one_row) ...
|
||||
20 одновременных add_message с одним ключом: 1 строка, 1 новое + 19 повторов с тем же сообщением
|
||||
ok
|
||||
test_create_chat_rolls_back_when_failing_midway (test_store.StoreIntegrationTest.test_create_chat_rolls_back_when_failing_midway) ... ok
|
||||
test_database_rejects_message_from_non_member (test_store.StoreIntegrationTest.test_database_rejects_message_from_non_member) ...
|
||||
чат с несуществующим участником: транзакция откатилась, строк chats/chat_members не осталось
|
||||
|
||||
INSERT сообщения от не-участника напрямую в БД: ForeignKeyViolation
|
||||
ok
|
||||
test_migrations_rerun_is_noop (test_store.StoreIntegrationTest.test_migrations_rerun_is_noop) ... ok
|
||||
test_old_version_insert_without_key_still_works (test_store.StoreIntegrationTest.test_old_version_insert_without_key_still_works) ...
|
||||
schema_migrations: ['001_core', '002_sessions', '003_text_as_bytes', '004_message_idempotency', '005_attachments']; повторный migrate() ничего не применил
|
||||
ok
|
||||
test_same_key_other_body_is_conflict (test_store.StoreIntegrationTest.test_same_key_other_body_is_conflict) ...
|
||||
INSERT как в lab2 (без ключа) после миграции 004 работает: старая версия совместима со схемой
|
||||
|
||||
тот же ключ с другим телом: Conflict (409), в базе по-прежнему одна строка
|
||||
ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 7 tests in 0.281s
|
||||
|
||||
OK
|
||||
@@ -0,0 +1,56 @@
|
||||
python student-tests/run_failover.py
|
||||
hook: scripts/stop-one.cmd; api replicas: ['901d91ace549', 'c0f257b4b378']
|
||||
|
||||
=== run 1: containers before (HAProxy: api1 UP, api2 UP)
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 901d91ace549 running (healthy) 2026-10-22T14:01:25.740
|
||||
api c0f257b4b378 running (healthy) 2026-10-22T14:05:06.764
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:01:26.528
|
||||
migrate 51b3180c16d9 exited 2026-10-22T14:01:22.887
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T13:58:38.541
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T13:58:38.538
|
||||
s3-init f596754a9e8b exited 2026-10-22T14:01:22.889
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T13:58:38.539
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.␍
|
||||
{"observed_instances_before": 2, "successful_writes": 124, "failed_attempts": 0, "first_recovery_seconds": 4.891}␍
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
containers after (HAProxy: api1 UP)
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 901d91ace549 exited 2026-10-22T14:01:25.740
|
||||
api c0f257b4b378 running (healthy) 2026-10-22T14:05:06.764
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:01:26.528
|
||||
migrate 51b3180c16d9 exited 2026-10-22T14:01:22.887
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T13:58:38.541
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T13:58:38.538
|
||||
s3-init f596754a9e8b exited 2026-10-22T14:01:22.889
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T13:58:38.539
|
||||
the hook stopped 901d91ace549 (X-Instance-Id of that replica = container ID); other api containers, postgres, valkey, s3 and lb kept running
|
||||
restored: docker start 901d91ace549 -> healthy and back in HAProxy (api1 UP, api2 UP)
|
||||
|
||||
=== run 2: containers before (HAProxy: api1 UP, api2 UP)
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 901d91ace549 running (healthy) 2026-10-22T14:05:30.621
|
||||
api c0f257b4b378 running (healthy) 2026-10-22T14:05:06.764
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:01:26.528
|
||||
migrate 51b3180c16d9 exited 2026-10-22T14:01:22.887
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T13:58:38.541
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T13:58:38.538
|
||||
s3-init f596754a9e8b exited 2026-10-22T14:01:22.889
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T13:58:38.539
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.␍
|
||||
{"observed_instances_before": 2, "successful_writes": 124, "failed_attempts": 0, "first_recovery_seconds": 4.469}␍
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
containers after (HAProxy: api2 UP)
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 901d91ace549 running (healthy) 2026-10-22T14:05:30.621
|
||||
api c0f257b4b378 exited 2026-10-22T14:05:06.764
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:01:26.528
|
||||
migrate 51b3180c16d9 exited 2026-10-22T14:01:22.887
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T13:58:38.541
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T13:58:38.538
|
||||
s3-init f596754a9e8b exited 2026-10-22T14:01:22.889
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T13:58:38.539
|
||||
the hook stopped c0f257b4b378 (X-Instance-Id of that replica = container ID); other api containers, postgres, valkey, s3 and lb kept running
|
||||
restored: docker start c0f257b4b378 -> healthy and back in HAProxy (api1 UP, api2 UP)
|
||||
|
||||
PASS: public failover test passed 2 times; every api replica was stopped once and restored
|
||||
@@ -0,0 +1,27 @@
|
||||
python student-tests/failure_s3.py
|
||||
=== s3 stopped
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 81410605dad3 running (healthy) 2026-10-22T14:19:42.319
|
||||
api ccaea065f01a running (healthy) 2026-10-22T14:20:22.672
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:06:53.419
|
||||
migrate 806265078f47 exited 2026-10-22T14:19:39.391
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T14:06:06.682
|
||||
s3 cf488bd53603 exited 2026-10-22T14:07:23.226
|
||||
s3-init 37fe53772dcb exited 2026-10-22T14:19:39.389
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T14:06:06.574
|
||||
upload while S3 is down: 503 unavailable in 6.03 s
|
||||
metadata of the ready attachment (PostgreSQL): 200
|
||||
download while S3 is down: 503 unavailable
|
||||
text message: 201; history: 200; /health/ready: 200
|
||||
=== s3 started
|
||||
the file uploaded before the outage is back after 12.8 s, same bytes (sha256 99ea7533c441f79c...)
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 81410605dad3 running (healthy) 2026-10-22T14:19:42.319
|
||||
api ccaea065f01a running (healthy) 2026-10-22T14:20:22.672
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:06:53.419
|
||||
migrate 806265078f47 exited 2026-10-22T14:19:39.391
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T14:06:06.682
|
||||
s3 cf488bd53603 running (starting) 2026-10-22T14:20:57.064
|
||||
s3-init 37fe53772dcb exited 2026-10-22T14:19:39.389
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T14:06:06.574
|
||||
PASS: S3 down -> upload/download 503 (no 500), metadata, text messages and readiness keep working; after S3 is back the original is intact and uploads work again
|
||||
@@ -0,0 +1,10 @@
|
||||
python student-tests/orphan_cleanup.py
|
||||
injected: stale pending row + object (PUT ok, COMMIT failed), fresh pending row + object (upload in progress), orphan object without a row; plus one ready attachment
|
||||
1. dry-run: {"dry_run": true, "grace_seconds": 900, "stale_pending": 1, "pending_deleted": 0, "orphan_objects": 0, "orphans_deleted": 0, "missing_objects": 0, "objects_in_bucket": 49, "ready_rows": 46, "pending_rows": 5, "seconds": 0.132}
|
||||
2. cleanup, grace 900 s: {"dry_run": false, "grace_seconds": 900, "stale_pending": 1, "pending_deleted": 1, "orphan_objects": 0, "orphans_deleted": 0, "missing_objects": 0, "objects_in_bucket": 48, "ready_rows": 46, "pending_rows": 4, "seconds": 0.138}
|
||||
stale object and row removed; fresh pending, fresh orphan and the ready attachment kept
|
||||
3. repeated run: {"dry_run": false, "grace_seconds": 900, "stale_pending": 0, "pending_deleted": 0, "orphan_objects": 0, "orphans_deleted": 0, "missing_objects": 0, "objects_in_bucket": 48, "ready_rows": 46, "pending_rows": 4, "seconds": 0.129}
|
||||
4. cleanup, grace 2 s (test only): {"dry_run": false, "grace_seconds": 2, "stale_pending": 4, "pending_deleted": 4, "orphan_objects": 1, "orphans_deleted": 1, "missing_objects": 0, "objects_in_bucket": 47, "ready_rows": 46, "pending_rows": 0, "seconds": 0.165}
|
||||
after the grace period the old pending upload and the orphan object are removed too; the ready attachment is never touched
|
||||
5. client aborted an upload after 800531 of 2401593 bytes: rows in chat 1 -> 1, objects in bucket 46 -> 46
|
||||
PASS: failures between S3 and PostgreSQL leave no permanent unaccounted objects; the grace period protects uploads in progress; dry-run and repeated runs are safe; an aborted upload stores nothing
|
||||
@@ -0,0 +1,31 @@
|
||||
python student-tests/run_persistence.py
|
||||
hook: scripts/restart.cmd
|
||||
=== containers before
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 901d91ace549 running (healthy) 2026-10-22T14:05:30.621
|
||||
api c0f257b4b378 running (healthy) 2026-10-22T14:05:52.897
|
||||
lb 57f9ebc04460 running (healthy) 2026-10-22T14:01:26.528
|
||||
migrate 51b3180c16d9 exited 2026-10-22T14:01:22.887
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T13:58:38.541
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T13:58:38.538
|
||||
s3-init f596754a9e8b exited 2026-10-22T14:01:22.889
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T13:58:38.539
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.␍
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
=== containers after (test took 53.7 s: hook + waiting for readiness + data checks)
|
||||
SERVICE CONTAINER STATE STARTED AT (UTC)
|
||||
api 901d91ace549 running (healthy) 2026-10-22T14:06:49.166
|
||||
api c0f257b4b378 running (healthy) 2026-10-22T14:06:49.442
|
||||
lb 57f9ebc04460 running (starting) 2026-10-22T14:06:53.419
|
||||
migrate 51b3180c16d9 exited 2026-10-22T14:06:22.436
|
||||
postgres b4b2a3cf061f running (healthy) 2026-10-22T14:06:06.682
|
||||
s3 cf488bd53603 running (healthy) 2026-10-22T14:06:21.465
|
||||
s3-init f596754a9e8b exited 2026-10-22T14:06:46.932
|
||||
valkey d4851200ad55 running (healthy) 2026-10-22T14:06:06.574
|
||||
api 901d91ace549: same container, start time 14:05:30 -> 14:06:49
|
||||
api c0f257b4b378: same container, start time 14:05:52 -> 14:06:49
|
||||
lb 57f9ebc04460: same container, start time 14:01:26 -> 14:06:53
|
||||
postgres b4b2a3cf061f: same container, start time 13:58:38 -> 14:06:06
|
||||
s3 cf488bd53603: same container, start time 13:58:38 -> 14:06:21
|
||||
valkey d4851200ad55: same container, start time 13:58:38 -> 14:06:06
|
||||
PASS: api replicas, postgres, valkey, s3 and lb were restarted (same containers and volumes, new start time); data, the attachment bytes and the existing token survived
|
||||
@@ -0,0 +1,21 @@
|
||||
python student-tests/s3_checks.py
|
||||
object key is server-generated: originals/<random uuid> (filename is not used in the key)
|
||||
anonymous_get_object: HTTP 403
|
||||
anonymous_list_bucket: HTTP 403
|
||||
anonymous_list_buckets: HTTP 403
|
||||
API key GetObject: same SHA-256 as uploaded (the bytes are in the bucket)
|
||||
API key list_buckets: ['messenger-attachments']
|
||||
API key create_bucket: AccessDenied
|
||||
API key make_bucket_public: AccessDenied
|
||||
API key delete_bucket: AccessDenied
|
||||
SeaweedFS admin/UI port 9333 inside the network: closed
|
||||
SeaweedFS admin/UI port 8888 inside the network: closed
|
||||
SeaweedFS admin/UI port 8080 inside the network: closed
|
||||
host 127.0.0.1:9000, :9333, :8888: closed (S3 is not published)
|
||||
attachments columns: id:uuid, chat_id:uuid, owner_id:uuid, filename:text, content_type:text, size_bytes:bigint, sha256:text, width:integer, height:integer, storage_key:text, status:text, created_at:timestamp with time zone, updated_at:timestamp with time zone
|
||||
api 81410605dad3: files with the same SHA-256 on disk: 0
|
||||
api ccaea065f01a: files with the same SHA-256 on disk: 0
|
||||
s3-init run 1: exit 0: s3-init: bucket messenger-attachments already exists; anonymous access: 403 (private)
|
||||
s3-init run 2: exit 0: s3-init: bucket messenger-attachments already exists; anonymous access: 403 (private)
|
||||
objects in bucket before/after bootstrap: 47/47; the file still downloads
|
||||
PASS: bucket is private outside the API, the API S3 user has least privilege, the console is closed, bytes are only in S3, bucket bootstrap is idempotent
|
||||
@@ -0,0 +1,34 @@
|
||||
python student-tests/check_stack.py
|
||||
docker: 29.6.2
|
||||
compose: 5.3.1
|
||||
container_name: not set for any service (replicas of one service are possible)
|
||||
api replicas running: 2 -> ['901d91ace549', 'c0f257b4b378'] (deploy.replicas = 2)
|
||||
|
||||
service container cpus memory published ports networks
|
||||
lb 57f9ebc04460 0.50 128Mi 127.0.0.1:8080->8080/tcp, 127.0.0.1:8081->8081/tcp, 127.0.0.1:8404->8404/tcp edge
|
||||
api 901d91ace549 1.00 512Mi - backend, edge
|
||||
postgres b4b2a3cf061f 1.00 512Mi - backend
|
||||
api c0f257b4b378 1.00 512Mi - backend, edge
|
||||
s3 cf488bd53603 0.50 512Mi - backend
|
||||
valkey d4851200ad55 0.50 128Mi - backend
|
||||
|
||||
published: only lb, only on 127.0.0.1 (api replicas have no ports)
|
||||
balancer: every api server is under the /health/ready check, no backup servers -> api1 UP (L7OK), api2 UP (L7OK)
|
||||
limits: every running container has CPU and RAM limits
|
||||
networks: lb -> edge; api -> edge + backend; postgres, valkey, s3 -> backend (internal: no way out)
|
||||
s3: no published ports; master/filer web UIs only on 127.0.0.1 inside the container; IAM API off; pinned image; volume s3data
|
||||
secrets: api -> cache_url, database_url, s3_access_key_id, s3_secret_access_key; migrate -> database_url; lb -> none; postgres -> postgres_password; valkey -> valkey_acl; s3 -> s3_config; s3-init -> s3_root_password, s3_root_user
|
||||
images: lb haproxy:3.2.25-alpine; api mtusi-messenger:lab4; postgres postgres:17.10-bookworm; valkey valkey/valkey:8.1.9; s3 chrislusf/seaweedfs:4.44
|
||||
PASS: one entry point (lb on 127.0.0.1), >= 2 api replicas without ports and container_name, only ready replicas get traffic, CPU/RAM limits everywhere, stores (incl. S3) only on the internal network, S3 admin credentials only in s3-init
|
||||
docker compose ps -a --format "table {{.Service}}\t{{.ID}}\t{{.Status}}"
|
||||
SERVICE CONTAINER ID STATUS
|
||||
api c0f257b4b378 Up About a minute (healthy)
|
||||
api 901d91ace549 Up About a minute (healthy)
|
||||
lb 57f9ebc04460 Up About a minute (healthy)
|
||||
migrate 51b3180c16d9 Exited (0) About a minute ago
|
||||
postgres b4b2a3cf061f Up 4 minutes (healthy)
|
||||
s3 cf488bd53603 Up 4 minutes (healthy)
|
||||
s3-init f596754a9e8b Exited (0) About a minute ago
|
||||
valkey d4851200ad55 Up 4 minutes (healthy)
|
||||
s3-init-1 | s3-init: bucket messenger-attachments already exists; anonymous access: 403 (private)
|
||||
migrate-1 | 2026-10-22 14:01:24,642 INFO messenger.db: Миграции применены: 001_core, 002_sessions, 003_text_as_bytes, 004_message_idempotency, 005_attachments
|
||||
@@ -0,0 +1,83 @@
|
||||
python -m unittest discover -s student-tests -p "test_*.py" -v
|
||||
test_auth_checked_before_access_and_body (test_api.MessengerApiTest.test_auth_checked_before_access_and_body) ... ok
|
||||
test_bad_cursor_returns_400 (test_api.MessengerApiTest.test_bad_cursor_returns_400) ... ok
|
||||
test_chat_list_pagination (test_api.MessengerApiTest.test_chat_list_pagination) ... ok
|
||||
test_chat_membership_rules (test_api.MessengerApiTest.test_chat_membership_rules) ... ok
|
||||
test_duplicate_username_returns_409 (test_api.MessengerApiTest.test_duplicate_username_returns_409) ... ok
|
||||
test_empty_blank_and_too_long_messages_return_400 (test_api.MessengerApiTest.test_empty_blank_and_too_long_messages_return_400) ... ok
|
||||
test_malformed_json_returns_400 (test_api.MessengerApiTest.test_malformed_json_returns_400) ... ok
|
||||
test_nul_character_is_stored (test_api.MessengerApiTest.test_nul_character_is_stored) ... ok
|
||||
test_outsider_gets_404_for_foreign_chat (test_api.MessengerApiTest.test_outsider_gets_404_for_foreign_chat) ... ok
|
||||
test_pagination_walks_several_pages (test_api.MessengerApiTest.test_pagination_walks_several_pages) ... ok
|
||||
test_unicode_roundtrip (test_api.MessengerApiTest.test_unicode_roundtrip) ... ok
|
||||
test_wrong_types_and_extra_fields_return_400 (test_api.MessengerApiTest.test_wrong_types_and_extra_fields_return_400) ... ok
|
||||
test_attachment_rules_without_500 (test_attachments.AttachmentTest.test_attachment_rules_without_500) ... ok
|
||||
test_corrupted_images_are_415 (test_attachments.AttachmentTest.test_corrupted_images_are_415) ... ok
|
||||
test_dangerous_filenames_are_400 (test_attachments.AttachmentTest.test_dangerous_filenames_are_400) ... ok
|
||||
test_idempotency_with_attachments (test_attachments.AttachmentTest.test_idempotency_with_attachments) ... ok
|
||||
test_large_real_image_within_limits_is_accepted (test_attachments.AttachmentTest.test_large_real_image_within_limits_is_accepted) ... ok
|
||||
test_message_with_attachments (test_attachments.AttachmentTest.test_message_with_attachments) ... ok
|
||||
test_mime_spoofing_is_415 (test_attachments.AttachmentTest.test_mime_spoofing_is_415) ... ok
|
||||
test_outsider_and_anonymous_cannot_upload (test_attachments.AttachmentTest.test_outsider_and_anonymous_cannot_upload) ... ok
|
||||
test_pixel_bomb_is_413 (test_attachments.AttachmentTest.test_pixel_bomb_is_413) ... ok
|
||||
test_png_and_jpeg_roundtrip_for_member (test_attachments.AttachmentTest.test_png_and_jpeg_roundtrip_for_member) ... ok
|
||||
test_too_large_is_413_before_reading (test_attachments.AttachmentTest.test_too_large_is_413_before_reading) ... ok
|
||||
test_too_large_stream_is_413 (test_attachments.AttachmentTest.test_too_large_stream_is_413) ... ok
|
||||
test_variants_and_bad_ids (test_attachments.AttachmentTest.test_variants_and_bad_ids) ... ok
|
||||
test_bearer_required_on_business_endpoints (test_auth.AuthTest.test_bearer_required_on_business_endpoints) ... ok
|
||||
test_login_returns_opaque_token_with_expiry (test_auth.AuthTest.test_login_returns_opaque_token_with_expiry) ... ok
|
||||
test_logout_revokes_only_current_session (test_auth.AuthTest.test_logout_revokes_only_current_session) ... ok
|
||||
test_malformed_basic_returns_401 (test_auth.AuthTest.test_malformed_basic_returns_401) ... ok
|
||||
test_password_length_rules (test_auth.AuthTest.test_password_length_rules) ... ok
|
||||
test_password_with_colon_and_unicode (test_auth.AuthTest.test_password_with_colon_and_unicode) ... ok
|
||||
test_relogin_after_logout (test_auth.AuthTest.test_relogin_after_logout) ... ok
|
||||
test_user_never_contains_password (test_auth.AuthTest.test_user_never_contains_password) ... ok
|
||||
test_wrong_password_and_unknown_user_look_the_same (test_auth.AuthTest.test_wrong_password_and_unknown_user_look_the_same) ... ok
|
||||
test_x_user_id_does_not_change_identity (test_auth.AuthTest.test_x_user_id_does_not_change_identity) ... ok
|
||||
test_instance_id_on_errors_and_health (test_balancing.BalancingTest.test_instance_id_on_errors_and_health) ... ok
|
||||
test_logout_applies_on_every_replica (test_balancing.BalancingTest.test_logout_applies_on_every_replica) ... ok
|
||||
test_one_session_is_served_by_every_replica (test_balancing.BalancingTest.test_one_session_is_served_by_every_replica) ... ok
|
||||
test_session_cache_is_shared_between_replicas (test_balancing.BalancingTest.test_session_cache_is_shared_between_replicas) ... ok
|
||||
test_write_on_one_replica_read_on_another (test_balancing.BalancingTest.test_write_on_one_replica_read_on_another) ... ok
|
||||
test_failed_request_does_not_burn_key (test_idempotency.IdempotencyTest.test_failed_request_does_not_burn_key) ... ok
|
||||
test_json_formatting_does_not_matter (test_idempotency.IdempotencyTest.test_json_formatting_does_not_matter) ... ok
|
||||
test_key_is_required_and_validated (test_idempotency.IdempotencyTest.test_key_is_required_and_validated) ... ok
|
||||
test_key_scope_is_user_and_chat (test_idempotency.IdempotencyTest.test_key_scope_is_user_and_chat) ... ok
|
||||
test_parallel_different_bodies_same_key (test_idempotency.IdempotencyTest.test_parallel_different_bodies_same_key) ... ok
|
||||
test_parallel_same_key_through_replicas_creates_one_message (test_idempotency.IdempotencyTest.test_parallel_same_key_through_replicas_creates_one_message) ... ok
|
||||
test_replay_rechecks_session_and_access (test_idempotency.IdempotencyTest.test_replay_rechecks_session_and_access) ... ok
|
||||
test_replay_through_another_replica_returns_same_message (test_idempotency.IdempotencyTest.test_replay_through_another_replica_returns_same_message) ... ok
|
||||
test_same_key_other_body_is_409 (test_idempotency.IdempotencyTest.test_same_key_other_body_is_409) ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 49 tests in 9.886s
|
||||
|
||||
OK
|
||||
|
||||
X-Instance-Id есть в health, 404, 401 и 400
|
||||
|
||||
logout через одну реплику -> 401 на ['81410605dad3', 'ccaea065f01a']
|
||||
|
||||
20 x GET /users/me с одним токеном -> реплики {'ccaea065f01a': 10, '81410605dad3': 10}; это ID запущенных контейнеров api, повторный вход не нужен
|
||||
|
||||
10 x GET /users/me через реплики {'ccaea065f01a': 5, '81410605dad3': 5}: попаданий в кэш +20, промахов +0 — кэш общий
|
||||
|
||||
сообщение записала реплика ccaea065f01a, сразу прочитали ['81410605dad3', 'ccaea065f01a']
|
||||
|
||||
с тем же ключом: сначала 400 (пустой текст), потом 201 — ошибка ключ не заняла
|
||||
|
||||
тот же JSON с другими пробелами и переносами -> тот же 201 и то же сообщение
|
||||
|
||||
нет ключа, пустой, 129 символов, пробел, '/', кириллица -> 400; 128 символов и ._:- -> 201
|
||||
|
||||
тот же ключ у другого пользователя и в другом чате -> независимые сообщения
|
||||
|
||||
10 одновременных разных тел с одним ключом: 201 x1, 409 x9, в истории 1 сообщение
|
||||
|
||||
20 одновременных POST с одним ключом через реплики {'ccaea065f01a': 10, '81410605dad3': 10}: все 201 с одним id, в истории 1 сообщение
|
||||
|
||||
повтор: посторонний -> 404, после logout -> 401, после нового входа -> то же сообщение
|
||||
|
||||
1 запрос + 4 повтора через реплики ['81410605dad3', 'ccaea065f01a']: 201 и то же сообщение, в истории 1
|
||||
|
||||
другой текст с тем же ключом -> 409 conflict, второе сообщение не создано
|
||||
@@ -0,0 +1,2 @@
|
||||
python tests/smoke.py --base-url "http://127.0.0.1:8080"
|
||||
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"date": "2026-10-22T14:08:37Z",
|
||||
"count": 12,
|
||||
"file_mib": 8.76,
|
||||
"profile_a_seconds": 5.69,
|
||||
"profile_b_seconds": 30.06,
|
||||
"limits": {
|
||||
"api_memory": "512M",
|
||||
"spool_in_memory": "1 MiB per upload",
|
||||
"decode_concurrency": 1
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"replica": "901d91ace549",
|
||||
"uploads_served": 6,
|
||||
"rss_before_mib": 95.2,
|
||||
"hwm_before_mib": 95.2,
|
||||
"hwm_after_a_mib": 198.1,
|
||||
"hwm_after_b_mib": 198.6,
|
||||
"max_rss_polled_mib": 198.1,
|
||||
"cgroup_peak_after_mib": null,
|
||||
"peak_growth_mib": 102.9,
|
||||
"growth_from_b_mib": 0.5,
|
||||
"bodies_if_in_memory_mib": 52.6
|
||||
},
|
||||
{
|
||||
"replica": "c0f257b4b378",
|
||||
"uploads_served": 6,
|
||||
"rss_before_mib": 95.4,
|
||||
"hwm_before_mib": 95.4,
|
||||
"hwm_after_a_mib": 201.0,
|
||||
"hwm_after_b_mib": 202.2,
|
||||
"max_rss_polled_mib": 201.3,
|
||||
"cgroup_peak_after_mib": null,
|
||||
"peak_growth_mib": 105.6,
|
||||
"growth_from_b_mib": 1.2,
|
||||
"bodies_if_in_memory_mib": 52.6
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
python student-tests/upload_memory.py
|
||||
replicas: ['901d91ace549', 'c0f257b4b378']; 12 files x 8.8 MiB (1800x1700, random pixels)
|
||||
A (accepted): 12 concurrent uploads in 5.69 s -> statuses [201]
|
||||
B (11 MiB, rejected): 12 concurrent uploads in 30.06 s -> statuses [413]
|
||||
Профиль A: 12 одновременных PNG по 8.8 МиБ за 5.69 с, все 201, SHA-256 совпали при скачивании; профиль B: 12 одновременных по 11 МиБ за 30.06 с, все 413. Лимит памяти реплики 512 МиБ. Сырые данные: evidence/upload-memory.json.
|
||||
|
||||
| Реплика | Загрузок A | RSS до, МиБ | Пик RSS до → после A, МиБ | Рост пика, МиБ | Тела целиком в памяти были бы, МиБ | Рост пика от B (11 МиБ ×12), МиБ | memory.peak cgroup, МиБ |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| 901d91ace549 | 6 | 95.2 | 95.2 → 198.1 | 102.9 | 52.6 | 0.5 | None |
|
||||
| c0f257b4b378 | 6 | 95.4 | 95.4 → 201.0 | 105.6 | 52.6 | 1.2 | None |
|
||||
REPORT.md: table updated between upload-memory markers
|
||||
PASS: >= 10 concurrent uploads measured; see the table above
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"date": "2026-10-22T14:22:09Z",
|
||||
"count": 12,
|
||||
"file_mib": 8.76,
|
||||
"profile_a_seconds": 7.3,
|
||||
"profile_b_seconds": 0.06,
|
||||
"limits": {
|
||||
"api_memory": "512M",
|
||||
"spool_in_memory": "1 MiB per upload",
|
||||
"decode_concurrency": 1,
|
||||
"malloc_arena_max": 2
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"replica": "81410605dad3",
|
||||
"uploads_served": 6,
|
||||
"rss_before_mib": 95.1,
|
||||
"hwm_before_mib": 95.1,
|
||||
"hwm_after_a_mib": 131.0,
|
||||
"hwm_after_b_mib": 131.0,
|
||||
"max_rss_polled_mib": 131.0,
|
||||
"cgroup_peak_after_mib": null,
|
||||
"peak_growth_mib": 35.9,
|
||||
"growth_from_b_mib": 0.0,
|
||||
"bodies_if_in_memory_mib": 52.6
|
||||
},
|
||||
{
|
||||
"replica": "ccaea065f01a",
|
||||
"uploads_served": 6,
|
||||
"rss_before_mib": 97.2,
|
||||
"hwm_before_mib": 97.2,
|
||||
"hwm_after_a_mib": 130.8,
|
||||
"hwm_after_b_mib": 130.8,
|
||||
"max_rss_polled_mib": 130.8,
|
||||
"cgroup_peak_after_mib": null,
|
||||
"peak_growth_mib": 33.6,
|
||||
"growth_from_b_mib": 0.0,
|
||||
"bodies_if_in_memory_mib": 52.6
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
python student-tests/upload_memory.py
|
||||
replicas: ['81410605dad3', 'ccaea065f01a']; 12 files x 8.8 MiB (1800x1700, random pixels)
|
||||
A (accepted): 12 concurrent uploads in 7.30 s -> statuses [201]
|
||||
B (11 MiB, rejected): 12 concurrent uploads in 0.06 s -> statuses [413]
|
||||
Профиль A: 12 одновременных PNG по 8.8 МиБ за 7.3 с, все 201, SHA-256 совпали при скачивании; профиль B: 12 одновременных по 11 МиБ за 0.06 с, все 413. Лимит памяти реплики 512 МиБ. Сырые данные: evidence/upload-memory.json.
|
||||
|
||||
| Реплика | Загрузок A | RSS до, МиБ | Пик RSS до → после A, МиБ | Рост пика, МиБ | Тела целиком в памяти были бы, МиБ | Рост пика от B (11 МиБ ×12), МиБ | memory.peak cgroup, МиБ |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| 81410605dad3 | 6 | 95.1 | 95.1 → 131.0 | 35.9 | 52.6 | 0.0 | None |
|
||||
| ccaea065f01a | 6 | 97.2 | 97.2 → 130.8 | 33.6 | 52.6 | 0.0 | None |
|
||||
REPORT.md: table updated between upload-memory markers
|
||||
PASS: >= 10 concurrent uploads measured; see the table above
|
||||
Reference in New Issue
Block a user