diff options
Diffstat (limited to 'tvix/castore')
-rw-r--r-- | tvix/castore/Cargo.toml | 3 | ||||
-rw-r--r-- | tvix/castore/src/blobservice/grpc.rs | 28 |
2 files changed, 15 insertions, 16 deletions
diff --git a/tvix/castore/Cargo.toml b/tvix/castore/Cargo.toml index 8f96c3fbf6ad..4dab3bfa4469 100644 --- a/tvix/castore/Cargo.toml +++ b/tvix/castore/Cargo.toml @@ -34,7 +34,8 @@ tonic-build = "0.10.2" [dev-dependencies] test-case = "2.2.2" tempfile = "3.3.0" +tokio-retry = "0.3.0" [features] default = [] -tonic-reflection = ["dep:tonic-reflection"] \ No newline at end of file +tonic-reflection = ["dep:tonic-reflection"] 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 = { |