summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXiaohan Ni <91544758+phanen@users.noreply.github.com>2024-01-07 05:49:27 +0800
committerGitHub <noreply@github.com>2024-01-06 22:49:27 +0100
commitef7b77355719bb3fc7c3bd3056b7c3d1fb4b8a25 (patch)
tree0da4fa6e1db704ccb73b0a55fdfa61d62e3353c5 /src
parent2bb57cf0cd6d53194d26f4be96dff5fa14942622 (diff)
test(aws): fix flaky tests `expiration_date_set` `expiration_date_set_from_file` (#5685)
* fix(aws): fix flaky test `expiration_date_set` * fix(aws): fix flaky test `expiration_date_set_from_file`
Diffstat (limited to 'src')
-rw-r--r--src/modules/aws.rs87
1 files changed, 40 insertions, 47 deletions
diff --git a/src/modules/aws.rs b/src/modules/aws.rs
index 0a5a0176e..fa455862f 100644
--- a/src/modules/aws.rs
+++ b/src/modules/aws.rs
@@ -703,14 +703,21 @@ credential_process = /opt/bin/awscreds-retriever
now_plus_half_hour.to_rfc3339_opts(SecondsFormat::Secs, true),
)
.collect();
- let expected = Some(format!(
- "on {}",
- Color::Yellow
- .bold()
- .paint("☁️ astronauts (ap-northeast-2) [30m] ")
- ));
-
- assert_eq!(expected, actual);
+
+ let possible_values = [
+ "30m2s", "30m1s", "30m", "29m59s", "29m58s", "29m57s", "29m56s", "29m55s",
+ ];
+ let possible_values = possible_values.map(|duration| {
+ let segment_colored = format!("☁️ astronauts (ap-northeast-2) [{duration}] ");
+ Some(format!(
+ "on {}",
+ Color::Yellow.bold().paint(segment_colored)
+ ))
+ });
+ assert!(
+ possible_values.contains(&actual),
+ "time is not in range: {actual:?}"
+ );
});
}
@@ -743,46 +750,32 @@ aws_secret_access_key=dummy
)
.unwrap();
- let actual = ModuleRenderer::new("aws")
- .env("AWS_PROFILE", "astronauts")
- .env("AWS_REGION", "ap-northeast-2")
- .env(
- "AWS_SHARED_CREDENTIALS_FILE",
- credentials_path.to_string_lossy().as_ref(),
- )
- .collect();
-
- let actual_variant = ModuleRenderer::new("aws")
- .env("AWS_PROFILE", "astronauts")
- .env("AWS_REGION", "ap-northeast-2")
- .env(
- "AWS_CREDENTIALS_FILE",
- credentials_path.to_string_lossy().as_ref(),
- )
- .collect();
-
- assert_eq!(
- actual, actual_variant,
- "both AWS_SHARED_CREDENTIALS_FILE and AWS_CREDENTIALS_FILE should work"
- );
-
- // In principle, "30m" should be correct. However, bad luck in scheduling
- // on shared runners may delay it.
- let possible_values = [
- "30m2s", "30m1s", "30m", "29m59s", "29m58s", "29m57s", "29m56s", "29m55s",
- ];
- let possible_values = possible_values.map(|duration| {
- let segment_colored = format!("☁️ astronauts (ap-northeast-2) [{duration}] ");
- Some(format!(
- "on {}",
- Color::Yellow.bold().paint(segment_colored)
- ))
+ let credentials_env_vars = ["AWS_SHARED_CREDENTIALS_FILE", "AWS_CREDENTIALS_FILE"];
+ credentials_env_vars.iter().for_each(|env_var| {
+ let actual = ModuleRenderer::new("aws")
+ .env("AWS_PROFILE", "astronauts")
+ .env("AWS_REGION", "ap-northeast-2")
+ .env(env_var, credentials_path.to_string_lossy().as_ref())
+ .collect();
+
+ // In principle, "30m" should be correct. However, bad luck in scheduling
+ // on shared runners may delay it.
+ let possible_values = [
+ "30m2s", "30m1s", "30m", "29m59s", "29m58s", "29m57s", "29m56s", "29m55s",
+ ];
+ let possible_values = possible_values.map(|duration| {
+ let segment_colored = format!("☁️ astronauts (ap-northeast-2) [{duration}] ");
+ Some(format!(
+ "on {}",
+ Color::Yellow.bold().paint(segment_colored)
+ ))
+ });
+
+ assert!(
+ possible_values.contains(&actual),
+ "time is not in range: {actual:?}"
+ );
});
-
- assert!(
- possible_values.contains(&actual),
- "time is not in range: {actual:?}"
- );
});
dir.close()