Merge pull request #5951 from liubin/fix/5948-check_latest_version

kata-ctl: skip test if access GitHub.com fail
This commit is contained in:
Fabiano Fidêncio 2023-01-03 18:49:57 +01:00 committed by GitHub
commit 5f5f6ce7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -1382,6 +1382,7 @@ dependencies = [
"seccompiler",
"serde",
"serde_json",
"shim-interface",
"slog",
"slog-scope",
"thiserror",
@ -2188,6 +2189,7 @@ dependencies = [
"safe-path",
"serde",
"serde_json",
"shim-interface",
]
[[package]]
@ -2717,6 +2719,7 @@ dependencies = [
"logging",
"oci",
"persist",
"shim-interface",
"slog",
"slog-scope",
"tokio",
@ -2913,6 +2916,16 @@ dependencies = [
"digest",
]
[[package]]
name = "shim-interface"
version = "0.1.0"
dependencies = [
"anyhow",
"hyper",
"hyperlocal",
"tokio",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.0"

View File

@ -126,6 +126,7 @@ fn get_kata_all_releases_by_url() -> std::result::Result<Vec<Release>, reqwest::
.header(CONTENT_TYPE, JSON_TYPE)
.header(USER_AGENT, USER_AGT)
.send()?
.error_for_status()?
.json()?;
Ok(releases)
}
@ -202,6 +203,7 @@ mod tests {
.header(CONTENT_TYPE, JSON_TYPE)
.header(USER_AGENT, USER_AGT)
.send()?
.error_for_status()?
.json::<HashMap<String, Value>>()?;
let version = content["tag_name"].as_str().unwrap();
@ -254,7 +256,17 @@ mod tests {
#[test]
fn check_latest_version() {
let version = get_kata_version_by_url(KATA_GITHUB_URL).unwrap();
let version = get_kata_version_by_url(KATA_GITHUB_URL);
// sometime in GitHub action accessing to github.com API may fail
// we can skip this test to prevent the whole test fail.
if version.is_err() {
println!(
"WARNING!!!\nget kata version failed({:?}), this maybe a temporary error, just skip the test.",
version.unwrap_err()
);
return;
}
let version = version.unwrap();
let v = Version::parse(&version).unwrap();
assert!(!v.major.to_string().is_empty());