Merge pull request #2324 from cgwalters/test-use-ex
Various patches for tests/inst
This commit is contained in:
commit
9154f41fd4
|
|
@ -19,14 +19,14 @@ anyhow = "1.0"
|
|||
tempfile = "3.1.0"
|
||||
glib = "0.10"
|
||||
gio = "0.9"
|
||||
ostree = { version = "0.8.0", features = ["v2020_1"] }
|
||||
ostree = { version = "0.10.0", features = ["v2021_1"] }
|
||||
libtest-mimic = "0.3.0"
|
||||
twoway = "0.2.1"
|
||||
hyper = "0.13"
|
||||
hyper = { version = "0.14", features = ["runtime", "http1", "http2", "tcp", "server"] }
|
||||
hyper-staticfile = "0.6.0"
|
||||
futures = "0.3.4"
|
||||
http = "0.2.0"
|
||||
hyper-staticfile = "0.5.1"
|
||||
tokio = { version = "0.2", features = ["full"] }
|
||||
tokio = { version = "1.4.0", features = ["full"] }
|
||||
futures-util = "0.3.1"
|
||||
base64 = "0.12.0"
|
||||
procspawn = "0.8"
|
||||
|
|
@ -36,17 +36,12 @@ strum = "0.18.0"
|
|||
strum_macros = "0.18.0"
|
||||
openat = "0.1.19"
|
||||
openat-ext = "0.1.4"
|
||||
nix = "0.17.0"
|
||||
nix = "0.20.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" }
|
||||
rpmostree-client = { git = "https://github.com/coreos/rpm-ostree", tag = "v2021.3" }
|
||||
|
||||
# This one I might publish to crates.io, not sure yet
|
||||
with-procspawn-tempdir = { git = "https://github.com/cgwalters/with-procspawn-tempdir" }
|
||||
|
||||
# Internal crate for the test macro
|
||||
itest-macro = { path = "itest-macro" }
|
||||
|
||||
[patch.crates-io]
|
||||
# PR openat (pun intended) https://github.com/tailhook/openat/pull/36
|
||||
openat = { git = 'https://github.com/cgwalters/openat', branch = 'libc-rename-signed' }
|
||||
|
|
|
|||
|
|
@ -208,12 +208,13 @@ fn upgrade_and_finalize() -> Result<()> {
|
|||
|
||||
async fn run_upgrade_or_timeout(timeout: time::Duration) -> Result<bool> {
|
||||
let upgrade = tokio::task::spawn_blocking(upgrade_and_finalize);
|
||||
tokio::pin!(upgrade);
|
||||
Ok(tokio::select! {
|
||||
res = upgrade => {
|
||||
let _res = res?;
|
||||
true
|
||||
},
|
||||
_ = tokio::time::delay_for(timeout) => {
|
||||
_ = tokio::time::sleep(timeout) => {
|
||||
false
|
||||
}
|
||||
})
|
||||
|
|
@ -244,6 +245,11 @@ impl CommitStates {
|
|||
}
|
||||
}
|
||||
|
||||
fn query_status() -> Result<rpmostree_client::Status> {
|
||||
let client = rpmostree_client::CliClient::new("ostreetest");
|
||||
rpmostree_client::query_status(&client).map_err(anyhow::Error::msg)
|
||||
}
|
||||
|
||||
/// In the case where we've entered via a reboot, this function
|
||||
/// checks the state of things, and also generates a new update
|
||||
/// if everything was successful.
|
||||
|
|
@ -255,7 +261,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_client::query_status().map_err(anyhow::Error::msg)?;
|
||||
let status = query_status()?;
|
||||
let firstdeploy = &status.deployments[0];
|
||||
// The first deployment should not be staged
|
||||
assert!(!firstdeploy.staged.unwrap_or(false));
|
||||
|
|
@ -279,7 +285,7 @@ fn parse_and_validate_reboot_mark<M: AsRef<str>>(
|
|||
// Update the target state
|
||||
let srvrepo_obj = ostree::Repo::new(&gio::File::new_for_path(SRVREPO));
|
||||
srvrepo_obj.open(gio::NONE_CANCELLABLE)?;
|
||||
commitstates.target = srvrepo_obj.resolve_rev(TESTREF, false)?.into();
|
||||
commitstates.target = srvrepo_obj.resolve_rev(TESTREF, false)?.unwrap().into();
|
||||
} else if commitstates.booted == commitstates.orig || commitstates.booted == commitstates.prev {
|
||||
println!(
|
||||
"Failed update to {} (booted={})",
|
||||
|
|
@ -315,7 +321,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_client::query_status().map_err(anyhow::Error::msg)?;
|
||||
let status = query_status()?;
|
||||
let firstdeploy = &status.deployments[0];
|
||||
let pending_commit = firstdeploy.checksum.as_str();
|
||||
let res = if firstdeploy.staged.unwrap_or(false) {
|
||||
|
|
@ -353,11 +359,12 @@ fn impl_transaction_test<M: AsRef<str>>(
|
|||
|
||||
CommitStates {
|
||||
booted: booted_commit.to_string(),
|
||||
orig: sysrepo_obj.resolve_rev(ORIGREF, false)?.into(),
|
||||
orig: sysrepo_obj.resolve_rev(ORIGREF, false)?.unwrap().into(),
|
||||
prev: srvrepo_obj
|
||||
.resolve_rev(&format!("{}^", TESTREF), false)?
|
||||
.unwrap()
|
||||
.into(),
|
||||
target: srvrepo_obj.resolve_rev(TESTREF, false)?.into(),
|
||||
target: srvrepo_obj.resolve_rev(TESTREF, false)?.unwrap().into(),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -377,7 +384,7 @@ fn impl_transaction_test<M: AsRef<str>>(
|
|||
|
||||
assert_ne!(commitstates.booted.as_str(), commitstates.target.as_str());
|
||||
|
||||
let mut rt = tokio::runtime::Runtime::new()?;
|
||||
let rt = tokio::runtime::Runtime::new()?;
|
||||
let cycle_time_ms = (tdata.cycle_time.as_secs_f64() * 1000f64 * FORCE_REBOOT_AFTER_MUL) as u64;
|
||||
// Set when we're trying an interrupt strategy that isn't a reboot, so we will
|
||||
// re-enter the loop below.
|
||||
|
|
@ -483,7 +490,7 @@ fn impl_transaction_test<M: AsRef<str>>(
|
|||
} else {
|
||||
live_strategy = Some(strategy);
|
||||
}
|
||||
let status = rpmostree_client::query_status().map_err(anyhow::Error::msg)?;
|
||||
let status = query_status()?;
|
||||
let firstdeploy = &status.deployments[0];
|
||||
let pending_commit = firstdeploy.checksum.as_str();
|
||||
validate_pending_commit(pending_commit, &commitstates)
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ where
|
|||
F: Send + 'static,
|
||||
{
|
||||
let path = path.as_ref();
|
||||
let mut rt = Runtime::new()?;
|
||||
let rt = Runtime::new()?;
|
||||
rt.block_on(async move {
|
||||
let addr = http_server(path, *opts).await?;
|
||||
tokio::task::spawn_blocking(move || f(&addr)).await?
|
||||
|
|
|
|||
Loading…
Reference in New Issue