From 359dff85fe6e9b4eaa623dae78422b7c5c1c60ae Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Tue, 24 Jan 2023 12:38:11 -0800 Subject: [PATCH] Add support for test_timeout option --- test-plans/src/bin/ping.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test-plans/src/bin/ping.rs b/test-plans/src/bin/ping.rs index b41b80da4ff0..ea9f4701d50b 100644 --- a/test-plans/src/bin/ping.rs +++ b/test-plans/src/bin/ping.rs @@ -16,8 +16,6 @@ use libp2p::{ use redis::AsyncCommands; use strum::EnumString; -const REDIS_TIMEOUT: usize = 10; - /// Supported transports by rust-libp2p. #[derive(Clone, Debug, EnumString)] #[strum(serialize_all = "kebab-case")] @@ -110,6 +108,10 @@ async fn main() -> Result<()> { .unwrap_or_else(|_| "true".into()) .parse::()?; + let test_timeout = env::var("test_timeout") + .unwrap_or_else(|_| "10".into()) + .parse::()?; + let redis_addr = env::var("REDIS_ADDR") .map(|addr| format!("redis://{addr}")) .unwrap_or_else(|_| "redis://redis:6379".into()); @@ -189,7 +191,7 @@ async fn main() -> Result<()> { // retrieved via `listenAddr` key over the redis connection. Or wait to be pinged and have // `dialerDone` key ready on the redis connection. if is_dialer { - let result: Vec = conn.blpop("listenerAddr", REDIS_TIMEOUT).await?; + let result: Vec = conn.blpop("listenerAddr", test_timeout).await?; let other = result .get(1) .context("Failed to wait for listener to be ready")?; @@ -234,7 +236,7 @@ async fn main() -> Result<()> { } }); - let done: Vec = conn.blpop("dialerDone", REDIS_TIMEOUT).await?; + let done: Vec = conn.blpop("dialerDone", test_timeout).await?; done.get(1) .context("Failed to wait for dialer conclusion")?; log::info!("Ping successful");