test: measure aged reconciliation scans and cross-replica retries

This commit is contained in:
2026-11-06 18:10:55 +03:00
parent 14c659fda4
commit 9d9d425205
5 changed files with 87 additions and 2 deletions
+30
View File
@@ -213,3 +213,33 @@ def test_internal_jpeg_bytesio_fallback():
stream = BytesIO(image_bytes("JPEG"))
assert validate_image(stream, "image/jpeg") == ("image/jpeg", 32, 20)
assert stream.tell() == 0
def test_parallel_same_key_across_replicas(scenario):
import threading
from concurrent.futures import ThreadPoolExecutor
c, alice, _, _, chat = scenario
key = uuid.uuid4().hex
barrier = threading.Barrier(10)
path = f"/api/v1/chats/{chat['id']}/messages"
body = {"text": "concurrent idempotent message"}
def send(_):
barrier.wait()
return Client(c.base).call(
"POST",
path,
201,
actor=alice,
body=body,
headers={"Idempotency-Key": key},
schema="Message",
)
with ThreadPoolExecutor(max_workers=10) as pool:
responses = list(pool.map(send, range(10)))
assert len({r["json"]["id"] for r in responses}) == 1
assert len({r["headers"]["X-Instance-Id"] for r in responses}) >= 2
history = c.call("GET", path, actor=alice, schema="MessagePage")["json"]["items"]
assert sum(m["id"] == responses[0]["json"]["id"] for m in history) == 1