Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
omertuc committed Sep 5, 2024
1 parent b31fc2b commit 1333517
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions tests-integration/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ pub(crate) const BASE_ARGS: &[&str] = &[
];

// Clear out and delete any ostree roots
fn reset_root(sh: &Shell) -> Result<()> {
// TODO fix https://github.com/containers/bootc/pull/137
if !Path::new("/ostree/deploy/default").exists() {
return Ok(());
}
cmd!(
sh,
"sudo /bin/sh -c 'chattr -i /ostree/deploy/default/deploy/*'"
)
.run()?;
cmd!(sh, "sudo rm /ostree/deploy/default -rf").run()?;
fn reset_root(sh: &Shell, image: &str) -> Result<()> {
let target_args = &["-v", "/ostree:/ostree"];
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} {image} bootc install to-filesystem state wipe-ostree").run()?;
cmd!(sh, "sudo /bin/sh -c 'rm -rf /ostree/deploy/*'").run()?;
Ok(())
}

Expand Down Expand Up @@ -76,7 +69,7 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
let tests = [
Trial::test("loopback install", move || {
let sh = &xshell::Shell::new()?;
reset_root(sh)?;
reset_root(sh, image)?;
let size = 10 * 1000 * 1000 * 1000;
let mut tmpdisk = tempfile::NamedTempFile::new_in("/var/tmp")?;
tmpdisk.as_file_mut().set_len(size)?;
Expand All @@ -89,7 +82,7 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
"replace=alongside with ssh keys and a karg, and SELinux disabled",
move || {
let sh = &xshell::Shell::new()?;
reset_root(sh)?;
reset_root(sh, image)?;
let tmpd = &sh.create_temp_dir()?;
let tmp_keys = tmpd.path().join("test_authorized_keys");
let tmp_keys = tmp_keys.to_str().unwrap();
Expand Down Expand Up @@ -128,7 +121,7 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
),
Trial::test("Install and verify selinux state", move || {
let sh = &xshell::Shell::new()?;
reset_root(sh)?;
reset_root(sh, image)?;
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} {image} bootc install to-existing-root --acknowledge-destructive {generic_inst_args...}").run()?;
generic_post_install_verification()?;
let root = &Dir::open_ambient_dir("/ostree", cap_std::ambient_authority()).unwrap();
Expand All @@ -138,7 +131,7 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
}),
Trial::test("without an install config", move || {
let sh = &xshell::Shell::new()?;
reset_root(sh)?;
reset_root(sh, image)?;
let empty = sh.create_temp_dir()?;
let empty = empty.path().to_str().unwrap();
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} -v {empty}:/usr/lib/bootc/install {image} bootc install to-existing-root {generic_inst_args...}").run()?;
Expand Down

0 comments on commit 1333517

Please sign in to comment.