Skip to content

Commit 7227a2d

Browse files
committed
Retry allocation timeout test
1 parent 8aaa8e8 commit 7227a2d

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

crates/turn/src/allocation/allocation_manager/allocation_manager_test.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,30 @@ async fn test_allocation_timeout() -> Result<()> {
237237
allocations.push(a);
238238
}
239239

240-
tokio::time::sleep(lifetime + Duration::from_millis(100)).await;
240+
let mut count = 0;
241241

242-
for allocation in allocations {
243-
let mut a = allocation.lock().await;
244-
assert!(
245-
a.close().await.is_err(),
246-
"Allocation should be closed if lifetime timeout"
247-
);
248-
}
242+
'outer: loop {
243+
count += 1;
249244

250-
Ok(())
245+
if count >= 10 {
246+
assert!(false, "Allocations didn't timeout");
247+
}
248+
249+
tokio::time::sleep(lifetime + Duration::from_millis(100)).await;
250+
251+
let any_outstanding = false;
252+
253+
for allocation in &allocations {
254+
let mut a = allocation.lock().await;
255+
if !a.close().await.is_err() {
256+
continue 'outer;
257+
}
258+
}
259+
260+
if !any_outstanding {
261+
return Ok(());
262+
}
263+
}
251264
}
252265

253266
#[tokio::test]

0 commit comments

Comments
 (0)