Merge pull request 'feat: CI timing gate flakes under runner load' (#1292) from timmy/1289-ci-timing-gate-flakes-under-runner-load into main
All checks were successful
CI / lint (push) Successful in 4m4s
CI / build-release (push) Successful in 8s
CI / browser-journey (push) Successful in 7m13s
CI / release-candidate (push) Successful in 10s

This commit is contained in:
timmy 2026-08-23 02:45:12 +00:00
commit 4b4e55dbe2

View File

@ -419,11 +419,12 @@ async def test_slow_ledger_completion_does_not_block_health_requests(monkeypatch
return {"id": 249, "body": body}
started = threading.Event()
release = threading.Event()
original_complete = main._idempotency_ledger.complete
def slow_complete(key, response):
started.set()
time.sleep(0.2)
assert release.wait(1)
return original_complete(key, response)
monkeypatch.setattr(main._idempotency_ledger, "complete", slow_complete)
@ -432,15 +433,16 @@ async def test_slow_ledger_completion_does_not_block_health_requests(monkeypatch
transport = httpx.ASGITransport(app=main.app)
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
started_at = asyncio.get_running_loop().time()
authored = asyncio.create_task(client.post(
"/api/v1/repos/stackchain/api/issues/248/comments",
json={"body": "Persist without freezing"},
headers={"Idempotency-Key": "slow-completion-248"},
))
assert await asyncio.to_thread(started.wait, 1)
started_at = asyncio.get_running_loop().time()
health = await client.get("/healthz")
health_elapsed = asyncio.get_running_loop().time() - started_at
release.set()
authored_response = await authored
assert health.status_code == 200