summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-03 08:58:43 -0500
committerGitHub <noreply@github.com>2021-02-03 08:58:43 -0500
commit38ba9a66c8e4d536989a68868740cc118b4d1a86 (patch)
tree204931dfa99a306a09611d3cb63992e8c11a983a
parent9b8871cf97ffdb4e206ebd891c112dd7fc8546ce (diff)
parentbf2c23ca066b58e9c8104d83c3fa0dbeb9014103 (diff)
downloadostree-38ba9a66c8e4d536989a68868740cc118b4d1a86.tar.gz
Merge pull request #2276 from lucab/ups/tests-enhance-destructive
tests/ext/destructive: enhance test logic
-rw-r--r--tests/inst/src/destructive.rs2
-rw-r--r--tests/inst/src/rpmostree.rs35
2 files changed, 29 insertions, 8 deletions
diff --git a/tests/inst/src/destructive.rs b/tests/inst/src/destructive.rs
index d6977bff..42b42ebf 100644
--- a/tests/inst/src/destructive.rs
+++ b/tests/inst/src/destructive.rs
@@ -393,6 +393,8 @@ fn impl_transaction_test<M: AsRef<str>>(
// then we'll exit implicitly via the reboot, and reenter the function
// above.
loop {
+ // Make sure previously failed services (if any) can run.
+ bash!("systemctl reset-failed || true")?;
// Save the previous strategy as a string so we can use it in error
// messages below
let prev_strategy_str = format!("{:?}", live_strategy);
diff --git a/tests/inst/src/rpmostree.rs b/tests/inst/src/rpmostree.rs
index fee97355..b579c4e6 100644
--- a/tests/inst/src/rpmostree.rs
+++ b/tests/inst/src/rpmostree.rs
@@ -1,7 +1,6 @@
-use anyhow::Result;
+use anyhow::{Context, Result};
use serde_derive::Deserialize;
-use serde_json;
-use std::process::{Command, Stdio};
+use std::process::Command;
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
@@ -25,9 +24,29 @@ pub(crate) struct Deployment {
}
pub(crate) fn query_status() -> Result<Status> {
- let cmd = Command::new("rpm-ostree")
- .args(&["status", "--json"])
- .stdout(Stdio::piped())
- .spawn()?;
- Ok(serde_json::from_reader(cmd.stdout.unwrap())?)
+ // Retry on temporary activation failures, see
+ // https://github.com/coreos/rpm-ostree/issues/2531
+ let pause = std::time::Duration::from_secs(1);
+ let mut retries = 0;
+ let cmd_res = loop {
+ retries += 1;
+ let res = Command::new("rpm-ostree")
+ .args(&["status", "--json"])
+ .output()
+ .context("failed to spawn 'rpm-ostree status'")?;
+
+ if res.status.success() || retries >= 10 {
+ break res;
+ }
+ std::thread::sleep(pause);
+ };
+
+ if !cmd_res.status.success() {
+ anyhow::bail!(
+ "running 'rpm-ostree status' failed: {}",
+ String::from_utf8_lossy(&cmd_res.stderr)
+ );
+ }
+
+ serde_json::from_slice(&cmd_res.stdout).context("failed to parse 'rpm-ostree status' output")
}