refactor
This commit is contained in:
@@ -82,59 +82,6 @@ async def test_hedge_schwelle_skaliert_mit_timeout(monkeypatch):
|
||||
assert calls == ["k1"]
|
||||
|
||||
|
||||
async def test_late_fold_nachzuegler_zaehlt_nach(monkeypatch):
|
||||
"""Quorum 2 kehrt sofort zurück; der dritte Slot wird nicht gekillt, sein Ergebnis
|
||||
geht an `late` (ersetzt den grace-Timer der Finder-Runden)."""
|
||||
import time
|
||||
killed, spaet = [], []
|
||||
|
||||
async def fake_agent(key, prompt, timeout, **kw):
|
||||
if key == "k3":
|
||||
await asyncio.sleep(0.2)
|
||||
return (0, "dritter", "")
|
||||
return (0, key, "")
|
||||
|
||||
async def late(val):
|
||||
spaet.append(val)
|
||||
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "kill_process", lambda k: killed.append(k))
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0)
|
||||
slots = [{"key": f"k{i}", "prompt": "p", "role": "quick", "capabilities": "none",
|
||||
"payload": lambda r: r[1]} for i in (1, 2, 3)]
|
||||
t0 = time.monotonic()
|
||||
res = await pipeline._race("t", "Test", slots, 2, 60, "claude", late=late)
|
||||
assert time.monotonic() - t0 < 0.15 # kein Warten auf k3
|
||||
assert sorted(res) == ["k1", "k2"]
|
||||
assert "k3" not in killed
|
||||
await asyncio.sleep(0.3)
|
||||
assert spaet == ["dritter"]
|
||||
|
||||
|
||||
async def test_late_fold_invalider_nachzuegler_ignoriert(monkeypatch):
|
||||
"""Nachzügler mit invalidem Payload löst late NICHT aus (best-effort)."""
|
||||
spaet = []
|
||||
|
||||
async def fake_agent(key, prompt, timeout, **kw):
|
||||
if key == "k3":
|
||||
await asyncio.sleep(0.1)
|
||||
return (1, "", "kaputt")
|
||||
return (0, key, "")
|
||||
|
||||
async def late(val):
|
||||
spaet.append(val)
|
||||
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "kill_process", lambda k: None)
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0)
|
||||
slots = [{"key": f"k{i}", "prompt": "p", "role": "quick", "capabilities": "none",
|
||||
"payload": lambda r: r[1]} for i in (1, 2, 3)]
|
||||
res = await pipeline._race("t", "Test", slots, 2, 60, "claude", late=late)
|
||||
assert res is not None
|
||||
await asyncio.sleep(0.25)
|
||||
assert spaet == []
|
||||
|
||||
|
||||
async def test_hedge_zwilling_ersetzt_restart(monkeypatch):
|
||||
"""Scheitert das Original, während der Zwilling noch läuft, gibt es KEINEN
|
||||
zusätzlichen Restart — der Zwilling ist der Retry."""
|
||||
|
||||
Reference in New Issue
Block a user