Skip to content

Commit

Permalink
Add support for test_timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Jan 25, 2023
1 parent a25ab7e commit cbf84c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions interop-tests/src/bin/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -110,6 +108,10 @@ async fn main() -> Result<()> {
.unwrap_or_else(|_| "true".into())
.parse::<bool>()?;

let test_timeout = env::var("test_timeout")
.unwrap_or_else(|_| "10".into())
.parse::<usize>()?;

let redis_addr = env::var("REDIS_ADDR")
.map(|addr| format!("redis://{addr}"))
.unwrap_or_else(|_| "redis://redis:6379".into());
Expand Down Expand Up @@ -191,7 +193,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<String> = conn.blpop("listenerAddr", REDIS_TIMEOUT).await?;
let result: Vec<String> = conn.blpop("listenerAddr", test_timeout).await?;
let other = result
.get(1)
.context("Failed to wait for listener to be ready")?;
Expand Down Expand Up @@ -236,7 +238,7 @@ async fn main() -> Result<()> {
}
});

let done: Vec<String> = conn.blpop("dialerDone", REDIS_TIMEOUT).await?;
let done: Vec<String> = conn.blpop("dialerDone", test_timeout).await?;
done.get(1)
.context("Failed to wait for dialer conclusion")?;
log::info!("Ping successful");
Expand Down

0 comments on commit cbf84c4

Please sign in to comment.