ЛР 3: балансировка, общая идемпотентность и исследование масштабирования

This commit is contained in:
Quzzqq
2026-11-06 16:47:34 +03:00
parent 0ab3a341aa
commit a14b013307
387 changed files with 350577 additions and 38 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""Small defense demonstration; outputs aliases and synthetic data, no credentials."""
import json
from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, check
c = Client()
alice, bob, _, chat = c.bootstrap()
instances = sorted({c.call('GET', '/api/v1/users/me', actor=alice, schema='User')['headers']['X-Instance-Id']
for _ in range(20)})
check(len(instances) >= 2, 'Expected >=2 replicas with the SAME session')
message = c.message(alice, chat, 'Одно сообщение через общий LB')['json']
page = c.call('GET', '/api/v1/chats/' + chat['id'] + '/messages', actor=bob, schema='MessagePage')['json']
check(message in page['items'], 'Message not visible to another member')
print(json.dumps({'same_session_served_by': instances, 'message': message,
'visible_to_second_member': True}, ensure_ascii=False, indent=2))