Лаба 4: вложения в S3, уровни 3-5, reconciler (трек 2)

This commit is contained in:
2026-11-14 09:19:07 +03:00
parent ec540a1a72
commit 0dc99c9e33
63 changed files with 4810 additions and 18 deletions
+19
View File
@@ -0,0 +1,19 @@
test_aborted_upload_leaves_no_metadata (student_tests.test_attachments_level4.AttachmentsLevel4.test_aborted_upload_leaves_no_metadata) ... ok
test_attachment_from_another_chat_of_same_user (student_tests.test_attachments_level4.AttachmentsLevel4.test_attachment_from_another_chat_of_same_user) ... ok
test_corrupted_jpeg_and_valid_jpeg (student_tests.test_attachments_level4.AttachmentsLevel4.test_corrupted_jpeg_and_valid_jpeg) ... ok
test_corrupted_png (student_tests.test_attachments_level4.AttachmentsLevel4.test_corrupted_png) ... ok
test_dangerous_filenames (student_tests.test_attachments_level4.AttachmentsLevel4.test_dangerous_filenames) ... ok
test_db_insert_failure_after_s3_put_is_compensated (student_tests.test_attachments_level4.AttachmentsLevel4.test_db_insert_failure_after_s3_put_is_compensated) ... ok
test_foreign_and_unknown_attachment_ids (student_tests.test_attachments_level4.AttachmentsLevel4.test_foreign_and_unknown_attachment_ids) ... ok
test_mime_spoofing (student_tests.test_attachments_level4.AttachmentsLevel4.test_mime_spoofing) ... ok
test_outsider_has_no_access (student_tests.test_attachments_level4.AttachmentsLevel4.test_outsider_has_no_access) ... ok
test_pixel_limit (student_tests.test_attachments_level4.AttachmentsLevel4.test_pixel_limit) ... ok
test_roundtrip_sha256_and_second_member (student_tests.test_attachments_level4.AttachmentsLevel4.test_roundtrip_sha256_and_second_member) ... ok
test_s3_down_gives_503_and_recovers (student_tests.test_attachments_level4.AttachmentsLevel4.test_s3_down_gives_503_and_recovers) ... ok
test_too_large_chunked_without_content_length (student_tests.test_attachments_level4.AttachmentsLevel4.test_too_large_chunked_without_content_length) ... ok
test_too_large_content_length (student_tests.test_attachments_level4.AttachmentsLevel4.test_too_large_content_length) ... ok
----------------------------------------------------------------------
Ran 14 tests in 29.266s
OK
+10
View File
@@ -0,0 +1,10 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 19 minutes ago Up 15 minutes (healthy) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 19 minutes ago Exited (137) 34 seconds ago
mtusi-lab4-lb-1 haproxy:3.0.7-alpine "docker-entrypoint.s…" lb 19 hours ago Up 19 hours 127.0.0.1:8080->8080/tcp
mtusi-lab4-migrate-1 mtusi-messenger:lab4 "python -m src.migra…" migrate 19 minutes ago Exited (0) 15 minutes ago
mtusi-lab4-postgres-1 postgres:16.6-alpine "docker-entrypoint.s…" postgres 19 hours ago Up 15 minutes (healthy) 5432/tcp
mtusi-lab4-reconciler-1 sha256:0e315aeef5f75920354c8c142ee631dfacaf5623bcad6dadb1f5cd1875f9f727 "python -m src.recon…" reconciler 8 hours ago Exited (0) 8 hours ago
mtusi-lab4-s3-1 chrislusf/seaweedfs:4.53 "/entrypoint.sh serv…" s3 8 hours ago Up About a minute (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp
mtusi-lab4-s3-init-1 amazon/aws-cli:2.32.29 "/bin/sh /init/s3-in…" s3-init 8 hours ago Exited (0) 15 minutes ago
mtusi-lab4-valkey-1 valkey/valkey:8.0.1-alpine "docker-entrypoint.s…" valkey 32 hours ago Up 15 minutes (healthy) 6379/tcp
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 129, "failed_attempts": 0, "first_recovery_seconds": 2.316}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+10
View File
@@ -0,0 +1,10 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 23 minutes ago Up 18 minutes (healthy) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 23 minutes ago Exited (137) About a minute ago
mtusi-lab4-lb-1 haproxy:3.0.7-alpine "docker-entrypoint.s…" lb 19 hours ago Up 19 hours 127.0.0.1:8080->8080/tcp
mtusi-lab4-migrate-1 mtusi-messenger:lab4 "python -m src.migra…" migrate 23 minutes ago Exited (0) 2 minutes ago
mtusi-lab4-postgres-1 postgres:16.6-alpine "docker-entrypoint.s…" postgres 19 hours ago Up 19 minutes (healthy) 5432/tcp
mtusi-lab4-reconciler-1 sha256:0e315aeef5f75920354c8c142ee631dfacaf5623bcad6dadb1f5cd1875f9f727 "python -m src.recon…" reconciler 8 hours ago Exited (0) 8 hours ago
mtusi-lab4-s3-1 chrislusf/seaweedfs:4.53 "/entrypoint.sh serv…" s3 8 hours ago Up 5 minutes (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp
mtusi-lab4-s3-init-1 amazon/aws-cli:2.32.29 "/bin/sh /init/s3-in…" s3-init 8 hours ago Exited (0) 2 minutes ago
mtusi-lab4-valkey-1 valkey/valkey:8.0.1-alpine "docker-entrypoint.s…" valkey 32 hours ago Up 19 minutes (healthy) 6379/tcp
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 129, "failed_attempts": 0, "first_recovery_seconds": 2.314}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+2
View File
@@ -0,0 +1,2 @@
{"rounds": 5, "parallel_requests_per_round": 30, "messages_in_history": 5, "replicas_that_answered": ["00be497bb3e0", "1a491e91605b"]}
PASS: same key in parallel -> exactly one message; different body -> 409
+36
View File
@@ -0,0 +1,36 @@
test_chat_creation_rolls_back (student_tests.test_level4.Level4.test_chat_creation_rolls_back) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 400: 'Bad Request'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
test_logout_revokes_session_and_cache (student_tests.test_level4.Level4.test_logout_revokes_session_and_cache) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 401: 'Unauthorized'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
test_postgres_down_returns_bounded_error (student_tests.test_level4.Level4.test_postgres_down_returns_bounded_error) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 503: 'Service Unavailable'>
_warnings.warn(self.warn_message, ResourceWarning)
/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 401: 'Unauthorized'>
_warnings.warn(self.warn_message, ResourceWarning)
/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 503: 'Service Unavailable'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
test_register_race_same_username (student_tests.test_level4.Level4.test_register_race_same_username) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 409: 'Conflict'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
test_valkey_down_falls_back_to_postgres (student_tests.test_level4.Level4.test_valkey_down_falls_back_to_postgres) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 401: 'Unauthorized'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
test_valkey_flush_keeps_sessions (student_tests.test_level4.Level4.test_valkey_flush_keeps_sessions) ... ok
test_wrong_password (student_tests.test_level4.Level4.test_wrong_password) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 401: 'Unauthorized'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
test_x_user_id_gives_no_access (student_tests.test_level4.Level4.test_x_user_id_gives_no_access) ... ok
test_zz_session_expiry (student_tests.test_level4.Level4.test_zz_session_expiry) ... /opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 503: 'Service Unavailable'>
_warnings.warn(self.warn_message, ResourceWarning)
/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 401: 'Unauthorized'>
_warnings.warn(self.warn_message, ResourceWarning)
/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/tempfile.py:484: ResourceWarning: Implicitly cleaning up <HTTPError 503: 'Service Unavailable'>
_warnings.warn(self.warn_message, ResourceWarning)
ok
----------------------------------------------------------------------
Ran 9 tests in 38.172s
OK
+150
View File
@@ -0,0 +1,150 @@
{
"summary": {
"duration_s": 30.0,
"concurrency": 8,
"replicas_seen": [
"6da22c3d39a9",
"96b6387add4f"
],
"requests": 25788,
"ok": 25788,
"errors": 0,
"error_rate": 0.0,
"rps_ok": 859.6,
"latency_ms": {
"p50": 6.5,
"p95": 29.4,
"p99": 51.6
},
"error_statuses": {},
"action": {},
"versions_first_last_seen_s": {
"v1": [
0.0,
30.0
]
}
},
"per_second": {
"0": {
"ok": 623,
"err": 0
},
"1": {
"ok": 903,
"err": 0
},
"2": {
"ok": 988,
"err": 0
},
"3": {
"ok": 765,
"err": 0
},
"4": {
"ok": 865,
"err": 0
},
"5": {
"ok": 697,
"err": 0
},
"6": {
"ok": 811,
"err": 0
},
"7": {
"ok": 861,
"err": 0
},
"8": {
"ok": 941,
"err": 0
},
"9": {
"ok": 953,
"err": 0
},
"10": {
"ok": 884,
"err": 0
},
"11": {
"ok": 880,
"err": 0
},
"12": {
"ok": 1026,
"err": 0
},
"13": {
"ok": 918,
"err": 0
},
"14": {
"ok": 919,
"err": 0
},
"15": {
"ok": 729,
"err": 0
},
"16": {
"ok": 911,
"err": 0
},
"17": {
"ok": 957,
"err": 0
},
"18": {
"ok": 920,
"err": 0
},
"19": {
"ok": 905,
"err": 0
},
"20": {
"ok": 897,
"err": 0
},
"21": {
"ok": 666,
"err": 0
},
"22": {
"ok": 736,
"err": 0
},
"23": {
"ok": 906,
"err": 0
},
"24": {
"ok": 823,
"err": 0
},
"25": {
"ok": 859,
"err": 0
},
"26": {
"ok": 691,
"err": 0
},
"27": {
"ok": 951,
"err": 0
},
"28": {
"ok": 861,
"err": 0
},
"29": {
"ok": 942,
"err": 0
}
}
}
+9
View File
@@ -0,0 +1,9 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 2 hours ago Exited (137) 27 seconds ago
mtusi-lab4-api-2 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 2 hours ago Up 2 hours (healthy) 8080/tcp
mtusi-lab4-lb-1 haproxy:3.0.7-alpine "docker-entrypoint.s…" lb 2 hours ago Up 2 hours 127.0.0.1:8080->8080/tcp
mtusi-lab4-migrate-1 mtusi-messenger:lab4 "python -m src.migra…" migrate 2 hours ago Exited (0) 2 hours ago
mtusi-lab4-postgres-1 postgres:16.6-alpine "docker-entrypoint.s…" postgres 2 hours ago Up 2 hours (healthy) 5432/tcp
mtusi-lab4-s3-1 chrislusf/seaweedfs:4.53 "/entrypoint.sh serv…" s3 14 hours ago Up 14 hours (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp
mtusi-lab4-s3-init-1 amazon/aws-cli:2.32.29 "/bin/sh /init/s3-in…" s3-init 14 hours ago Exited (0) 2 hours ago
mtusi-lab4-valkey-1 valkey/valkey:8.0.1-alpine "docker-entrypoint.s…" valkey 14 hours ago Up 14 hours (healthy) 6379/tcp
+201
View File
@@ -0,0 +1,201 @@
{
"summary": {
"duration_s": 40.0,
"concurrency": 8,
"replicas_seen": [
"6da22c3d39a9",
"96b6387add4f"
],
"requests": 23887,
"ok": 23887,
"errors": 0,
"error_rate": 0.0,
"rps_ok": 597.2,
"latency_ms": {
"p50": 7.3,
"p95": 55.0,
"p99": 85.4
},
"error_statuses": {},
"action": {
"target": "6da22c3d39a9",
"started_at": 10.0,
"finished_at": 12.54,
"exit_code": 0
},
"errors_after_action": 0,
"recovery_s": 0.0,
"max_stall_s": 0.15,
"instances_in_last_5s": [
"96b6387add4f"
],
"versions_first_last_seen_s": {
"v1": [
0.0,
40.0
]
}
},
"per_second": {
"0": {
"ok": 781,
"err": 0
},
"1": {
"ok": 816,
"err": 0
},
"2": {
"ok": 916,
"err": 0
},
"3": {
"ok": 966,
"err": 0
},
"4": {
"ok": 592,
"err": 0
},
"5": {
"ok": 656,
"err": 0
},
"6": {
"ok": 696,
"err": 0
},
"7": {
"ok": 982,
"err": 0
},
"8": {
"ok": 851,
"err": 0
},
"9": {
"ok": 927,
"err": 0
},
"10": {
"ok": 958,
"err": 0
},
"11": {
"ok": 667,
"err": 0
},
"12": {
"ok": 510,
"err": 0
},
"13": {
"ok": 555,
"err": 0
},
"14": {
"ok": 530,
"err": 0
},
"15": {
"ok": 518,
"err": 0
},
"16": {
"ok": 330,
"err": 0
},
"17": {
"ok": 523,
"err": 0
},
"18": {
"ok": 475,
"err": 0
},
"19": {
"ok": 476,
"err": 0
},
"20": {
"ok": 544,
"err": 0
},
"21": {
"ok": 550,
"err": 0
},
"22": {
"ok": 490,
"err": 0
},
"23": {
"ok": 499,
"err": 0
},
"24": {
"ok": 521,
"err": 0
},
"25": {
"ok": 524,
"err": 0
},
"26": {
"ok": 515,
"err": 0
},
"27": {
"ok": 245,
"err": 0
},
"28": {
"ok": 579,
"err": 0
},
"29": {
"ok": 491,
"err": 0
},
"30": {
"ok": 536,
"err": 0
},
"31": {
"ok": 454,
"err": 0
},
"32": {
"ok": 587,
"err": 0
},
"33": {
"ok": 549,
"err": 0
},
"34": {
"ok": 564,
"err": 0
},
"35": {
"ok": 562,
"err": 0
},
"36": {
"ok": 565,
"err": 0
},
"37": {
"ok": 467,
"err": 0
},
"38": {
"ok": 337,
"err": 0
},
"39": {
"ok": 583,
"err": 0
}
}
}
+9
View File
@@ -0,0 +1,9 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 2 hours ago Up 56 seconds (healthy) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 2 hours ago Exited (137) 28 seconds ago
mtusi-lab4-lb-1 haproxy:3.0.7-alpine "docker-entrypoint.s…" lb 2 hours ago Up 2 hours 127.0.0.1:8080->8080/tcp
mtusi-lab4-migrate-1 mtusi-messenger:lab4 "python -m src.migra…" migrate 2 hours ago Exited (0) 56 seconds ago
mtusi-lab4-postgres-1 postgres:16.6-alpine "docker-entrypoint.s…" postgres 2 hours ago Up 2 hours (healthy) 5432/tcp
mtusi-lab4-s3-1 chrislusf/seaweedfs:4.53 "/entrypoint.sh serv…" s3 14 hours ago Up 14 hours (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp
mtusi-lab4-s3-init-1 amazon/aws-cli:2.32.29 "/bin/sh /init/s3-in…" s3-init 14 hours ago Exited (0) 57 seconds ago
mtusi-lab4-valkey-1 valkey/valkey:8.0.1-alpine "docker-entrypoint.s…" valkey 14 hours ago Up 14 hours (healthy) 6379/tcp
+201
View File
@@ -0,0 +1,201 @@
{
"summary": {
"duration_s": 40.0,
"concurrency": 8,
"replicas_seen": [
"6da22c3d39a9",
"96b6387add4f"
],
"requests": 22558,
"ok": 22558,
"errors": 0,
"error_rate": 0.0,
"rps_ok": 564.0,
"latency_ms": {
"p50": 7.0,
"p95": 56.3,
"p99": 87.0
},
"error_statuses": {},
"action": {
"target": "96b6387add4f",
"started_at": 10.01,
"finished_at": 12.32,
"exit_code": 0
},
"errors_after_action": 0,
"recovery_s": 0.0,
"max_stall_s": 0.29,
"instances_in_last_5s": [
"6da22c3d39a9"
],
"versions_first_last_seen_s": {
"v1": [
0.0,
40.0
]
}
},
"per_second": {
"0": {
"ok": 545,
"err": 0
},
"1": {
"ok": 611,
"err": 0
},
"2": {
"ok": 888,
"err": 0
},
"3": {
"ok": 829,
"err": 0
},
"4": {
"ok": 831,
"err": 0
},
"5": {
"ok": 848,
"err": 0
},
"6": {
"ok": 830,
"err": 0
},
"7": {
"ok": 796,
"err": 0
},
"8": {
"ok": 808,
"err": 0
},
"9": {
"ok": 481,
"err": 0
},
"10": {
"ok": 667,
"err": 0
},
"11": {
"ok": 412,
"err": 0
},
"12": {
"ok": 452,
"err": 0
},
"13": {
"ok": 385,
"err": 0
},
"14": {
"ok": 440,
"err": 0
},
"15": {
"ok": 511,
"err": 0
},
"16": {
"ok": 541,
"err": 0
},
"17": {
"ok": 539,
"err": 0
},
"18": {
"ok": 486,
"err": 0
},
"19": {
"ok": 480,
"err": 0
},
"20": {
"ok": 288,
"err": 0
},
"21": {
"ok": 577,
"err": 0
},
"22": {
"ok": 565,
"err": 0
},
"23": {
"ok": 531,
"err": 0
},
"24": {
"ok": 575,
"err": 0
},
"25": {
"ok": 574,
"err": 0
},
"26": {
"ok": 531,
"err": 0
},
"27": {
"ok": 559,
"err": 0
},
"28": {
"ok": 565,
"err": 0
},
"29": {
"ok": 572,
"err": 0
},
"30": {
"ok": 299,
"err": 0
},
"31": {
"ok": 393,
"err": 0
},
"32": {
"ok": 507,
"err": 0
},
"33": {
"ok": 525,
"err": 0
},
"34": {
"ok": 514,
"err": 0
},
"35": {
"ok": 556,
"err": 0
},
"36": {
"ok": 572,
"err": 0
},
"37": {
"ok": 506,
"err": 0
},
"38": {
"ok": 501,
"err": 0
},
"39": {
"ok": 468,
"err": 0
}
}
}
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost: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.
+7
View File
@@ -0,0 +1,7 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 17 minutes ago Up 12 minutes (healthy) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 17 minutes ago Up 12 minutes (healthy) 8080/tcp
mtusi-lab4-lb-1 haproxy:3.0.7-alpine "docker-entrypoint.s…" lb 19 hours ago Up 19 hours 127.0.0.1:8080->8080/tcp
mtusi-lab4-postgres-1 postgres:16.6-alpine "docker-entrypoint.s…" postgres 19 hours ago Up 12 minutes (healthy) 5432/tcp
mtusi-lab4-s3-1 chrislusf/seaweedfs:4.53 "/entrypoint.sh serv…" s3 8 hours ago Up 12 minutes (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp
mtusi-lab4-valkey-1 valkey/valkey:8.0.1-alpine "docker-entrypoint.s…" valkey 32 hours ago Up 12 minutes (healthy) 6379/tcp
+7
View File
@@ -0,0 +1,7 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab4-api-1 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 29 minutes ago Up 29 minutes (healthy) 8080/tcp
mtusi-lab4-api-2 mtusi-messenger:lab4 "sh -c 'exec uvicorn…" api 29 minutes ago Up 29 minutes (healthy) 8080/tcp
mtusi-lab4-lb-1 haproxy:3.0.7-alpine "docker-entrypoint.s…" lb 12 hours ago Up 12 hours 127.0.0.1:8080->8080/tcp
mtusi-lab4-postgres-1 postgres:16.6-alpine "docker-entrypoint.s…" postgres 12 hours ago Up 10 hours (healthy) 5432/tcp
mtusi-lab4-s3-1 chrislusf/seaweedfs:4.53 "/entrypoint.sh serv…" s3 29 minutes ago Up 17 minutes (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp
mtusi-lab4-valkey-1 valkey/valkey:8.0.1-alpine "docker-entrypoint.s…" valkey 25 hours ago Up 10 hours (healthy) 6379/tcp
+6
View File
@@ -0,0 +1,6 @@
Container mtusi-lab4-s3-init-run-59b11da77c9b Creating
Container mtusi-lab4-s3-init-run-59b11da77c9b Created
bucket messenger-attachments already exists
Container mtusi-lab4-s3-init-run-770039d96f76 Creating
Container mtusi-lab4-s3-init-run-770039d96f76 Created
bucket messenger-attachments already exists
+24
View File
@@ -0,0 +1,24 @@
# bucket=messenger-attachments, проверяется объект attachments/21978dc4-8c5c-4641-9263-16f6e904804d
PASS анонимный GET объекта напрямую из S3 -> HTTP 403
PASS анонимный список bucket -> HTTP 403
PASS анонимный список всех bucket -> HTTP 403
# ответы S3 для API-ключа: {'create_bucket': 'AccessDenied', 'put_to_other_bucket': 'AccessDenied', 'get_from_other_bucket': 'AccessDenied', 'put_object_own_bucket': 'ALLOWED', 'delete_probe_own_bucket': 'ALLOWED'}
PASS API-ключ не может создавать bucket
PASS API-ключ не может писать в чужой bucket
PASS API-ключ не читает чужой bucket (NoSuchBucket/AccessDenied)
PASS в своём bucket API-ключ работает (put/delete)
# /run/secrets в api: database_url s3_api_access_key_id s3_api_secret_access_key
PASS в контейнере api нет админских S3-секретов
PASS S3 не публикует порты на хост (docker port: 'пусто')
PASS lb -> s3:9000 недостижим
PASS lb -> s3:8888 недостижим
PASS lb -> s3:9333 недостижим
PASS postgres -> s3:9000 недостижим
PASS postgres -> s3:8888 недостижим
PASS postgres -> s3:9333 недостижим
PASS valkey -> s3:9000 недостижим
PASS valkey -> s3:8888 недостижим
PASS valkey -> s3:9333 недостижим
INFO порты s3, открытые из api (внутри изолированной сети storage): {"9000": true, "8333": false, "8888": true, "9333": true, "8080": true}
ИТОГ: PASS
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
+32
View File
@@ -0,0 +1,32 @@
1. Orphan file created successfully!
Container mtusi-lab4-s3-1 Running
Container mtusi-lab4-postgres-1 Running
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-s3-init-1 Starting
Container mtusi-lab4-s3-init-1 Started
Container mtusi-lab4-s3-init-1 Waiting
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-s3-init-1 Exited
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-reconciler-run-6356b2614037 Creating
Container mtusi-lab4-reconciler-run-6356b2614037 Created
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "--dry-run": executable file not found in $PATH
Container mtusi-lab4-postgres-1 Running
Container mtusi-lab4-s3-1 Running
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-s3-init-1 Starting
Container mtusi-lab4-s3-init-1 Started
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-s3-init-1 Waiting
Container mtusi-lab4-s3-init-1 Exited
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-reconciler-run-f9528845606a Creating
Container mtusi-lab4-reconciler-run-f9528845606a Created
2026-11-13 20:32:44,185 [INFO] Starting S3 reconciliation...
2026-11-13 20:32:44,186 [INFO] Found 2 objects in PostgreSQL.
2026-11-13 20:32:44,245 [INFO] Found 1 orphaned objects to delete.
2026-11-13 20:32:44,246 [INFO] Deleted orphan: attachments/orphan-test-file
2026-11-13 20:32:44,246 [INFO] Reconciliation complete.
УСПЕХ: Файл успешно удален (404 Not Found)
+48
View File
@@ -0,0 +1,48 @@
== 0. Базовая очистка (чтобы счётчики ниже были точными)
reconciler --apply -> {"db_query_s": 0.001, "db_rows": 57, "dry_run": false, "elapsed_s": 0.076, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 0, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 0, "orphans_fresh_skipped": 0, "peak_rss_mib": 51.6, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 1, "s3_list_s": 0.075, "s3_objects": 55, "size_mismatch": 0} [exit 0]
== 1. Данные: используемые и неиспользуемые вложения
== 2. Внедрение ошибок. S3-сторона: 3 объекта без метаданных; БД-сторона: у 2 записей объект удалён
== 3. DRY-RUN: обнаруживает, но ничего не меняет
reconciler (dry-run) -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": true, "elapsed_s": 0.063, "grace_seconds": 30, "missing_found": 2, "missing_fresh_skipped": 1, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 3, "orphans_fresh_skipped": 1, "peak_rss_mib": 52.6, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 1, "s3_list_s": 0.062, "s3_objects": 61, "size_mismatch": 0} [exit 0]
PASS dry-run нашёл 3 сирот и 2 потерянных объекта
PASS свежие сирота и запись (моложе grace) пропущены
PASS dry-run ничего не изменил в счётчиках
PASS после dry-run все сироты ещё в S3
PASS после dry-run состояния записей не изменены
== 4. APPLY и сразу повторный APPLY (идемпотентность)
reconciler --apply -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 0.068, "grace_seconds": 30, "missing_found": 2, "missing_fresh_skipped": 1, "missing_marked": 2, "orphans_deleted": 3, "orphans_found": 3, "orphans_fresh_skipped": 1, "peak_rss_mib": 51.8, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 1, "s3_list_s": 0.06, "s3_objects": 61, "size_mismatch": 0} [exit 0]
reconciler --apply -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 0.064, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 1, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 0, "orphans_fresh_skipped": 1, "peak_rss_mib": 51.6, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 1, "s3_list_s": 0.062, "s3_objects": 58, "size_mismatch": 0} [exit 0]
PASS удалены 3 сироты, помечены 2 потерянных объекта
PASS повторный apply ничего не находит и не меняет
PASS свежая сирота НЕ удалена (grace period)
PASS свежая запись без объекта НЕ помечена (grace period)
PASS старые сироты удалены из S3
PASS используемое вложение старше grace цело и скачивается
PASS неиспользуемое, но с метаданными вложение старше grace цело и скачивается
PASS потерянные вложения: скачивание 409, а не 500
PASS метаданные потерянного вложения остаются (запись не удалена)
PASS потерянное вложение нельзя прикрепить к новому сообщению (409)
== 6. Восстановление: объект вернули на то же место
reconciler --apply -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 0.066, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 1, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 0, "orphans_fresh_skipped": 1, "peak_rss_mib": 51.6, "race_skipped": 0, "restore_found": 1, "restored": 1, "s3_list_pages": 1, "s3_list_s": 0.062, "s3_objects": 59, "size_mismatch": 0} [exit 0]
PASS запись снова ok после проверки размера и SHA-256
PASS восстановленное вложение скачивается
== 7. Прошёл grace: бывшие свежие объекты теперь обрабатываются
reconciler --apply -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 0.068, "grace_seconds": 30, "missing_found": 1, "missing_fresh_skipped": 0, "missing_marked": 1, "orphans_deleted": 1, "orphans_found": 1, "orphans_fresh_skipped": 0, "peak_rss_mib": 51.6, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 1, "s3_list_s": 0.062, "s3_objects": 59, "size_mismatch": 0} [exit 0]
PASS теперь удалена вторая сирота и помечена вторая потеря
== 8. Стоимость обхода и предохранитель
-- seed 1000 объектов-сирот
reconciler (dry-run) -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": true, "elapsed_s": 0.113, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 0, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 1000, "orphans_fresh_skipped": 0, "peak_rss_mib": 54.0, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 2, "s3_list_s": 0.099, "s3_objects": 1058, "size_mismatch": 0} [exit 0]
dry-run N=1000: reconciler elapsed=0.113s s3_list=0.099s pages=2 db_rows=62 peak_rss=54.0MiB (с запуском контейнера 0.9s)
PASS dry-run видит 1000 сирот
reconciler --apply --max-actions 1100 -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 0.826, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 0, "missing_marked": 0, "orphans_deleted": 1000, "orphans_found": 1000, "orphans_fresh_skipped": 0, "peak_rss_mib": 53.2, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 2, "s3_list_s": 0.093, "s3_objects": 1058, "size_mismatch": 0} [exit 0]
PASS очистка 1000 сирот выполнена
-- seed 5000 объектов-сирот
reconciler (dry-run) -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": true, "elapsed_s": 0.319, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 0, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 5000, "orphans_fresh_skipped": 0, "peak_rss_mib": 56.9, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 6, "s3_list_s": 0.259, "s3_objects": 5058, "size_mismatch": 0} [exit 0]
dry-run N=5000: reconciler elapsed=0.319s s3_list=0.259s pages=6 db_rows=62 peak_rss=56.9MiB (с запуском контейнера 1.2s)
PASS dry-run видит 5000 сирот
reconciler --apply -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 0.32, "error": "too_many_actions", "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 0, "missing_marked": 0, "orphans_deleted": 0, "orphans_found": 5000, "orphans_fresh_skipped": 0, "peak_rss_mib": 55.8, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 6, "s3_list_s": 0.262, "s3_objects": 5058, "size_mismatch": 0} [exit 3]
PASS предохранитель: массовое удаление выше --max-actions отклонено, ничего не удалено
reconciler --apply --max-actions 5100 -> {"db_query_s": 0.001, "db_rows": 62, "dry_run": false, "elapsed_s": 5.797, "grace_seconds": 30, "missing_found": 0, "missing_fresh_skipped": 0, "missing_marked": 0, "orphans_deleted": 5000, "orphans_found": 5000, "orphans_fresh_skipped": 0, "peak_rss_mib": 56.1, "race_skipped": 0, "restore_found": 0, "restored": 0, "s3_list_pages": 6, "s3_list_s": 0.249, "s3_objects": 5058, "size_mismatch": 0} [exit 0]
PASS очистка 5000 сирот выполнена
ИТОГ: PASS
+16
View File
@@ -0,0 +1,16 @@
Container mtusi-lab4-postgres-1 Running
Container mtusi-lab4-s3-1 Running
Container mtusi-lab4-s3-1 Waiting
Container mtusi-lab4-s3-1 Healthy
Container mtusi-lab4-s3-init-1 Starting
Container mtusi-lab4-s3-init-1 Started
Container mtusi-lab4-s3-init-1 Waiting
Container mtusi-lab4-postgres-1 Waiting
Container mtusi-lab4-s3-init-1 Exited
Container mtusi-lab4-postgres-1 Healthy
Container mtusi-lab4-reconciler-run-c1fad231a43b Creating
Container mtusi-lab4-reconciler-run-c1fad231a43b Created
2026-11-13 20:35:15,514 [INFO] Starting S3 reconciliation...
2026-11-13 20:35:15,516 [INFO] Found 2 objects in PostgreSQL.
2026-11-13 20:35:15,588 [INFO] No orphaned objects found.
УСПЕХ: Свежий файл НЕ удален, grace period работает!
@@ -0,0 +1,27 @@
{
"mode": "single-idat",
"concurrency": 10,
"file_mib": 9.81,
"payload_total_mib": 98.1,
"wall_s": 6.1,
"statuses": [
201
],
"ok": 10,
"containers": {
"1a491e91605b": {
"limit_mib": 256,
"baseline_anon_mib": 77.2,
"peak_anon_mib": 83.1,
"anon_growth_mib": 5.9,
"peak_current_mib_incl_page_cache": 141.2
},
"00be497bb3e0": {
"limit_mib": 256,
"baseline_anon_mib": 76.2,
"peak_anon_mib": 81.2,
"anon_growth_mib": 5.1,
"peak_current_mib_incl_page_cache": 136.3
}
}
}
+27
View File
@@ -0,0 +1,27 @@
{
"mode": "normal",
"concurrency": 10,
"file_mib": 9.81,
"payload_total_mib": 98.1,
"wall_s": 6.1,
"statuses": [
201
],
"ok": 10,
"containers": {
"1a491e91605b": {
"limit_mib": 256,
"baseline_anon_mib": 63.7,
"peak_anon_mib": 79.3,
"anon_growth_mib": 15.6,
"peak_current_mib_incl_page_cache": 137.0
},
"00be497bb3e0": {
"limit_mib": 256,
"baseline_anon_mib": 61.5,
"peak_anon_mib": 80.1,
"anon_growth_mib": 18.6,
"peak_current_mib_incl_page_cache": 138.6
}
}
}
+27
View File
@@ -0,0 +1,27 @@
{
"mode": "normal",
"concurrency": 20,
"file_mib": 9.81,
"payload_total_mib": 196.2,
"wall_s": 8.9,
"statuses": [
201
],
"ok": 20,
"containers": {
"c816acfa90c4": {
"limit_mib": 256,
"baseline_anon_mib": 51.3,
"peak_anon_mib": 100.8,
"anon_growth_mib": 49.5,
"peak_current_mib_incl_page_cache": 212.8
},
"1c8d7116a019": {
"limit_mib": 256,
"baseline_anon_mib": 64.0,
"peak_anon_mib": 98.5,
"anon_growth_mib": 34.4,
"peak_current_mib_incl_page_cache": 211.6
}
}
}
+28
View File
@@ -0,0 +1,28 @@
{
"mode": "normal",
"concurrency": 20,
"file_mib": 9.81,
"payload_total_mib": 196.2,
"wall_s": 8.5,
"statuses": [
201,
503
],
"ok": 1,
"containers": {
"1a491e91605b": {
"limit_mib": 256,
"baseline_anon_mib": 77.8,
"peak_anon_mib": 96.7,
"anon_growth_mib": 18.9,
"peak_current_mib_incl_page_cache": 202.2
},
"00be497bb3e0": {
"limit_mib": 256,
"baseline_anon_mib": 76.5,
"peak_anon_mib": 108.6,
"anon_growth_mib": 32.1,
"peak_current_mib_incl_page_cache": 204.2
}
}
}