forked from mtusi2026/mtusi2026lab4
ЛР4: S3-вложения (SeaweedFS), приватный bucket, компенсация/reconciler, тесты, отчёт
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Failover: stop ONE API replica under load, verified recovery via the LB
|
||||
## containers before
|
||||
messenger-lab4-api-1 Up About a minute (healthy)
|
||||
messenger-lab4-api-2 Up About a minute (healthy)
|
||||
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 137, "failed_attempts": 0, "first_recovery_seconds": 0.89}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
Container messenger-lab4-postgres-1 Running
|
||||
Container messenger-lab4-migrate-1 Created
|
||||
Container messenger-lab4-s3-1 Running
|
||||
Container messenger-lab4-valkey-1 Running
|
||||
Container messenger-lab4-s3-init-1 Created
|
||||
Container messenger-lab4-api-1 Created
|
||||
Container messenger-lab4-api-2 Running
|
||||
Container messenger-lab4-postgres-1 Waiting
|
||||
Container messenger-lab4-s3-1 Waiting
|
||||
Container messenger-lab4-postgres-1 Healthy
|
||||
Container messenger-lab4-migrate-1 Starting
|
||||
Container messenger-lab4-s3-1 Healthy
|
||||
Container messenger-lab4-s3-init-1 Starting
|
||||
Container messenger-lab4-migrate-1 Started
|
||||
Container messenger-lab4-s3-init-1 Started
|
||||
Container messenger-lab4-valkey-1 Waiting
|
||||
Container messenger-lab4-migrate-1 Waiting
|
||||
Container messenger-lab4-s3-init-1 Waiting
|
||||
Container messenger-lab4-valkey-1 Healthy
|
||||
Container messenger-lab4-migrate-1 Exited
|
||||
Container messenger-lab4-s3-init-1 Exited
|
||||
Container messenger-lab4-api-1 Starting
|
||||
Container messenger-lab4-api-1 Started
|
||||
|
||||
## containers after restore
|
||||
messenger-lab4-api-1 Up Less than a second (health: starting)
|
||||
messenger-lab4-api-2 Up About a minute (healthy)
|
||||
@@ -0,0 +1,24 @@
|
||||
# Persistence: restart API replicas + lb + PostgreSQL + Valkey + S3 (volumes kept)
|
||||
## containers before
|
||||
messenger-lab4-api-1 Up 2 minutes (healthy)
|
||||
messenger-lab4-api-2 Up 2 minutes (healthy)
|
||||
messenger-lab4-lb-1 Up 5 minutes (healthy)
|
||||
messenger-lab4-postgres-1 Up 5 minutes (healthy)
|
||||
messenger-lab4-s3-1 Up 54 seconds (healthy)
|
||||
messenger-lab4-valkey-1 Up 5 minutes (healthy)
|
||||
|
||||
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
|
||||
messenger-lab4-api-1 Up 32 seconds (healthy)
|
||||
messenger-lab4-api-2 Up 32 seconds (healthy)
|
||||
messenger-lab4-lb-1 Up 32 seconds (health: starting)
|
||||
messenger-lab4-postgres-1 Up 32 seconds (healthy)
|
||||
messenger-lab4-s3-1 Up 24 seconds (healthy)
|
||||
messenger-lab4-valkey-1 Up 33 seconds (healthy)
|
||||
|
||||
## volumes still present
|
||||
messenger-lab4_pgdata
|
||||
messenger-lab4_s3data
|
||||
messenger-lab4_valkeydata
|
||||
@@ -0,0 +1,10 @@
|
||||
Container messenger-lab4-s3-1 Stopping
|
||||
Container messenger-lab4-s3-1 Stopped
|
||||
Container messenger-lab4-s3-1 Starting
|
||||
Container messenger-lab4-s3-1 Started
|
||||
baseline: upload = 201
|
||||
stopping s3 ...
|
||||
s3 down: /health/ready = 503, upload = 503 (bounded)
|
||||
s3 down: /users/me = 200 (metadata unaffected)
|
||||
s3 restored: upload = 201
|
||||
PASS: S3 outage degrades to bounded 503 and recovers
|
||||
@@ -0,0 +1,2 @@
|
||||
anonymous GET -> 403 (denied)
|
||||
PASS: private bucket denies anonymous access
|
||||
@@ -0,0 +1,13 @@
|
||||
# S3/DB consistency: orphan detection with a safe grace period, then cleanup
|
||||
== baseline ==
|
||||
{"db_attachments": 44, "s3_objects": 44, "orphans": 0, "missing": 0, "apply": false, "grace_seconds": 3600}
|
||||
== create an orphan object (simulated crash between PUT and COMMIT) ==
|
||||
orphan put
|
||||
== reconcile dry-run (fresh orphan kept by grace period) ==
|
||||
{"db_attachments": 44, "s3_objects": 45, "orphans": 0, "missing": 0, "apply": false, "grace_seconds": 3600}
|
||||
== reconcile --apply --grace-seconds 0 ==
|
||||
{"db_attachments": 44, "s3_objects": 45, "orphans": 1, "missing": 0, "apply": true, "grace_seconds": 0}
|
||||
orphan: chats/orphan/demo
|
||||
{"deleted_orphans": 1}
|
||||
== reconcile after cleanup ==
|
||||
{"db_attachments": 44, "s3_objects": 44, "orphans": 0, "missing": 0, "apply": false, "grace_seconds": 3600}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Public acceptance scenario (lab4)
|
||||
$ 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,58 @@
|
||||
# Student black-box tests (grade 4), one command
|
||||
$ C:\IT-labs\VNP\mtusi2026lab4\.venv\Scripts\python.exe -m pytest student-tests -v
|
||||
============================= test session starts =============================
|
||||
platform win32 -- Python 3.11.9, pytest-8.3.4, pluggy-1.7.0 -- C:\IT-labs\VNP\mtusi2026lab4\.venv\Scripts\python.exe
|
||||
cachedir: .pytest_cache
|
||||
rootdir: C:\IT-labs\VNP\mtusi2026lab4
|
||||
plugins: anyio-4.16.0
|
||||
collecting ... collected 47 items
|
||||
|
||||
student-tests/test_attachments.py::test_upload_download_roundtrip PASSED [ 2%]
|
||||
student-tests/test_attachments.py::test_foreign_actor_gets_404 PASSED [ 4%]
|
||||
student-tests/test_attachments.py::test_cross_chat_attachment_is_404 PASSED [ 6%]
|
||||
student-tests/test_attachments.py::test_oversized_upload_is_413 PASSED [ 8%]
|
||||
student-tests/test_attachments.py::test_corrupt_image_is_415 PASSED [ 10%]
|
||||
student-tests/test_attachments.py::test_mime_spoof_is_415 PASSED [ 12%]
|
||||
student-tests/test_attachments.py::test_empty_upload_is_415 PASSED [ 14%]
|
||||
student-tests/test_attachments.py::test_unsafe_filename_is_400 PASSED [ 17%]
|
||||
student-tests/test_attachments.py::test_empty_text_without_attachment_is_400 PASSED [ 19%]
|
||||
student-tests/test_attachments.py::test_message_idempotency_includes_attachments PASSED [ 21%]
|
||||
student-tests/test_auth.py::test_registration_requires_password PASSED [ 23%]
|
||||
student-tests/test_auth.py::test_short_password_is_400 PASSED [ 25%]
|
||||
student-tests/test_auth.py::test_extra_field_is_400 PASSED [ 27%]
|
||||
student-tests/test_auth.py::test_malformed_json_is_400 PASSED [ 29%]
|
||||
student-tests/test_auth.py::test_duplicate_username_is_409 PASSED [ 31%]
|
||||
student-tests/test_auth.py::test_registration_never_returns_password PASSED [ 34%]
|
||||
student-tests/test_auth.py::test_wrong_password_is_401_basic PASSED [ 36%]
|
||||
student-tests/test_auth.py::test_unknown_user_is_401_basic PASSED [ 38%]
|
||||
student-tests/test_auth.py::test_basic_on_business_endpoint_is_401_bearer PASSED [ 40%]
|
||||
student-tests/test_auth.py::test_missing_auth_is_401_bearer PASSED [ 42%]
|
||||
student-tests/test_auth.py::test_unknown_bearer_is_401 PASSED [ 44%]
|
||||
student-tests/test_auth.py::test_x_user_id_is_ignored PASSED [ 46%]
|
||||
student-tests/test_auth.py::test_logout_revokes_session PASSED [ 48%]
|
||||
student-tests/test_concurrency.py::test_100_concurrent_messages_are_not_lost PASSED [ 51%]
|
||||
student-tests/test_idempotency.py::test_replay_same_key_returns_same_message PASSED [ 53%]
|
||||
student-tests/test_idempotency.py::test_same_key_different_body_is_409 PASSED [ 55%]
|
||||
student-tests/test_idempotency.py::test_missing_key_is_400 PASSED [ 57%]
|
||||
student-tests/test_idempotency.py::test_invalid_key_is_400 PASSED [ 59%]
|
||||
student-tests/test_idempotency.py::test_concurrent_same_key_creates_exactly_one_message PASSED [ 61%]
|
||||
student-tests/test_instances.py::test_instance_header_present_on_success PASSED [ 63%]
|
||||
student-tests/test_instances.py::test_instance_header_present_on_error PASSED [ 65%]
|
||||
student-tests/test_instances.py::test_at_least_two_instances_seen_through_lb PASSED [ 68%]
|
||||
student-tests/test_negative.py::test_foreign_chat_is_404 PASSED [ 70%]
|
||||
student-tests/test_negative.py::test_empty_message_is_400 PASSED [ 72%]
|
||||
student-tests/test_negative.py::test_oversized_message_is_400 PASSED [ 74%]
|
||||
student-tests/test_negative.py::test_limit_out_of_range_is_400 PASSED [ 76%]
|
||||
student-tests/test_negative.py::test_sender_id_in_body_is_rejected PASSED [ 78%]
|
||||
student-tests/test_negative.py::test_chat_without_caller_is_400 PASSED [ 80%]
|
||||
student-tests/test_negative.py::test_chat_with_unknown_member_is_400 PASSED [ 82%]
|
||||
student-tests/test_negative.py::test_chat_with_duplicate_members_is_400 PASSED [ 85%]
|
||||
student-tests/test_pagination.py::test_full_traversal_without_duplicates PASSED [ 87%]
|
||||
student-tests/test_pagination.py::test_cursor_from_other_chat_is_400 PASSED [ 89%]
|
||||
student-tests/test_pagination.py::test_garbage_cursor_is_400 PASSED [ 91%]
|
||||
student-tests/test_pagination.py::test_well_formed_cursor_with_wrong_types_is_400 PASSED [ 93%]
|
||||
student-tests/test_race.py::test_concurrent_duplicate_username_single_winner PASSED [ 95%]
|
||||
student-tests/test_race.py::test_failed_chat_creation_rolls_back PASSED [ 97%]
|
||||
student-tests/test_session_revocation.py::test_logout_invalidates_across_replicas PASSED [100%]
|
||||
|
||||
============================= 47 passed in 5.57s ==============================
|
||||
@@ -0,0 +1,6 @@
|
||||
# 12 concurrent uploads of ~6 MiB through the balancer; API memory sampled
|
||||
## baseline (idle)
|
||||
messenger-lab4-api-2 98.11MiB / 256MiB
|
||||
messenger-lab4-api-1 79.3MiB / 256MiB
|
||||
{"file_bytes": 6292108, "uploads": 12}
|
||||
{"ok": 12, "errors": [], "seconds": 4.27, "api_peak_mem_mb": 388.7}
|
||||
Reference in New Issue
Block a user