//! AUTOPKGTEST_REBOOT_MARK.
use anyhow::{Context, Result};
-use commandspec::sh_execute;
+use sh_inline::bash;
use rand::seq::SliceRandom;
use rand::Rng;
use serde::{Deserialize, Serialize};
/// TODO add readonly sysroot handling into base ostree
fn testinit() -> Result<()> {
assert!(std::path::Path::new("/run/ostree-booted").exists());
- sh_execute!(
+ bash!(
r"if ! test -w /sysroot; then
mount -o remount,rw /sysroot
fi"
// Amortize the prune across multiple runs; we don't want to leak space,
// but traversing all the objects is expensive. So here we only prune 1/5 of the time.
if rand::thread_rng().gen_ratio(1, 5) {
- sh_execute!(
+ bash!(
"ostree --repo={srvrepo} prune --refs-only --depth=1",
srvrepo = SRVREPO
)?;
/// and then teach our webserver to redirect to the system for objects it doesn't
/// have.
fn generate_srv_repo(commit: &str) -> Result<()> {
- sh_execute!(
+ bash!(
r#"
ostree --repo={srvrepo} init --mode=archive
ostree --repo={srvrepo} config set archive.zlib-level 1
}
fn upgrade_and_finalize() -> Result<()> {
- sh_execute!(
+ bash!(
"rpm-ostree upgrade
systemctl start ostree-finalize-staged
systemctl stop ostree-finalize-staged"
fn validate_pending_commit(pending_commit: &str, commitstates: &CommitStates) -> Result<()> {
if pending_commit != commitstates.target {
- sh_execute!("rpm-ostree status -v")?;
- sh_execute!(
+ bash!("rpm-ostree status -v")?;
+ bash!(
"ostree show {pending_commit}",
pending_commit = pending_commit
)?;
// If we've reached our target iterations, exit the test successfully
if mark.iter == ITERATIONS {
// TODO also add ostree admin fsck to check the deployment directories
- sh_execute!(
+ bash!(
"echo Performing final validation...
ostree fsck"
)?;
);
// Reset the target ref to booted, and perform a cleanup
// to ensure we're re-downloading objects each time
- sh_execute!(
+ bash!(
"
systemctl stop rpm-ostreed
systemctl stop ostree-finalize-staged
// the interrupt strategy.
match strategy {
InterruptStrategy::Force(ForceInterruptStrategy::Kill9) => {
- sh_execute!(
+ bash!(
"systemctl kill -s KILL rpm-ostreed || true
systemctl kill -s KILL ostree-finalize-staged || true"
)?;
mark.reboot_strategy = Some(strategy.clone());
prepare_reboot(serde_json::to_string(&mark)?)?;
// This is a forced reboot - no syncing of the filesystem.
- sh_execute!("reboot -ff")?;
+ bash!("reboot -ff")?;
std::thread::sleep(time::Duration::from_secs(60));
// Shouldn't happen
anyhow::bail!("failed to reboot");
// We either rebooted, or failed to reboot
}
InterruptStrategy::Polite(PoliteInterruptStrategy::Stop) => {
- sh_execute!(
+ bash!(
"systemctl stop rpm-ostreed || true
systemctl stop ostree-finalize-staged || true"
)?;
};
with_webserver_in(&srvrepo, &webserver_opts, move |addr| {
let url = format!("http://{}", addr);
- sh_execute!(
+ bash!(
"ostree remote delete --if-exists testrepo
ostree remote add --set=gpg-verify=false testrepo {url}",
url = url
// Also disable some services (like zincati) because we don't want automatic updates
// in our reboots, and it currently fails to start. The less
// we have in each reboot, the faster reboots are.
- sh_execute!("systemctl disable --now zincati fedora-coreos-pinger")?;
+ bash!("systemctl disable --now zincati fedora-coreos-pinger")?;
// And prepare for updates
- sh_execute!("rpm-ostree cleanup -pr")?;
+ bash!("rpm-ostree cleanup -pr")?;
generate_update(&commit)?;
// Directly set the origin, so that we're not dependent on the pending deployment.
// FIXME: make this saner
- sh_execute!(
+ bash!(
"
ostree admin set-origin testrepo {url} {testref}
ostree refs --create testrepo:{testref} {commit}
let mut f = std::io::BufWriter::new(std::fs::File::create(&TDATAPATH)?);
serde_json::to_writer(&mut f, &tdata)?;
f.flush()?;
- sh_execute!("rpm-ostree status")?;
+ bash!("rpm-ostree status")?;
}
let tdata = {
use crate::test::*;
use anyhow::{Context, Result};
-use commandspec::{sh_command, sh_execute};
+use sh_inline::{bash_command, bash};
use with_procspawn_tempdir::with_procspawn_tempdir;
#[itest]
fn test_basic() -> Result<()> {
- sh_execute!(r"ostree --help >/dev/null")?;
+ bash!(r"ostree --help >/dev/null")?;
Ok(())
}
#[with_procspawn_tempdir]
fn test_nofifo() -> Result<()> {
assert!(std::path::Path::new(".procspawn-tmpdir").exists());
- sh_execute!(
+ bash!(
r"ostree --repo=repo init --mode=archive
mkdir tmproot
mkfifo tmproot/afile
"
)?;
cmd_fails_with(
- sh_command!(
+ bash_command!(
r#"ostree --repo=repo commit -b fifotest -s "commit fifo" --tree=dir=./tmproot"#
)
.unwrap(),
#[itest]
#[with_procspawn_tempdir]
fn test_mtime() -> Result<()> {
- sh_execute!(
+ bash!(
r"ostree --repo=repo init --mode=archive
mkdir tmproot
echo afile > tmproot/afile
"
)?;
let ts = Path::new("repo").metadata()?.modified().unwrap();
- sh_execute!(
+ bash!(
r#"ostree --repo=repo commit -b test -s "bump mtime" --tree=dir=tmproot >/dev/null"#
)?;
assert_ne!(ts, Path::new("repo").metadata()?.modified().unwrap());
#[itest]
#[with_procspawn_tempdir]
fn test_extensions() -> Result<()> {
- sh_execute!(r"ostree --repo=repo init --mode=bare")?;
+ bash!(r"ostree --repo=repo init --mode=bare")?;
assert!(Path::new("repo/extensions").exists());
Ok(())
}
)?;
let osroot = Path::new("osroot");
crate::treegen::mkroot(&osroot)?;
- sh_execute!(
+ bash!(
r#"ostree --repo={serverrepo} init --mode=archive
ostree --repo={serverrepo} commit -b os --tree=dir={osroot} >/dev/null
mkdir client
)?;
for rem in &["unauth", "badauth"] {
cmd_fails_with(
- sh_command!(
+ bash_command!(
r#"ostree --repo=client/repo pull origin-{rem} os >/dev/null"#,
rem = *rem
)
)
.context(rem)?;
}
- sh_execute!(r#"ostree --repo=client/repo pull origin-goodauth os >/dev/null"#,)?;
+ bash!(r#"ostree --repo=client/repo pull origin-goodauth os >/dev/null"#,)?;
Ok(())
})?;
Ok(())