mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:04:41 +00:00
test(tui): fix flaky notification-requeue test — assert contract, not queue order (#65506)
test_run_prompt_submit_requeues_all_unstarted_notifications_with_real_threading asserted strict FIFO order of the requeued events. The completion_queue is process-global, and notification pollers leaked by earlier session.init tests in the same file legitimately steal-and-requeue foreign-session events (_notification_poller_loop's belongs-elsewhere branch), rotating the queue — CI slice 6/8 saw [batch_3, batch_2] and failed on ordering alone. Assert the actual requeue contract instead: batch_1 is consumed while batch_2 and batch_3 both remain queued — membership via a deadline drain (an event can be transiently held by a poller mid-cycle), not order. Verified: single test 10/10 green, full file 337/337 across 3 consecutive CI-parity runs.
This commit is contained in:
parent
94136efcca
commit
b9858acb0c
1 changed files with 18 additions and 5 deletions
|
|
@ -2765,13 +2765,26 @@ def test_run_prompt_submit_requeues_all_unstarted_notifications_with_real_thread
|
|||
assert nested_started.wait(timeout=5)
|
||||
threads[0].join(timeout=5)
|
||||
assert not threads[0].is_alive()
|
||||
queued = []
|
||||
while not isolated_queue.empty():
|
||||
queued.append(isolated_queue.get_nowait())
|
||||
assert [event["session_id"] for event in queued] == [
|
||||
# Membership, not order: the completion_queue is process-global, and
|
||||
# notification pollers leaked by earlier session.init tests in this
|
||||
# file legitimately steal-and-requeue foreign-session events (see
|
||||
# _notification_poller_loop's belongs-elsewhere branch), rotating the
|
||||
# queue. The requeue contract is that batch_2 and batch_3 both remain
|
||||
# queued (never consumed) while batch_1's turn is in flight — so drain
|
||||
# with a deadline (an event may be transiently held by a poller
|
||||
# mid-cycle) and assert exactly {batch_2, batch_3} come back.
|
||||
queued: dict = {}
|
||||
deadline = time.time() + 5.0
|
||||
while time.time() < deadline and set(queued) != {
|
||||
"proc_batch_2",
|
||||
"proc_batch_3",
|
||||
]
|
||||
}:
|
||||
try:
|
||||
evt = isolated_queue.get(timeout=0.1)
|
||||
except _queue_mod.Empty:
|
||||
continue
|
||||
queued[evt["session_id"]] = evt
|
||||
assert set(queued) == {"proc_batch_2", "proc_batch_3"}
|
||||
finally:
|
||||
release_nested.set()
|
||||
for thread in threads:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue