mirror of
https://github.com/lexmount/moli.git
synced 2026-11-21 08:02:59 +00:00
test(worker): await nested keepalive detachment before inspection
Joining a parent Worker intentionally does not synchronously join its nested Workers. Wait for the child to publish its pending detached keepalive before asserting its exact count, while withholding the server response. Keep the existing timeout and the zero-after-completion assertion. Validation: workspace fmt, all-target/all-feature clippy and full nextest.
This commit is contained in:
@@ -84,6 +84,15 @@ async fn assert_immediate_close_keepalive(shared: bool, post: bool, nested: bool
|
||||
let method = if post { "POST" } else { "GET" };
|
||||
assert!(request.starts_with(&format!("{method} /keepalive HTTP/1.1\r\n")));
|
||||
assert!(request.ends_with(&format!("\r\n\r\n{body}")));
|
||||
// Joining the parent does not join its nested workers. Their asynchronous
|
||||
// teardown must detach the pending load before we inspect the registry.
|
||||
timeout(TIMEOUT, async {
|
||||
while runtime.detached_keepalive_diagnostics().active_load_count == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("the closing worker must detach its pending keepalive request");
|
||||
assert_eq!(
|
||||
runtime.detached_keepalive_diagnostics().active_load_count,
|
||||
1
|
||||
|
||||
Reference in New Issue
Block a user