Skip to content

Commit

Permalink
fix(tests): re-attempt connection to NATS
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Adossi <[email protected]>
  • Loading branch information
vados-cosmonic committed Oct 4, 2024
1 parent 22dd2c0 commit d4df73e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,18 @@ impl ClientInfo {
.kill_on_drop(true)
.spawn()
.expect("Unable to watch docker logs");

// Connect to NATS
let client = async_nats::connect("127.0.0.1:4222")
.await
.expect("Unable to connect to nats");
let client = tokio::time::timeout(Duration::from_secs(3), async {
loop {
if let Ok(client) = async_nats::connect("127.0.0.1:4222").await {
return client;
}
tokio::time::sleep(Duration::from_millis(250)).await;
}
})
.await
.expect("timed out while creating NATS client");

ClientInfo {
client,
Expand Down

0 comments on commit d4df73e

Please sign in to comment.