From 50a90f340887e806459aa5536eed7a1bdb99374d Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 19 Sep 2026 20:22:42 +0000 Subject: [PATCH] Skip polling delays in the external queue lifecycle test (#46714) ## Why The external queue lifecycle test waits through watcher and retry intervals, including explicit 11-second sleeps. ## What changed Run the test on Tokio's current-thread runtime and use `advance_queue_poll()` to pause time, advance it by 11 seconds, and resume it at polling boundaries. This skips interval waits while keeping the clock advancing during real I/O. GitOrigin-RevId: 0d1c3f53cc8b79559d6a20b5c9e70b58216e4b4d --- codex-rs/ext/queue/tests/queue_service.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/codex-rs/ext/queue/tests/queue_service.rs b/codex-rs/ext/queue/tests/queue_service.rs index cadd2fc7fc..9a3350ae3e 100644 --- a/codex-rs/ext/queue/tests/queue_service.rs +++ b/codex-rs/ext/queue/tests/queue_service.rs @@ -569,7 +569,14 @@ async fn registered_queue_lifecycle_starts_messages_in_fifo_order() -> anyhow::R Ok(()) } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +/// Skip a watcher/retry interval while keeping real I/O on an advancing clock. +async fn advance_queue_poll() { + tokio::time::pause(); + tokio::time::advance(Duration::from_secs(/*secs*/ 11)).await; + tokio::time::resume(); +} + +#[tokio::test] async fn externally_changed_queues_dispatch_independently_and_retry_failed_wakes() -> anyhow::Result<()> { let server = start_mock_server().await; @@ -638,6 +645,7 @@ async fn externally_changed_queues_dispatch_independently_and_retry_failed_wakes ) .await?; + advance_queue_poll().await; wait_for_event_with_timeout( independent_thread.thread.as_ref(), |event| matches!(event, EventMsg::TurnComplete(_)), @@ -647,13 +655,14 @@ async fn externally_changed_queues_dispatch_independently_and_retry_failed_wakes assert_eq!(1, model_responses.requests().len()); assert_eq!(vec![updated], queue.list(thread_id).await?); + advance_queue_poll().await; wait_for_event_with_timeout( test.codex.as_ref(), |event| matches!(event, EventMsg::TurnComplete(_)), Duration::from_secs(/*secs*/ 25), ) .await; - tokio::time::sleep(Duration::from_secs(/*secs*/ 11)).await; + advance_queue_poll().await; assert!(queue.list(thread_id).await?.is_empty()); assert!(queue.list(independent_thread.thread_id).await?.is_empty()); @@ -664,7 +673,7 @@ async fn externally_changed_queues_dispatch_independently_and_retry_failed_wakes external_queue .enqueue(thread_id, user_input("queued before ordinary resume")) .await?; - tokio::time::sleep(Duration::from_secs(/*secs*/ 11)).await; + advance_queue_poll().await; let resumed = test .thread_manager .resume_thread_from_rollout( @@ -675,6 +684,7 @@ async fn externally_changed_queues_dispatch_independently_and_retry_failed_wakes Default::default(), ) .await?; + advance_queue_poll().await; wait_for_event_with_timeout( resumed.thread.as_ref(), |event| matches!(event, EventMsg::TurnComplete(_)),