From 0f09ae234ed3c024d0a6c73c3b8a68560fab42ed Mon Sep 17 00:00:00 2001 From: Chris Kyrouac Date: Wed, 18 Sep 2024 10:07:21 -0400 Subject: [PATCH] tests: Add tmt test for bootc install with LBI Along with the test, this will install the LBIs on the machine running the tests prior to running the tests. Also refactors the existing LBI test into a separate test plan to make room for the install tests. Signed-off-by: Chris Kyrouac --- ...-bound.fmf => test-21-logically-bound-switch.fmf} | 4 ++-- plans/test-22-logically-bound-install.fmf | 12 ++++++++++++ tests/booted/test-logically-bound-install.nu | 10 ++++++++++ ...cally-bound.nu => test-logically-bound-switch.nu} | 0 tests/containerfiles/lbi/Containerfile | 6 ++++++ .../lbi/usr/share/containers/systemd/curl-base.image | 2 ++ .../lbi/usr/share/containers/systemd/curl.container | 3 +++ .../share/containers/systemd/jboss-webserver-5.image | 6 ++++++ xtask/src/xtask.rs | 4 ++++ 9 files changed, 45 insertions(+), 2 deletions(-) rename plans/{test-21-logically-bound.fmf => test-21-logically-bound-switch.fmf} (63%) create mode 100644 plans/test-22-logically-bound-install.fmf create mode 100644 tests/booted/test-logically-bound-install.nu rename tests/booted/{test-logically-bound.nu => test-logically-bound-switch.nu} (100%) create mode 100644 tests/containerfiles/lbi/Containerfile create mode 100644 tests/containerfiles/lbi/usr/share/containers/systemd/curl-base.image create mode 100644 tests/containerfiles/lbi/usr/share/containers/systemd/curl.container create mode 100644 tests/containerfiles/lbi/usr/share/containers/systemd/jboss-webserver-5.image diff --git a/plans/test-21-logically-bound.fmf b/plans/test-21-logically-bound-switch.fmf similarity index 63% rename from plans/test-21-logically-bound.fmf rename to plans/test-21-logically-bound-switch.fmf index a78f68988..fbdd2f7ac 100644 --- a/plans/test-21-logically-bound.fmf +++ b/plans/test-21-logically-bound-switch.fmf @@ -4,9 +4,9 @@ provision: # Generated by make test-tmt image: file://./target/testvm/disk.qcow2 disk: 20 -summary: Execute logically bound images tests +summary: Execute logically bound images tests for switching images execute: how: tmt # We avoid writing nontrivial shell script as a general rule, # so this is written in nu. - script: exec nu tests/booted/test-logically-bound.nu + script: exec nu tests/booted/test-logically-bound-switch.nu diff --git a/plans/test-22-logically-bound-install.fmf b/plans/test-22-logically-bound-install.fmf new file mode 100644 index 000000000..0445cac42 --- /dev/null +++ b/plans/test-22-logically-bound-install.fmf @@ -0,0 +1,12 @@ +environment+: + TMT_PLUGINS: ./tests/plugins +provision: + how: bootc + add_deps: false + containerfile: tests/containerfiles/lbi/Containerfile + containerfile_workdir: tests/containerfiles/lbi + disk: 20 +summary: Execute logically bound images tests for installing image +execute: + how: tmt + script: exec nu tests/booted/test-logically-bound-install.nu diff --git a/tests/booted/test-logically-bound-install.nu b/tests/booted/test-logically-bound-install.nu new file mode 100644 index 000000000..44facc319 --- /dev/null +++ b/tests/booted/test-logically-bound-install.nu @@ -0,0 +1,10 @@ +use std assert +use tap.nu + +let images = podman --storage-opt=additionalimagestore=/usr/lib/bootc/storage images --format {{.Repository}} | from csv --noheaders +print "IMAGES:" +podman --storage-opt=additionalimagestore=/usr/lib/bootc/storage images # for debugging +assert ($images | any {|item| $item.column1 == "quay.io/curl/curl"}) +assert ($images | any {|item| $item.column1 == "quay.io/curl/curl-base"}) + +tap ok diff --git a/tests/booted/test-logically-bound.nu b/tests/booted/test-logically-bound-switch.nu similarity index 100% rename from tests/booted/test-logically-bound.nu rename to tests/booted/test-logically-bound-switch.nu diff --git a/tests/containerfiles/lbi/Containerfile b/tests/containerfiles/lbi/Containerfile new file mode 100644 index 000000000..bf9f8e1ef --- /dev/null +++ b/tests/containerfiles/lbi/Containerfile @@ -0,0 +1,6 @@ +FROM localhost/bootc + +COPY ./usr/. /usr + +RUN ln -s /usr/share/containers/systemd/curl.container /usr/lib/bootc/bound-images.d/curl.container && \ + ln -s /usr/share/containers/systemd/curl-base.image /usr/lib/bootc/bound-images.d/curl-base.image diff --git a/tests/containerfiles/lbi/usr/share/containers/systemd/curl-base.image b/tests/containerfiles/lbi/usr/share/containers/systemd/curl-base.image new file mode 100644 index 000000000..5c818c0fb --- /dev/null +++ b/tests/containerfiles/lbi/usr/share/containers/systemd/curl-base.image @@ -0,0 +1,2 @@ +[Image] +Image=quay.io/curl/curl-base:latest diff --git a/tests/containerfiles/lbi/usr/share/containers/systemd/curl.container b/tests/containerfiles/lbi/usr/share/containers/systemd/curl.container new file mode 100644 index 000000000..b3788916c --- /dev/null +++ b/tests/containerfiles/lbi/usr/share/containers/systemd/curl.container @@ -0,0 +1,3 @@ +[Container] +Image=quay.io/curl/curl:latest +GlobalArgs=--storage-opt=additionalimagestore=/usr/lib/bootc/storage diff --git a/tests/containerfiles/lbi/usr/share/containers/systemd/jboss-webserver-5.image b/tests/containerfiles/lbi/usr/share/containers/systemd/jboss-webserver-5.image new file mode 100644 index 000000000..6b04d82dc --- /dev/null +++ b/tests/containerfiles/lbi/usr/share/containers/systemd/jboss-webserver-5.image @@ -0,0 +1,6 @@ +# This is not symlinked to bound-images.d so it should not be pulled. +# It's here to represent an app image that exists +# in a bootc image but is not logically bound. +[Image] +Image=registry.redhat.io/jboss-webserver-5/jws5-rhel8-operator:latest +AuthFile=/root/auth.json diff --git a/xtask/src/xtask.rs b/xtask/src/xtask.rs index df55e2ffb..3903450c0 100644 --- a/xtask/src/xtask.rs +++ b/xtask/src/xtask.rs @@ -8,6 +8,7 @@ use fn_error_context::context; use xshell::{cmd, Shell}; const NAME: &str = "bootc"; +const TEST_IMAGES: &[&str] = &["quay.io/curl/curl-base:latest", "quay.io/curl/curl:latest"]; fn main() { if let Err(e) = try_main() { @@ -182,6 +183,9 @@ fn test_tmt(sh: &Shell) -> Result<()> { cmd!(sh, "cargo run -p tests-integration run-vm prepare-tmt").run()?; + // pull some small images that are used for LBI installation tests + cmd!(sh, "podman pull {TEST_IMAGES...}").run()?; + for (_prio, name) in all_plan_files { // cc https://pagure.io/testcloud/pull-request/174 cmd!(sh, "rm -vf /var/tmp/tmt/testcloud/images/disk.qcow2").run()?;