fix(work): show client idle timeout as red result-unknown card
This commit is contained in:
@@ -153,6 +153,42 @@ async def test_timeout_projects_unknown_without_claiming_failure(env,monkeypatch
|
||||
assert '状态待核对' in text and '执行失败' not in text
|
||||
|
||||
|
||||
async def test_lost_client_turns_red_persists_and_recovers_on_authenticated_progress(env,monkeypatch):
|
||||
task(env);cards,calls,clock=setup_cards(env,monkeypatch)
|
||||
api=env['app'].state.deliveries;api.cards=cards
|
||||
await report(env,'running',1);await cards.flush()
|
||||
cards.mark_connection_lost('task-durable')
|
||||
with env['store'].db:env['store'].db.execute("UPDATE work_tasks_v2 SET status='unknown'")
|
||||
clock[0]+=6;await cards.flush()
|
||||
card=calls[-1][2]
|
||||
assert card['header']['template']=='red'
|
||||
text=json.dumps(card,ensure_ascii=False)
|
||||
assert '客户端失联,任务结果待核对' in text and '执行失败' not in text
|
||||
reopened=TaskCards(env['store'].lifecycle,env['platform'],'worker-new',clock=lambda:clock[0])
|
||||
assert reopened.snapshot(env['store'].lifecycle.task('task-durable'))['header']['template']=='red'
|
||||
await report(env,'completed',2);clock[0]+=6;await cards.flush()
|
||||
assert calls[-1][2]['header']['template']=='green'
|
||||
assert not env['store'].db.execute('SELECT * FROM work_task_connection_v3').fetchall()
|
||||
|
||||
|
||||
async def test_idle_timeout_is_distinct_from_hard_tracking_limit():
|
||||
from types import SimpleNamespace
|
||||
from relay.connector import Broker,Pending,ClientIdleTimeout
|
||||
broker=object.__new__(Broker)
|
||||
broker.s=SimpleNamespace(request_timeout=.01,task_tracking_timeout=1)
|
||||
item=Pending(asyncio.get_running_loop().create_future(),None,None,'synthetic','synthetic')
|
||||
with pytest.raises(ClientIdleTimeout):await broker.wait_tracked(item)
|
||||
broker.s.task_tracking_timeout=0
|
||||
with pytest.raises(asyncio.TimeoutError)as error:await broker.wait_tracked(item)
|
||||
assert not isinstance(error.value,ClientIdleTimeout)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('state',['completed','failed','cancelled','interrupted'])
|
||||
def test_lost_connection_never_overwrites_known_terminal_state(state):
|
||||
card=card_content('synthetic',state,None,connection_lost=True)
|
||||
assert '客户端失联' not in json.dumps(card,ensure_ascii=False)
|
||||
|
||||
|
||||
async def test_platform_card_wire_format_and_receipt_validation(env):
|
||||
seen=[]
|
||||
def handler(request):
|
||||
|
||||
Reference in New Issue
Block a user