From e574578cfaaa4242e26be6e1c9f92994c1ae417d Mon Sep 17 00:00:00 2001 From: Hirotaka Tagawa Date: Thu, 17 Aug 2023 22:08:18 +0100 Subject: [PATCH] fix: prevent infinite loop when DynamoDbClient connection fails --- tests/util/mod.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 82114635..53570699 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -113,13 +113,23 @@ pub async fn setup_with_port(port: i32) -> Result { + println!("ListTables API succeeded."); + break; + } + Err(e) => { + println!("Couldn't connect: {} \n Retry after 3 seconds.", e); + sleep(Duration::from_secs(3)).await; + + attempts += 1; + if attempts >= max_retries { + panic!("Failed to connect after {} attempts.", max_retries); + } + } } }