$ BASE_URL=http://localhost:8080 poetry run pytest student-tests/test_balancing.py student-tests/test_idempotency.py student-tests/test_concurrency.py -s
/Users/enterxx/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
============================= test session starts ==============================
platform darwin -- Python 3.12.12, pytest-9.1.1, pluggy-1.6.0 -- /Users/enterxx/Library/Caches/pypoetry/virtualenvs/max2-jSniokBX-py3.12/bin/python
cachedir: .pytest_cache
rootdir: /Users/enterxx/Desktop/university/4course/mtusi2026lab3
configfile: pyproject.toml
plugins: anyio-4.15.1
collecting ... collected 21 items

student-tests/test_balancing.py::test_one_session_is_served_by_several_replicas 
INSTANCES FOR ONE SESSION: {'389b271f592b': 10, '978f2777b379': 10}
PASSED
student-tests/test_balancing.py::test_write_is_visible_through_every_replica PASSED
student-tests/test_balancing.py::test_logout_applies_to_all_replicas PASSED
student-tests/test_balancing.py::test_every_api_response_has_instance_id PASSED
student-tests/test_idempotency.py::test_replay_returns_same_message PASSED
student-tests/test_idempotency.py::test_replay_ignores_json_formatting PASSED
student-tests/test_idempotency.py::test_same_key_with_other_body_is_conflict PASSED
student-tests/test_idempotency.py::test_missing_or_invalid_key_is_rejected[headers0] PASSED
student-tests/test_idempotency.py::test_missing_or_invalid_key_is_rejected[headers1] PASSED
student-tests/test_idempotency.py::test_missing_or_invalid_key_is_rejected[headers2] PASSED
student-tests/test_idempotency.py::test_missing_or_invalid_key_is_rejected[headers3] PASSED
student-tests/test_idempotency.py::test_missing_or_invalid_key_is_rejected[headers4] PASSED
student-tests/test_idempotency.py::test_missing_or_invalid_key_is_rejected[headers5] PASSED
student-tests/test_idempotency.py::test_key_boundaries_are_accepted[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED
student-tests/test_idempotency.py::test_key_boundaries_are_accepted[Az09._:-] PASSED
student-tests/test_idempotency.py::test_key_scope_is_user_and_chat PASSED
student-tests/test_idempotency.py::test_replay_rechecks_session_and_access PASSED
student-tests/test_idempotency.py::test_expired_key_can_be_reused PASSED
student-tests/test_idempotency.py::test_parallel_replays_through_replicas_create_one_message 
PARALLEL SAME KEY: {"requests": 20, "statuses": {"201": 20}, "instances": {"389b271f592b": 10, "978f2777b379": 10}, "distinct_bodies": 1, "messages_in_history": 1, "rows_in_db": 1}
PASSED
student-tests/test_idempotency.py::test_parallel_same_key_with_different_bodies PASSED
student-tests/test_concurrency.py::test_parallel_messages_are_not_lost_or_duplicated 
CONCURRENCY RESULT: {"clients": 10, "messages_sent": 100, "status_201": 100, "messages_read": 100, "unique_ids": 100, "unique_texts": 100, "pages_read": 4, "send_seconds": 0.227}
PASSED

============================== 21 passed in 3.79s ==============================
$ docker compose logs --no-log-prefix nginx | grep "\"uri\":\"/api/v1/users/me\",\"status\":200" | tail -6
{"time":"2026-10-19T17:01:21+00:00","request_id":"d754e7abc1b3b0e09ab4bf0d9fd50270","method":"GET","uri":"/api/v1/users/me","status":200,"request_time":0.001,"upstream_addr":"192.168.48.3:8080","upstream_status":"200","upstream_response_time":"0.002","instance":"389b271f592b"}
{"time":"2026-10-19T17:01:21+00:00","request_id":"aeaf60de5c114ed306169370ede170b6","method":"GET","uri":"/api/v1/users/me","status":200,"request_time":0.002,"upstream_addr":"192.168.48.2:8080","upstream_status":"200","upstream_response_time":"0.001","instance":"978f2777b379"}
{"time":"2026-10-19T17:01:21+00:00","request_id":"7caafb063b53d8985d17356cd62d812d","method":"GET","uri":"/api/v1/users/me","status":200,"request_time":0.002,"upstream_addr":"192.168.48.3:8080","upstream_status":"200","upstream_response_time":"0.001","instance":"389b271f592b"}
{"time":"2026-10-19T17:01:21+00:00","request_id":"a8e4fb898cd5ff5e56bdd1669067a60f","method":"GET","uri":"/api/v1/users/me","status":200,"request_time":0.001,"upstream_addr":"192.168.48.2:8080","upstream_status":"200","upstream_response_time":"0.001","instance":"978f2777b379"}
{"time":"2026-10-19T17:01:21+00:00","request_id":"fb8e6ba34f06d739933b9872b9aadd89","method":"GET","uri":"/api/v1/users/me","status":200,"request_time":0.001,"upstream_addr":"192.168.48.3:8080","upstream_status":"200","upstream_response_time":"0.000","instance":"389b271f592b"}
{"time":"2026-10-19T17:01:21+00:00","request_id":"e166ba8766667300b8bcc65996ab6827","method":"GET","uri":"/api/v1/users/me","status":200,"request_time":0.001,"upstream_addr":"192.168.48.2:8080","upstream_status":"200","upstream_response_time":"0.001","instance":"978f2777b379"}
$ rid=$(docker compose logs --no-log-prefix nginx | grep "\"uri\":\"/api/v1/users/me\",\"status\":200" | tail -1 | sed -E "s/.*\"request_id\":\"([0-9a-f]+)\".*/\1/"); echo "request_id=$rid"; docker compose logs api | grep "$rid"
request_id=e166ba8766667300b8bcc65996ab6827
api-1  | 2026-10-19 17:01:21.285 | INFO     | application.api.middlewares.request_context:_log_request:70 - GET /api/v1/users/me -> 200 | 0.6 ms | request_id=e166ba8766667300b8bcc65996ab6827
