diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-03-13 15:03:54 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-03-13 15:06:05 +0100 |
commit | 70b5424b9987ca348a1da97cc1827e2286bbfe4b (patch) | |
tree | 0940c4c1cdf8d19a7b346aa138d3f760c785cb1a /src/garage/tests/common/garage.rs | |
parent | 2687fb7fa80f645a2e29822d60e8970433788889 (diff) | |
download | garage-70b5424b9987ca348a1da97cc1827e2286bbfe4b.tar.gz garage-70b5424b9987ca348a1da97cc1827e2286bbfe4b.zip |
use one key per context to isolate teststests/increase-robustness
Diffstat (limited to 'src/garage/tests/common/garage.rs')
-rw-r--r-- | src/garage/tests/common/garage.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/garage/tests/common/garage.rs b/src/garage/tests/common/garage.rs index d64a8310..8aaf6f5b 100644 --- a/src/garage/tests/common/garage.rs +++ b/src/garage/tests/common/garage.rs @@ -13,7 +13,7 @@ static GARAGE_TEST_SECRET: &str = #[derive(Debug, Default, Clone)] pub struct Key { - pub name: String, + pub name: Option<String>, pub id: String, pub secret: String, } @@ -21,7 +21,7 @@ pub struct Key { pub struct Instance { process: process::Child, pub path: PathBuf, - pub key: Key, + pub default_key: Key, pub s3_port: u16, pub k2v_port: u16, pub web_port: u16, @@ -102,7 +102,7 @@ api_bind_addr = "127.0.0.1:{admin_port}" Instance { process: child, path, - key: Key::default(), + default_key: Key::default(), s3_port: port, k2v_port: port + 1, web_port: port + 3, @@ -113,7 +113,7 @@ api_bind_addr = "127.0.0.1:{admin_port}" fn setup(&mut self) { self.wait_for_boot(); self.setup_layout(); - self.key = self.new_key("garage_test"); + self.default_key = self.key(Some("garage_test")); } fn wait_for_boot(&mut self) { @@ -182,14 +182,17 @@ api_bind_addr = "127.0.0.1:{admin_port}" .expect("Could not build garage endpoint URI") } - pub fn new_key(&self, name: &str) -> Key { + pub fn key(&self, maybe_name: Option<&str>) -> Key { let mut key = Key::default(); - let output = self - .command() - .args(["key", "new"]) - .args(["--name", name]) - .expect_success_output("Could not create key"); + let mut cmd = self.command(); + let base = cmd.args(["key", "new"]); + let with_name = match maybe_name { + Some(name) => base.args(["--name", name]), + None => base, + }; + + let output = with_name.expect_success_output("Could not create key"); let stdout = String::from_utf8(output.stdout).unwrap(); for line in stdout.lines() { @@ -206,7 +209,7 @@ api_bind_addr = "127.0.0.1:{admin_port}" assert!(!key.secret.is_empty(), "Invalid key: Key secret is empty"); Key { - name: name.to_owned(), + name: maybe_name.map(String::from), ..key } } |