fix: measure and verify queues at single UID granularity

This commit is contained in:
阿白叔 committed 2026-11-08 19:37:54 +08:00
1 parent e78cdd3c97
commit 4ee7b768bd
2 files changed
+58 -9

No files matched your search

+4 -5
View File
@@ -72,7 +72,7 @@ def run_scenario(output: Path, *, projects=3, sheets=2, rules=2, behavior='succe
assert item['target_scope'] == 'targets'
selected = [entry.split('\x1f') for entry in _decode_vbs_field(item['target_selectors']).split('\x1e')]
matched = [t for t in inventory if t.sheet_number == item['sheet_number'] and t.uid in {s[0] for s in selected}]
assert len(matched) == 2
assert len(selected) == len(matched) == 1
assert {(t.uid, t.refdes, t.old_value) for t in matched} == {tuple(s) for s in selected}
assert all(model[t.key] == item['old_part'] for t in matched)
state = 'saved_ok'
@@ -131,9 +131,8 @@ def run_scenario(output: Path, *, projects=3, sheets=2, rules=2, behavior='succe
assert result.paused and len(calls) == 2
stop.clear()
result = measured('queue_resume_wall', lambda: execute_task_queue(service, ids, stop_event=stop, queue_id=result.queue_id))
expected_steps = projects * sheets * rules
expected_calls = (1 if behavior == 'uncertain_stop' else
1 + (projects-1)*sheets*rules if behavior == 'failure_continue' else expected_steps)
expected_steps = projects * sheets * rules * 2
expected_calls = 1 if behavior == 'uncertain_stop' else expected_steps
assert len(calls) == expected_calls
if behavior == 'uncertain_stop':
assert result.paused and result.entries[0].state == 'blocked'
@@ -145,7 +144,7 @@ def run_scenario(output: Path, *, projects=3, sheets=2, rules=2, behavior='succe
order = [call['task_id'] for call in calls]
assert order == sorted(order, key=ids.index)
changed = sum(model[t.key] != t.old_part_number for inventory in targets.values() for t in inventory)
assert changed == sum(call['state'] == 'saved_ok' for call in calls) * 2
assert changed == sum(call['state'] == 'saved_ok' for call in calls)
assert all(model[t.key] == t.old_part_number for inventory in targets.values() for t in inventory if int(t.uid.split('-')[-1]) == 3)
for task in tasks:
events = [json.loads(line) for line in service.tail_log(task.task_id, limit=None)]