From 3aada947527f04578575602fcdf28ff838222196 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Thu, 5 Dec 2024 22:11:30 +0800 Subject: [PATCH] test: Remove tmt bootc plugin code and use released bootc plugin Remove tests-intetration folder because TMT bootc plugin replaces tests-integration Signed-off-by: Xiaofeng Wang --- .packit.yaml | 2 +- hack/provision-derived.sh | 32 ----------------- plans/integration-build.fmf | 27 --------------- plans/integration.fmf | 33 ++++++++++++++++++ plans/test-01-readonly.fmf | 10 +++--- plans/test-20-local-upgrade.fmf | 9 ++--- plans/test-21-logically-bound-switch.fmf | 9 ++--- plans/test-22-logically-bound-install.fmf | 5 +-- plans/test-23-install-outside-container.fmf | 8 +++-- tests-integration/build-image.fmf | 3 -- tests/containerfiles/lbi/Containerfile | 38 +++++++++++++++++++-- tests/integration.fmf | 3 ++ xtask/src/xtask.rs | 2 -- 13 files changed, 95 insertions(+), 86 deletions(-) delete mode 100644 plans/integration-build.fmf create mode 100644 plans/integration.fmf delete mode 100644 tests-integration/build-image.fmf create mode 100644 tests/integration.fmf diff --git a/.packit.yaml b/.packit.yaml index 56894d60b..fa7de8c1b 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -65,6 +65,6 @@ jobs: targets: - fedora-41-x86_64 - fedora-41-aarch64 - tmt_plan: /integration-build + tmt_plan: /integration skip_build: true identifier: integration-test diff --git a/hack/provision-derived.sh b/hack/provision-derived.sh index dddcc8237..8d5d544a3 100755 --- a/hack/provision-derived.sh +++ b/hack/provision-derived.sh @@ -1,6 +1,5 @@ #!/bin/bash set -xeu -variant=$1 # I'm a big fan of nushell for interactive use, and I want to support # using it in our test suite because it's better than bash. First, # enable EPEL to get it. @@ -15,35 +14,4 @@ mkdir -p ~/.config/nushell echo '$env.config = { show_banner: false, }' > ~/.config/nushell/config.nu touch ~/.config/nushell/env.nu dnf -y install nu -# And we also add pytest, to support running tests written in Python -dnf -y install python3-pytest -case "$variant" in - tmt) - # tmt wants rsync - dnf -y install cloud-init rsync - ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants - - # tmt puts scrips in /var/lib/tmt/scripts, add them to $PATH - touch /etc/environment - echo "export PATH=$PATH:/var/lib/tmt/scripts" >> /etc/environment - - # tmt needs a webserver to verify the VM is running - TESTCLOUD_GUEST="python3 -m http.server 10022 || python -m http.server 10022 || /usr/libexec/platform-python -m http.server 10022 || python2 -m SimpleHTTPServer 10022 || python -m SimpleHTTPServer 10022" - echo "$TESTCLOUD_GUEST" >> /opt/testcloud-guest.sh - chmod +x /opt/testcloud-guest.sh - echo "[Unit]" >> /etc/systemd/system/testcloud.service - echo "Description=Testcloud guest integration" >> /etc/systemd/system/testcloud.service - echo "After=cloud-init.service" >> /etc/systemd/system/testcloud.service - echo "[Service]" >> /etc/systemd/system/testcloud.service - echo "ExecStart=/bin/bash /opt/testcloud-guest.sh" >> /etc/systemd/system/testcloud.service - echo "[Install]" >> /etc/systemd/system/testcloud.service - echo "WantedBy=multi-user.target" >> /etc/systemd/system/testcloud.service - systemctl enable testcloud.service - ;; - "") echo "No variant" - ;; - *) - echo "Unknown variant: $1" exit 1 - ;; -esac dnf clean all && rm /var/log/* -rf diff --git a/plans/integration-build.fmf b/plans/integration-build.fmf deleted file mode 100644 index 975bb4cbc..000000000 --- a/plans/integration-build.fmf +++ /dev/null @@ -1,27 +0,0 @@ -provision: - hardware: - cpu: - processors: ">= 2" - memory: ">= 6 GB" - virtualization: - is-supported: true -prepare: - - how: install - package: - - podman - - skopeo - - tmt+provision-virtual - - how: shell - script: systemctl start libvirtd -execute: - how: tmt -discover: - how: fmf - test: - - /build-image -finish: - how: shell - script: - # move tmt test log to tmt plan data folder - # the tmt integration test log can be archived in testing farm artifacts - - cp -r /var/tmp/tmt/run-001 $TMT_PLAN_DATA/test-tmt-log diff --git a/plans/integration.fmf b/plans/integration.fmf new file mode 100644 index 000000000..42b277ed1 --- /dev/null +++ b/plans/integration.fmf @@ -0,0 +1,33 @@ +provision: + hardware: + cpu: + processors: ">= 2" + memory: ">= 6 GB" + virtualization: + is-supported: true +prepare: + - how: install + package: + - git + - podman + - skopeo + - tmt+provision-virtual + - tmt+provision-bootc + - how: shell + script: | + systemctl start libvirtd + systemctl status libvirtd +environment: + TMT_VERBOSE: 1 +execute: + how: tmt +discover: + how: fmf + test: + - /integration +finish: + how: shell + script: + # move all tmt plan logs to tmt plan data folder + - mkdir -p $TMT_PLAN_DATA/test-tmt-log + - cp -r /var/tmp/tmt/run-* $TMT_PLAN_DATA/test-tmt-log diff --git a/plans/test-01-readonly.fmf b/plans/test-01-readonly.fmf index c6114b200..bf1642dae 100644 --- a/plans/test-01-readonly.fmf +++ b/plans/test-01-readonly.fmf @@ -1,9 +1,9 @@ -# Run this via `make test-tmt` which will build a container, -# and a disk image from it. provision: - how: virtual - # Generated by make test-tmt - image: file://./target/testvm/disk.qcow2 + how: bootc + add-tmt-dependencies: true + container-file: hack/Containerfile + container-file-workdir: . + image-builder: quay.io/centos-bootc/bootc-image-builder:latest disk: 20 summary: Execute booted readonly/nondestructive tests execute: diff --git a/plans/test-20-local-upgrade.fmf b/plans/test-20-local-upgrade.fmf index e095c60bf..8b5a655ea 100644 --- a/plans/test-20-local-upgrade.fmf +++ b/plans/test-20-local-upgrade.fmf @@ -1,8 +1,9 @@ -# provision: - how: virtual - # Generated by make test-tmt - image: file://./target/testvm/disk.qcow2 + how: bootc + add-tmt-dependencies: true + container-file: hack/Containerfile + container-file-workdir: . + image-builder: quay.io/centos-bootc/bootc-image-builder:latest disk: 20 summary: Execute local upgrade tests execute: diff --git a/plans/test-21-logically-bound-switch.fmf b/plans/test-21-logically-bound-switch.fmf index fbdd2f7ac..cbc5b0c5d 100644 --- a/plans/test-21-logically-bound-switch.fmf +++ b/plans/test-21-logically-bound-switch.fmf @@ -1,8 +1,9 @@ -# provision: - how: virtual - # Generated by make test-tmt - image: file://./target/testvm/disk.qcow2 + how: bootc + add-tmt-dependencies: true + container-file: hack/Containerfile + container-file-workdir: . + image-builder: quay.io/centos-bootc/bootc-image-builder:latest disk: 20 summary: Execute logically bound images tests for switching images execute: diff --git a/plans/test-22-logically-bound-install.fmf b/plans/test-22-logically-bound-install.fmf index 92f7e0835..fb1eb5e2e 100644 --- a/plans/test-22-logically-bound-install.fmf +++ b/plans/test-22-logically-bound-install.fmf @@ -1,8 +1,9 @@ provision: how: bootc - add-tmt-dependencies: false + add-tmt-dependencies: true container-file: tests/containerfiles/lbi/Containerfile - container-file-workdir: tests/containerfiles/lbi + container-file-workdir: . + image-builder: quay.io/centos-bootc/bootc-image-builder:latest disk: 20 summary: Execute logically bound images tests for installing image execute: diff --git a/plans/test-23-install-outside-container.fmf b/plans/test-23-install-outside-container.fmf index 2e91c9577..ec17929c0 100644 --- a/plans/test-23-install-outside-container.fmf +++ b/plans/test-23-install-outside-container.fmf @@ -1,7 +1,9 @@ provision: - how: virtual - # Generated by make test-tmt - image: file://./target/testvm/disk.qcow2 + how: bootc + add-tmt-dependencies: true + container-file: hack/Containerfile + container-file-workdir: . + image-builder: quay.io/centos-bootc/bootc-image-builder:latest disk: 20 summary: Execute tests for installing outside of a container execute: diff --git a/tests-integration/build-image.fmf b/tests-integration/build-image.fmf deleted file mode 100644 index 075df589c..000000000 --- a/tests-integration/build-image.fmf +++ /dev/null @@ -1,3 +0,0 @@ -summary: build bootc and build qcow2 image -test: cd .. && dnf -y builddep bootc && make test-tmt -duration: 30m diff --git a/tests/containerfiles/lbi/Containerfile b/tests/containerfiles/lbi/Containerfile index 7466e11e7..3a2b7c915 100644 --- a/tests/containerfiles/lbi/Containerfile +++ b/tests/containerfiles/lbi/Containerfile @@ -1,7 +1,39 @@ -FROM localhost/bootc - -COPY ./usr/. /usr +# Build bootc from the current git into a c9s-bootc container image. +# Use e.g. --build-arg=base=quay.io/fedora/fedora-bootc:40 to target +# Fedora instead. +# +# You can also generate an image with cloud-init and other dependencies +# with `--build-arg=tmt` which is intended for use particularly via +# https://tmt.readthedocs.io/en/stable/ +ARG base=quay.io/centos-bootc/centos-bootc:stream9 +FROM $base as build +COPY hack/build.sh /build.sh +RUN /build.sh && rm -v /build.sh +COPY . /build +WORKDIR /build +RUN mkdir -p /build/target/dev-rootfs # This can hold arbitrary extra content +# See https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/ +# We aren't using the full recommendations there, just the simple bits. +RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome make test-bin-archive && mkdir -p /out && cp target/bootc.tar.zst /out +FROM $base +# We support e.g. adding cloud-init +ARG variant= +COPY hack/provision-derived.sh /tmp +RUN /tmp/provision-derived.sh "$variant" && rm -f /tmp/*.sh +# Also copy in some default install configs we use for testing +COPY hack/install-test-configs/* /usr/lib/bootc/install/ +# And some test kargs +COPY hack/test-kargs /usr/lib/bootc/kargs.d/ +# Inject our built code +COPY --from=build /out/bootc.tar.zst /tmp +RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vrf /tmp/* +# Also copy over arbitrary bits from the target root +COPY --from=build /build/target/dev-rootfs/ / +# Test our own linting +RUN bootc container lint +# For test-22-logically-bound-install +COPY tests/containerfiles/lbi/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 && \ ln -s /usr/share/containers/systemd/podman.image /usr/lib/bootc/bound-images.d/podman.image diff --git a/tests/integration.fmf b/tests/integration.fmf new file mode 100644 index 000000000..f3bb14b04 --- /dev/null +++ b/tests/integration.fmf @@ -0,0 +1,3 @@ +summary: Run integration test +test: cd .. && dnf -y builddep bootc && make test-tmt +duration: 1h diff --git a/xtask/src/xtask.rs b/xtask/src/xtask.rs index 5d2716e1f..0cb939019 100644 --- a/xtask/src/xtask.rs +++ b/xtask/src/xtask.rs @@ -200,8 +200,6 @@ 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()?;