ЛР5: асинхронная обработка вложений (RabbitMQ + worker), transactional outbox, варианты, трек 5.1

This commit is contained in:
2026-11-20 16:57:31 +03:00
parent 276dbdad8a
commit cbaadb7636
67 changed files with 5603 additions and 20 deletions
+23
View File
@@ -0,0 +1,23 @@
"""Lab3 balancing: X-Instance-Id is present and more than one replica serves."""
from __future__ import annotations
def test_instance_header_present_on_success(client, alice):
response = client.me(alice["token"])
assert response.status == 200, response.body
assert response.instance_id, "missing X-Instance-Id"
def test_instance_header_present_on_error(client):
response = client.request("GET", "/api/v1/users/me")
assert response.status == 401, response.body
assert response.instance_id, "error response missing X-Instance-Id"
def test_at_least_two_instances_seen_through_lb(client, alice):
seen = set()
for _ in range(60):
instance = client.me(alice["token"]).instance_id
if instance:
seen.add(instance)
assert len(seen) >= 2, f"expected >=2 API replicas behind the LB, saw {sorted(seen)}"