From 421e37896ac08b4d463c75f8f7616d86f1192ce3 Mon Sep 17 00:00:00 2001 From: Zyy Date: Mon, 26 Oct 2026 15:42:32 +0800 Subject: [PATCH] fix(tests): avoid RPC admission callback deadlock Drive the ordinary callback call to completion before consuming its notification so delayed suspension cannot strand an unpolled admission future. Bound next callback startup and resumption waits. Co-authored-by: Codex --- .../runtime/tests/rpc/admission.rs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/crates/gateway-plugin/runtime/tests/rpc/admission.rs b/backend/crates/gateway-plugin/runtime/tests/rpc/admission.rs index 4b682a528..0f7dfba88 100644 --- a/backend/crates/gateway-plugin/runtime/tests/rpc/admission.rs +++ b/backend/crates/gateway-plugin/runtime/tests/rpc/admission.rs @@ -145,12 +145,13 @@ async fn next_resumption_does_not_need_a_vacant_initial_queue_slot() { .await } }); - started.recv().await.unwrap(); - // 未消费的 next 与普通回调共享有界驻留额度 - let mut occupying = Box::pin(call(&session, "callback")); - assert!(futures::poll!(&mut occupying).is_pending()); - started.recv().await.unwrap(); - occupying.await.unwrap(); + tokio::time::timeout(Duration::from_secs(2), started.recv()) + .await + .expect("next callback should start") + .unwrap(); + // 回调通知可能先于 Suspend 到达,持续驱动普通调用才能在名额释放后完成 + call(&session, "callback").await.unwrap(); + started.try_recv().unwrap(); let mut active = Box::pin(call(&session, "hang")); assert!(futures::poll!(&mut active).is_pending()); let mut queued = Box::pin(call(&session, "echo")); @@ -165,7 +166,13 @@ async fn next_resumption_does_not_need_a_vacant_initial_queue_slot() { assert!(!waiting.is_finished()); drop(active); assert!(queued.await.is_ok()); - assert!(waiting.await.unwrap().is_ok()); + assert!( + tokio::time::timeout(Duration::from_secs(2), waiting) + .await + .expect("next call should resume after execution capacity is released") + .unwrap() + .is_ok() + ); assert!(session.is_ready()); session.shutdown(Duration::from_secs(1)).await; }