about summary refs log tree commit diff
path: root/tvix/castore/src/blobservice/grpc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/castore/src/blobservice/grpc.rs')
-rw-r--r--tvix/castore/src/blobservice/grpc.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/tvix/castore/src/blobservice/grpc.rs b/tvix/castore/src/blobservice/grpc.rs
index b0544387bb0a..115efa5f09c6 100644
--- a/tvix/castore/src/blobservice/grpc.rs
+++ b/tvix/castore/src/blobservice/grpc.rs
@@ -281,10 +281,12 @@ impl<W: tokio::io::AsyncWrite + Unpin> tokio::io::AsyncWrite for GRPCBlobWriter<
 #[cfg(test)]
 mod tests {
     use std::sync::Arc;
+    use std::time::Duration;
 
     use tempfile::TempDir;
     use tokio::net::UnixListener;
-    use tokio::time;
+    use tokio_retry::strategy::ExponentialBackoff;
+    use tokio_retry::Retry;
     use tokio_stream::wrappers::UnixListenerStream;
 
     use crate::blobservice::MemoryBlobService;
@@ -374,22 +376,18 @@ mod tests {
         });
 
         // wait for the socket to be created
-        {
-            let mut socket_created = false;
-            // TODO: exponential backoff urgently
-            for _try in 1..20 {
+        Retry::spawn(
+            ExponentialBackoff::from_millis(20).max_delay(Duration::from_secs(10)),
+            || async {
                 if socket_path.exists() {
-                    socket_created = true;
-                    break;
+                    Ok(())
+                } else {
+                    Err(())
                 }
-                tokio::time::sleep(time::Duration::from_millis(20)).await;
-            }
-
-            assert!(
-                socket_created,
-                "expected socket path to eventually get created, but never happened"
-            );
-        }
+            },
+        )
+        .await
+        .expect("failed to wait for socket");
 
         // prepare a client
         let grpc_client = {