feat: ЛР3 - Nginx балансировка, идемпотентность сообщений и failover

This commit is contained in:
Ильяс
2026-10-30 12:17:01 +03:00
parent df42648939
commit 786bb2077f
27 changed files with 943 additions and 70 deletions
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+6
View File
@@ -0,0 +1,6 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi2026lab3-api-1-1 highload-messenger:lab3 "python -m uvicorn a…" api-1 46 minutes ago Up About a minute (healthy) 8080/tcp
mtusi2026lab3-api-2-1 highload-messenger:lab3 "python -m uvicorn a…" api-2 49 minutes ago Up About a minute (healthy) 8080/tcp
mtusi2026lab3-load_balancer-1 nginx:1.27-alpine "/docker-entrypoint.…" load_balancer 49 minutes ago Up About a minute (healthy) 80/tcp, 0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp
mtusi2026lab3-postgres-1 postgres:16-alpine "docker-entrypoint.s…" postgres 49 minutes ago Up About a minute (healthy) 5432/tcp
mtusi2026lab3-redis-1 redis:7-alpine "docker-entrypoint.s…" redis 49 minutes ago Up About a minute (healthy) 6379/tcp
+3
View File
@@ -0,0 +1,3 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 122, "failed_attempts": 0, "first_recovery_seconds": 0.447}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 10.0,
"elapsed_seconds": 10.065,
"concurrency": 4,
"successful_requests": 3393,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 337.112,
"successful_latency_ms": {
"p50": 6.724,
"p95": 53.145,
"p99": 79.35
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+2
View File
@@ -0,0 +1,2 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+10
View File
@@ -0,0 +1,10 @@
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
+1
View File
@@ -0,0 +1 @@
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
+38
View File
@@ -0,0 +1,38 @@
BASE_URL="http://localhost:8080" .venv/bin/pytest tests_student/ -v
============================= test session starts ==============================
platform linux -- Python 3.12.15, pytest-9.1.1, pluggy-1.7.0 -- /home/ilyas/projects/labs_highload/mtusi2026lab3/.venv/bin/python3.12
cachedir: .pytest_cache
rootdir: /home/ilyas/projects/labs_highload/mtusi2026lab3
configfile: pytest.ini
plugins: anyio-4.15.1, asyncio-1.4.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collecting ... collected 26 items
tests_student/tests.py::test_invalid_json_and_extra_fields PASSED [ 3%]
tests_student/tests.py::test_outsider_chat_access_is_404 PASSED [ 7%]
tests_student/tests.py::test_empty_and_whitespace_message PASSED [ 11%]
tests_student/tests.py::test_duplicate_username_conflict PASSED [ 15%]
tests_student/tests.py::test_wrong_password_and_bad_basic_auth PASSED [ 19%]
tests_student/tests.py::test_logout_and_revocation PASSED [ 23%]
tests_student/tests.py::test_multi_page_cursor_pagination PASSED [ 26%]
tests_student/tests.py::test_concurrency_race_condition PASSED [ 30%]
tests_student/tests.py::test_password_whitespace_rejected PASSED [ 34%]
tests_student/tests.py::test_auth_sessions_with_body_rejected PASSED [ 38%]
tests_student/tests.py::test_unsupported_media_type_415 PASSED [ 42%]
tests_student/tests.py::test_nul_byte_in_strings_handled PASSED [ 46%]
tests_student/tests.py::test_basic_auth_invalid_base64_returns_401 PASSED [ 50%]
tests_student/tests.py::test_cross_chat_cursor_rejected_400 PASSED [ 53%]
tests_student/tests.py::test_utf8_password_support PASSED [ 57%]
tests_student/tests.py::test_health_readiness_and_liveness PASSED [ 61%]
tests_student/tests.py::test_instance_id_header_present PASSED [ 65%]
tests_student/tests.py::test_idempotency_key_validation PASSED [ 69%]
tests_student/tests.py::test_idempotency_replay_and_conflict PASSED [ 73%]
tests_student/tests.py::test_idempotency_acl_check_on_replay PASSED [ 76%]
tests_student/tests.py::test_invalid_cursor_date_returns_400 PASSED [ 80%]
tests_student/tests.py::test_strict_types_and_json_parsing PASSED [ 84%]
tests_student/tests.py::test_session_create_rejects_non_empty_body PASSED [ 88%]
tests_student/tests.py::test_chat_creation_with_unknown_participant_is_400 PASSED [ 92%]
tests_student/tests.py::test_password_with_colons_and_utf8 PASSED [ 96%]
tests_student/tests.py::test_keyset_pagination_returns_next_cursor PASSED [100%]
============================= 26 passed in 28.82s ==============================
+2
View File
@@ -0,0 +1,2 @@
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.