aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-03-13 10:48:47 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-03-13 12:14:19 +0100
commit7ebed96b4449582c93b18f7497b6ac3ef21c4267 (patch)
tree304bd4a169da84b9a604d78d1d72c67e23d52a16
parent40fa1242f080ba69159607c47f46d47c30267285 (diff)
downloadgarage-test-ci-wait.tar.gz
garage-test-ci-wait.zip
do not assume Garage boots in 2sec during teststest-ci-wait
-rw-r--r--src/garage/tests/common/garage.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/garage/tests/common/garage.rs b/src/garage/tests/common/garage.rs
index 8f994f49..d64a8310 100644
--- a/src/garage/tests/common/garage.rs
+++ b/src/garage/tests/common/garage.rs
@@ -111,16 +111,29 @@ api_bind_addr = "127.0.0.1:{admin_port}"
}
fn setup(&mut self) {
- use std::{thread, time::Duration};
-
- // Wait for node to be ready
- thread::sleep(Duration::from_secs(2));
-
+ self.wait_for_boot();
self.setup_layout();
-
self.key = self.new_key("garage_test");
}
+ fn wait_for_boot(&mut self) {
+ use std::{thread, time::Duration};
+
+ // 60 * 2 seconds = 120 seconds = 2min
+ for _ in 0..60 {
+ let termination = self
+ .command()
+ .args(["status"])
+ .quiet()
+ .status()
+ .expect("Unable to run command");
+ if termination.success() {
+ break;
+ }
+ thread::sleep(Duration::from_secs(2));
+ }
+ }
+
fn setup_layout(&self) {
let node_id = self.node_id();
let node_short_id = &node_id[..64];