ci: Fix aws::expiration_date_set_from_file race (#3484)

* ci: Fix aws::expiration_date_set_from_file race

While aws::expiration_date_set_from_file will almost-always work
perfectly locally, it is theoretically possible for the thread running
the test to be scheduled away betwen writing the file with timing
information and then actually reading it, resulting in a
shorter-than-expected time appearing in the module. This can also happen
if the test triggers right at the very end of a second (e.g. at
10:45:47.999995).

This appears to actually happen sometimes on heavily-loaded GitHub
Actions runners. To fix this issue, we allow for up to a two-second
delay between when the file is written and when the test actually fires
(allowing "30m", "29m59s", and "29m58s" as possible values).

* Fix typo
This commit is contained in:
Kevin Song 2022-01-22 05:54:04 -06:00 committed by GitHub
parent 31ab8aa0c5
commit 08b5ad94fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -554,14 +554,19 @@ expiration={}
credentials_path.to_string_lossy().as_ref(),
)
.collect();
let expected = Some(format!(
"on {}",
Color::Yellow
.bold()
.paint("☁️ astronauts (ap-northeast-2) [30m]")
));
assert_eq!(expected, actual);
// In principle, "30m" should be correct. However, bad luck in scheduling
// on shared runners may delay it. Allow for up to 2 seconds of delay.
let possible_values = ["30m", "29m59s", "29m58s"];
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));
dir.close()
}