Skip to content

Commit

Permalink
test: Remove tmt bootc plugin code and use released bootc plugin
Browse files Browse the repository at this point in the history
Remove tests-intetration folder because TMT bootc plugin replaces
tests-integration

Signed-off-by: Xiaofeng Wang <[email protected]>
  • Loading branch information
henrywang committed Dec 7, 2024
1 parent ff0260a commit 3aada94
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 0 additions & 32 deletions hack/provision-derived.sh
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
27 changes: 0 additions & 27 deletions plans/integration-build.fmf

This file was deleted.

33 changes: 33 additions & 0 deletions plans/integration.fmf
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions plans/test-01-readonly.fmf
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 5 additions & 4 deletions plans/test-20-local-upgrade.fmf
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 5 additions & 4 deletions plans/test-21-logically-bound-switch.fmf
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 3 additions & 2 deletions plans/test-22-logically-bound-install.fmf
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 5 additions & 3 deletions plans/test-23-install-outside-container.fmf
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 0 additions & 3 deletions tests-integration/build-image.fmf

This file was deleted.

38 changes: 35 additions & 3 deletions tests/containerfiles/lbi/Containerfile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/integration.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
summary: Run integration test
test: cd .. && dnf -y builddep bootc && make test-tmt
duration: 1h
2 changes: 0 additions & 2 deletions xtask/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;

Expand Down

0 comments on commit 3aada94

Please sign in to comment.