tests/inst: Switch to rpmostree-client from git
authorColin Walters <walters@verbum.org>
Wed, 17 Feb 2021 21:59:15 +0000 (21:59 +0000)
committerColin Walters <walters@verbum.org>
Tue, 23 Feb 2021 15:20:54 +0000 (15:20 +0000)
See discussion in https://github.com/coreos/rpm-ostree/pull/2569#issuecomment-780569188
Currently pinned to a hash, but after the next stable release let's switch to tags

tests/inst/Cargo.toml
tests/inst/src/destructive.rs
tests/inst/src/insttestmain.rs
tests/inst/src/rpmostree.rs [deleted file]

index 31b43b4e7070d52301d96c66b1e2d42ca105abe5..0986c0a71d011a9a19547f153ad49a098fb578db 100644 (file)
@@ -37,6 +37,9 @@ strum_macros = "0.18.0"
 openat = "0.1.19"
 openat-ext = "0.1.4"
 nix = "0.17.0"
+# See discussion in https://github.com/coreos/rpm-ostree/pull/2569#issuecomment-780569188
+# Currently pinned to a hash, but after the next stable release let's switch to tags
+rpmostree-client = { git = "https://github.com/coreos/rpm-ostree", rev = "170095bd60ec8802afeea42d120fb2e88298648f" }
 
 # This one I might publish to crates.io, not sure yet
 with-procspawn-tempdir = { git = "https://github.com/cgwalters/with-procspawn-tempdir" }
index 42b42ebf09abe76bcd8ba5fec73639f70df7cdd9..459587e40dd134f52968de11c05148cef32d62ac 100644 (file)
@@ -31,7 +31,6 @@ use std::time;
 use strum::IntoEnumIterator;
 use strum_macros::EnumIter;
 
-use crate::rpmostree;
 use crate::test::*;
 
 const ORIGREF: &'static str = "orig-booted";
@@ -258,7 +257,7 @@ fn parse_and_validate_reboot_mark<M: AsRef<str>>(
     let mut mark: RebootMark = serde_json::from_str(markstr)
         .with_context(|| format!("Failed to parse reboot mark {:?}", markstr))?;
     // The first failed reboot may be into the original booted commit
-    let status = rpmostree::query_status()?;
+    let status = rpmostree_client::query_status().map_err(anyhow::Error::msg)?;
     let firstdeploy = &status.deployments[0];
     // The first deployment should not be staged
     assert!(!firstdeploy.staged.unwrap_or(false));
@@ -318,7 +317,7 @@ fn validate_pending_commit(pending_commit: &str, commitstates: &CommitStates) ->
 
 /// In the case where we did a kill -9 of rpm-ostree, check the state
 fn validate_live_interrupted_upgrade(commitstates: &CommitStates) -> Result<UpdateResult> {
-    let status = rpmostree::query_status()?;
+    let status = rpmostree_client::query_status().map_err(anyhow::Error::msg)?;
     let firstdeploy = &status.deployments[0];
     let pending_commit = firstdeploy.checksum.as_str();
     let res = if firstdeploy.staged.unwrap_or(false) {
@@ -488,7 +487,7 @@ fn impl_transaction_test<M: AsRef<str>>(
             } else {
                 live_strategy = Some(strategy);
             }
-            let status = rpmostree::query_status()?;
+            let status = rpmostree_client::query_status().map_err(anyhow::Error::msg)?;
             let firstdeploy = &status.deployments[0];
             let pending_commit = firstdeploy.checksum.as_str();
             validate_pending_commit(pending_commit, &commitstates)
index 3fdc1be1a8d474df7f1701848a6f7c1039ad0c42..162f510c3a8fb9df49e18717de9731dbe78442d7 100644 (file)
@@ -3,7 +3,6 @@ use structopt::StructOpt;
 
 mod destructive;
 mod repobin;
-mod rpmostree;
 mod sysroot;
 mod test;
 mod treegen;
diff --git a/tests/inst/src/rpmostree.rs b/tests/inst/src/rpmostree.rs
deleted file mode 100644 (file)
index b579c4e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-use anyhow::{Context, Result};
-use serde_derive::Deserialize;
-use std::process::Command;
-
-#[derive(Deserialize)]
-#[serde(rename_all = "kebab-case")]
-#[allow(unused)]
-pub(crate) struct Status {
-    pub(crate) deployments: Vec<Deployment>,
-}
-
-#[derive(Deserialize)]
-#[serde(rename_all = "kebab-case")]
-#[allow(unused)]
-pub(crate) struct Deployment {
-    pub(crate) unlocked: Option<String>,
-    pub(crate) osname: String,
-    pub(crate) pinned: bool,
-    pub(crate) checksum: String,
-    pub(crate) staged: Option<bool>,
-    pub(crate) booted: bool,
-    pub(crate) serial: u32,
-    pub(crate) origin: String,
-}
-
-pub(crate) fn query_status() -> Result<Status> {
-    // 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")
-}