Watch
0
0
Fork
You've already forked hyperhive
0

hive-agent: poll, do not sleep, for the positive case in the accept-limit test

This commit is contained in:
damocles 2026-11-07 09:08:04 +01:00 • committed by mara
commit fca7f669f5

View file

@ -550,12 +550,26 @@ mod tests {
let _a = UnixStream::connect(&path).await.expect("first");
let _b = UnixStream::connect(&path).await.expect("second");
let reached = |n: usize| {
let started = started.clone();
async move {
tokio::time::timeout(std::time::Duration::from_secs(5), async {
while started.load(Ordering::SeqCst) < n {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
}
})
.await
.is_ok()
}
};
assert!(reached(1).await, "first was served");
// The negative case only fails if the cap is broken, so a short wait
// is enough.
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
assert_eq!(started.load(Ordering::SeqCst), 1, "second waited its turn");
release.notify_one();
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
assert_eq!(started.load(Ordering::SeqCst), 2, "freed slot admitted it");
assert!(reached(2).await, "freed slot admitted the second");
server.abort();
}