fix: explain explicit auto migration and verify probe cleanup

This commit is contained in:
2026-09-09 01:37:07 -04:00
parent a0a33c0c01
commit c710c3a7ec
3 changed files with 42 additions and 0 deletions
+24
View File
@@ -1316,3 +1316,27 @@ class TestManagedReasoningAdmission:
assert (await client._limiter_backend.source_stats(source.name)).inflight == 0
finally:
await client._transport.aclose()
async def test_managed_conflict_returns_half_open_probe_and_permit():
"""本地拒绝没有上游响应,不计故障且必须归还半开探针。"""
from tests.contracts.conftest import FakeClock
clock = FakeClock()
source = _source(
provider="openai", reasoning_effort="high", extra_body={"reasoning_effort": "high"}
)
gate = InMemoryGate(config=BreakerConfig(1, 1, 10), now=clock)
entry = await gate.try_enter(source.name, "setup")
await gate.record_failure(entry, "source_dead", True)
clock.advance(2)
client = _client(sources=[source], breaker=gate)
try:
with pytest.raises(RequestRejectedError, match="冲突"):
await client.chat([])
assert (await client._limiter_backend.source_stats(source.name)).inflight == 0
next_entry = await gate.try_enter(source.name, "next")
assert next_entry.allowed and next_entry.is_probe
await gate.release_probe(next_entry)
finally:
await client._transport.aclose()