File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
crates/turn/src/allocation/allocation_manager Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff 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]
You can’t perform that action at this time.
0 commit comments