$ python scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
exit=0

$ python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
exit=0

$ python tests/smoke.py --base-url http://127.0.0.1:8080
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
exit=0

$ python -m unittest discover -s student-tests -p test_api.py -v
test_bearer_rules (test_api.AuthTest.test_bearer_rules) ... ok
test_concurrent_registration_of_same_username (test_api.AuthTest.test_concurrent_registration_of_same_username) ... ok
test_logout_revokes_in_database_and_cache (test_api.AuthTest.test_logout_revokes_in_database_and_cache) ... ok
test_password_is_not_exposed_or_stored_plain (test_api.AuthTest.test_password_is_not_exposed_or_stored_plain) ... ok
test_register_validation (test_api.AuthTest.test_register_validation) ... ok
test_session_shape_entropy_and_logout (test_api.AuthTest.test_session_shape_entropy_and_logout) ... ok
test_token_only_stored_as_hash (test_api.AuthTest.test_token_only_stored_as_hash) ... ok
test_wrong_password_and_unknown_user_are_indistinguishable (test_api.AuthTest.test_wrong_password_and_unknown_user_are_indistinguishable) ... ok
test_chat_creation_is_atomic (test_api.DataTest.test_chat_creation_is_atomic) ... ok
test_foreign_chat_empty_message_bad_json (test_api.DataTest.test_foreign_chat_empty_message_bad_json) ... ok
test_multi_page_history_and_cursor_binding (test_api.DataTest.test_multi_page_history_and_cursor_binding) ... ok
test_parallel_writes_from_many_clients (test_api.DataTest.test_parallel_writes_from_many_clients) ... ok

----------------------------------------------------------------------
Ran 12 tests in 2.559s

OK
exit=0

$ python -m unittest discover -s student-tests -p test_idempotency.py -v
test_concurrent_same_key_creates_exactly_one_message_across_replicas (test_idempotency.IdempotencyTest.test_concurrent_same_key_creates_exactly_one_message_across_replicas) ... ok
test_different_body_same_key_is_409 (test_idempotency.IdempotencyTest.test_different_body_same_key_is_409) ... ok
test_expired_key_is_reusable_after_ttl (test_idempotency.IdempotencyTest.test_expired_key_is_reusable_after_ttl) ... ok
test_key_validation (test_idempotency.IdempotencyTest.test_key_validation) ... ok
test_replay_rechecks_session_and_membership (test_idempotency.IdempotencyTest.test_replay_rechecks_session_and_membership) ... ok
test_replay_returns_same_message_and_creates_no_duplicate (test_idempotency.IdempotencyTest.test_replay_returns_same_message_and_creates_no_duplicate) ... ok
test_scope_is_user_and_chat (test_idempotency.IdempotencyTest.test_scope_is_user_and_chat) ... ok
test_semantically_equal_body_is_replayed (test_idempotency.IdempotencyTest.test_semantically_equal_body_is_replayed) ... ok
test_session_is_shared_between_replicas_without_relogin (test_idempotency.IdempotencyTest.test_session_is_shared_between_replicas_without_relogin) ... ok

----------------------------------------------------------------------
Ran 9 tests in 1.806s

OK
exit=0

$ python -m unittest discover -s student-tests -p test_attachments.py -v
test_aborted_upload_leaves_nothing (test_attachments.AttachmentTest.test_aborted_upload_leaves_nothing) ... ok
test_bucket_is_private_outside_the_api (test_attachments.AttachmentTest.test_bucket_is_private_outside_the_api) ... ok
test_corrupted_and_spoofed_files_are_415_not_500 (test_attachments.AttachmentTest.test_corrupted_and_spoofed_files_are_415_not_500) ... ok
test_dangerous_filenames_are_400 (test_attachments.AttachmentTest.test_dangerous_filenames_are_400) ... ok
test_decompression_bomb_header_is_413 (test_attachments.AttachmentTest.test_decompression_bomb_header_is_413) ... ok
test_empty_body_is_400 (test_attachments.AttachmentTest.test_empty_body_is_400) ... ok
test_foreign_user_cannot_upload_read_or_download (test_attachments.AttachmentTest.test_foreign_user_cannot_upload_read_or_download) ... ok
test_idempotent_replay_with_attachments (test_attachments.AttachmentTest.test_idempotent_replay_with_attachments) ... ok
test_message_with_attachments_and_chat_binding (test_attachments.AttachmentTest.test_message_with_attachments_and_chat_binding) ... ok
test_png_and_jpeg_roundtrip_with_checksum (test_attachments.AttachmentTest.test_png_and_jpeg_roundtrip_with_checksum) ... ok
test_too_large_is_413_and_nothing_is_stored (test_attachments.AttachmentTest.test_too_large_is_413_and_nothing_is_stored) ... ok

----------------------------------------------------------------------
Ran 11 tests in 5.441s

OK
exit=0

$ python -m unittest discover -s student-tests -p test_topology.py -v
test_api_runs_as_non_root (test_topology.TopologyTest.test_api_runs_as_non_root) ... ok
test_at_least_two_api_replicas_without_published_ports (test_topology.TopologyTest.test_at_least_two_api_replicas_without_published_ports) ... ok
test_no_fixed_container_names (test_topology.TopologyTest.test_no_fixed_container_names) ... ok
test_only_lb_is_published_and_only_on_localhost (test_topology.TopologyTest.test_only_lb_is_published_and_only_on_localhost) ... ok
test_resource_limits_are_set (test_topology.TopologyTest.test_resource_limits_are_set) ... ok
test_stop_grace_period_covers_drain (test_topology.TopologyTest.test_stop_grace_period_covers_drain) ... ok

----------------------------------------------------------------------
Ran 6 tests in 1.582s

OK
exit=0

$ python -m unittest discover -s student-tests -p test_pipeline.py -v
test_alpha_is_composited_on_white (test_pipeline.PipelineTest.test_alpha_is_composited_on_white) ... C:\Users\kolya5544\source\repos\vmdMTUCI\mtusi2026lab5\student-tests\test_pipeline.py:25: ResourceWarning: unclosed file <_io.BufferedReader name='C:\\Users\\kolya5544\\source\\repos\\vmdMTUCI\\mtusi2026lab5\\student-tests\\fixtures\\alpha.png'>
  return open(os.path.join(FIX, name), "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
test_content_is_409_while_not_ready_and_original_is_untouched (test_pipeline.PipelineTest.test_content_is_409_while_not_ready_and_original_is_untouched) ... ok
test_exif_orientation_is_applied (test_pipeline.PipelineTest.test_exif_orientation_is_applied) ... C:\Users\kolya5544\source\repos\vmdMTUCI\mtusi2026lab5\student-tests\test_pipeline.py:25: ResourceWarning: unclosed file <_io.BufferedReader name='C:\\Users\\kolya5544\\source\\repos\\vmdMTUCI\\mtusi2026lab5\\student-tests\\fixtures\\exif_rot6.jpg'>
  return open(os.path.join(FIX, name), "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
test_message_can_reference_attachment_before_ready_and_failed_cannot (test_pipeline.PipelineTest.test_message_can_reference_attachment_before_ready_and_failed_cannot) ... C:\Users\kolya5544\source\repos\vmdMTUCI\mtusi2026lab5\student-tests\test_pipeline.py:25: ResourceWarning: unclosed file <_io.BufferedReader name='C:\\Users\\kolya5544\\source\\repos\\vmdMTUCI\\mtusi2026lab5\\student-tests\\fixtures\\poison.png'>
  return open(os.path.join(FIX, name), "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
test_other_variants_visible_only_to_chat_members (test_pipeline.PipelineTest.test_other_variants_visible_only_to_chat_members) ... ok
test_ready_job_redelivery_does_not_duplicate_variants (test_pipeline.PipelineTest.test_ready_job_redelivery_does_not_duplicate_variants) ... ok
test_sample_png_produces_all_variants_per_contract (test_pipeline.PipelineTest.test_sample_png_produces_all_variants_per_contract) ... ok
test_small_image_is_not_upscaled_but_crop_is_128 (test_pipeline.PipelineTest.test_small_image_is_not_upscaled_but_crop_is_128) ... C:\Users\kolya5544\source\repos\vmdMTUCI\mtusi2026lab5\student-tests\test_pipeline.py:25: ResourceWarning: unclosed file <_io.BufferedReader name='C:\\Users\\kolya5544\\source\\repos\\vmdMTUCI\\mtusi2026lab5\\student-tests\\fixtures\\small.png'>
  return open(os.path.join(FIX, name), "rb").read()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
test_staging_is_cleaned_after_ready_and_kept_for_failed (test_pipeline.PipelineTest.test_staging_is_cleaned_after_ready_and_kept_for_failed) ... ok

----------------------------------------------------------------------
Ran 9 tests in 10.719s

OK
exit=0

$ python -m unittest discover -s student-tests -p test_reconcile5.py -v
test_ready_variants_and_uncommitted_side_effect_are_preserved (test_reconcile5.ReconcilePipelineTest.test_ready_variants_and_uncommitted_side_effect_are_preserved) ... ok
test_staging_is_protected_and_unowned_orphan_obeys_grace (test_reconcile5.ReconcilePipelineTest.test_staging_is_protected_and_unowned_orphan_obeys_grace) ... ok

----------------------------------------------------------------------
Ran 2 tests in 28.990s

OK
exit=0

$ python -m unittest discover -s student-tests -p test_resilience5.py -v
test_1_worker_down_upload_api_restart_worker_up (test_resilience5.ResilienceTest.test_1_worker_down_upload_api_restart_worker_up) ... ok
test_2_broker_restart_keeps_accepted_jobs (test_resilience5.ResilienceTest.test_2_broker_restart_keeps_accepted_jobs) ... ok
test_3_broker_down_during_acceptance_outbox_delivers_later (test_resilience5.ResilienceTest.test_3_broker_down_during_acceptance_outbox_delivers_later) ... ok
test_4_api_crash_between_commit_and_publish (test_resilience5.ResilienceTest.test_4_api_crash_between_commit_and_publish) ... ok
test_5_worker_crash_after_s3_before_commit_lease_recovery (test_resilience5.ResilienceTest.test_5_worker_crash_after_s3_before_commit_lease_recovery) ... ok
test_6_worker_crash_after_commit_before_ack_redelivery_is_noop (test_resilience5.ResilienceTest.test_6_worker_crash_after_commit_before_ack_redelivery_is_noop) ... ok
test_7_retry_exhaustion_registry_and_operator_replay (test_resilience5.ResilienceTest.test_7_retry_exhaustion_registry_and_operator_replay) ... ok

----------------------------------------------------------------------
Ran 7 tests in 141.784s

OK
exit=0

$ python tests/resilience.py --mode persistence --action-script scripts/restart.cmd --base-url http://127.0.0.1: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.
exit=0

$ python tests/resilience.py --mode failover --action-script scripts/stop-one.cmd --base-url http://127.0.0.1:8080
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 121, "failed_attempts": 0, "first_recovery_seconds": 2.344}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0

$ docker compose --env-file .env start api
 Container mtusi-lab5-seaweedfs-1 Waiting
 Container mtusi-lab5-postgres-1 Waiting
 Container mtusi-lab5-postgres-1 Healthy
 Container mtusi-lab5-seaweedfs-1 Healthy
 Container mtusi-lab5-migrate-1 Starting
 Container mtusi-lab5-s3-init-1 Starting
 Container mtusi-lab5-migrate-1 Started
 Container mtusi-lab5-s3-init-1 Started
 Container mtusi-lab5-migrate-1 Waiting
 Container mtusi-lab5-s3-init-1 Waiting
 Container mtusi-lab5-valkey-1 Waiting
 Container mtusi-lab5-valkey-1 Healthy
 Container mtusi-lab5-migrate-1 Exited
 Container mtusi-lab5-s3-init-1 Exited
 Container mtusi-lab5-api-1 Starting
 Container mtusi-lab5-api-1 Started
exit=0

$ python student-tests/test_expiry.py
..
----------------------------------------------------------------------
Ran 2 tests in 19.786s

OK
exit=0

$ python student-tests/test_dependencies.py
..
----------------------------------------------------------------------
Ran 2 tests in 20.171s

OK
exit=0

$ docker compose --env-file .env run --rm -T s3-init
 Container mtusi-lab5-seaweedfs-1 Running
 Container mtusi-lab5-seaweedfs-1 Waiting
 Container mtusi-lab5-seaweedfs-1 Healthy
 Container mtusi-lab5-s3-init-run-54461bd2fe34 Creating
 Container mtusi-lab5-s3-init-run-54461bd2fe34 Created
bucket messenger-attachments уже существует
анонимный доступ запрещён (HTTP 403)
ключ API ограничен одним bucket (create_bucket отклонён: AccessDenied)
bootstrap завершён
exit=0

$ docker compose --env-file .env run --rm -T s3-init
 Container mtusi-lab5-seaweedfs-1 Running
 Container mtusi-lab5-seaweedfs-1 Waiting
 Container mtusi-lab5-seaweedfs-1 Healthy
 Container mtusi-lab5-s3-init-run-84c641a11c75 Creating
 Container mtusi-lab5-s3-init-run-84c641a11c75 Created
bucket messenger-attachments уже существует
анонимный доступ запрещён (HTTP 403)
ключ API ограничен одним bucket (create_bucket отклонён: AccessDenied)
bootstrap завершён
exit=0

$ python tests/smoke.py --base-url http://127.0.0.1:8080
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
exit=0
