diff --git a/.packit.yaml b/.packit.yaml index 1747d4282..d4726eda3 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -64,21 +64,23 @@ jobs: failure_comment: message: "bootc Copr build failed for {commit_sha}. @admin check logs {logs_url} and packit dashboard {packit_dashboard_url}" - # TODO: Readd some tmt tests that install the built RPM and e.g. test out system-reinstall-bootc - # - job: tests - # trigger: pull_request - # targets: - # - centos-stream-9-x86_64 - # - centos-stream-9-aarch64 - # - centos-stream-10-x86_64 - # - centos-stream-10-aarch64 - # - fedora-42-x86_64 - # - fedora-42-aarch64 - # - fedora-rawhide-x86_64 - # - fedora-rawhide-aarch64 - # tmt_plan: /integration - # skip_build: true - # identifier: integration-test + - job: tests + trigger: pull_request + targets: + - centos-stream-9-x86_64 + - centos-stream-9-aarch64 + - centos-stream-10-x86_64 + - centos-stream-10-aarch64 + - fedora-42-x86_64 + - fedora-42-aarch64 + - fedora-rawhide-x86_64 + - fedora-rawhide-aarch64 + tmt_plan: /tmt/plans/integration + tf_extra_params: + environments: + - tmt: + context: + running_env: "packit" - job: propose_downstream trigger: release diff --git a/hack/Containerfile.packit b/hack/Containerfile.packit new file mode 100644 index 000000000..1c289891d --- /dev/null +++ b/hack/Containerfile.packit @@ -0,0 +1,44 @@ +# Build image for system-reinstall-bootc test + +# Use centos-bootc:stream10 as default +FROM quay.io/centos-bootc/centos-bootc:stream10 + +WORKDIR /bootc-test + +# Some rhts-*, rstrnt-* and tmt-* commands are in /usr/local/bin +COPY bin /usr/local/bin +# Save testing farm run files +COPY ARTIFACTS /var/ARTIFACTS +# Copy bootc repo +COPY test-artifacts /var/share/test-artifacts + +RUN </dev/null && bootc status --json | grep '"type":"bootcHost"'; then + echo "This system is Image Mode." + exit 0 +fi + +# Install required packages +dnf install -y podman skopeo jq bootc system-reinstall-bootc expect ansible-core + +# temp folder to save building files and folders +BOOTC_TEMPDIR=$(mktemp -d) +trap 'rm -rf -- "$BOOTC_TEMPDIR"' EXIT + +# Copy files and folders in hack to TEMPDIR +cp -a . "$BOOTC_TEMPDIR" + +# Keep testing farm run folder +cp -r /var/ARTIFACTS "$BOOTC_TEMPDIR" + +# Copy bootc repo +cp -r /var/share/test-artifacts "$BOOTC_TEMPDIR" + +ARCH=$(uname -m) +# Get OS info +source /etc/os-release + +# Some rhts-*, rstrnt-* and tmt-* commands are in /usr/local/bin +if [[ -d /var/lib/tmt/scripts ]]; then + cp -r /var/lib/tmt/scripts "$BOOTC_TEMPDIR" +else + cp -r /usr/local/bin "$BOOTC_TEMPDIR" +fi + +# Get base image URL +TEST_OS="${ID}-${VERSION_ID}" +BASE=$(cat os-image-map.json | jq --arg v "$TEST_OS" '.[$v]') + +if [[ "$ID" == "rhel" ]]; then + # OSCI gating only + CURRENT_COMPOSE_ID=$(skopeo inspect --no-tags --retry-times=5 --tls-verify=false "docker://${BASE}" | jq -r '.Labels."redhat.compose-id"') + + if [[ -n ${CURRENT_COMPOSE_ID} ]]; then + if [[ ${CURRENT_COMPOSE_ID} == *-updates-* ]]; then + BATCH_COMPOSE="updates/" + else + BATCH_COMPOSE="" + fi + else + BATCH_COMPOSE="updates/" + CURRENT_COMPOSE_ID=latest-RHEL-$VERSION_ID + fi + + # use latest compose if specific compose is not accessible + RC=$(curl -skIw '%{http_code}' -o /dev/null "http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/STATUS") + if [[ $RC != "200" ]]; then + CURRENT_COMPOSE_ID=latest-RHEL-${VERSION_ID%%} + fi + + # generate rhel repo + tee "${BOOTC_TEMPDIR}/rhel.repo" >/dev/null < to continue" { + send "\r" + exp_continue + } + "Operation complete, rebooting in 10 seconds. Press Ctrl-C to cancel reboot, or press enter to continue immediately" { + send "\x03" + } +} + +# Wait for the program to complete +expect eof diff --git a/tmt/plans/integration.fmf b/tmt/plans/integration.fmf index 504aa0fd6..1636ec650 100644 --- a/tmt/plans/integration.fmf +++ b/tmt/plans/integration.fmf @@ -1,7 +1,17 @@ provision: how: virtual - # Build via `./tests/build.sh` image: $@{test_disk_image} +prepare: + # Replace package mode with image mode + - how: shell + script: + - pwd && ls -al + - if [[ -d hack ]]; then cd hack && ./provision-packit.sh; fi + # tmt-reboot and reboot do not work in this case + # reboot in ansible is the only way to reboot in tmt prepare + - how: ansible + playbook: + - https://github.com/henrywang/bootc/raw/refs/heads/gating/hack/packit-reboot.yml execute: how: tmt @@ -60,11 +70,18 @@ execute: how: fmf test: - /tmt/tests/test-26-examples-build + adjust: + - when: running_env == packit + enabled: false + because: packit tests use RPM bootc and does not install /usr/lib/bootc/initramfs-setup /test-27-custom-selinux-policy: summary: Execute restorecon test on system with custom selinux policy discover: how: fmf test: - - /tmt/tests/bootc-install-provision - /tmt/tests/test-27-custom-selinux-policy + adjust: + - when: running_env == packit + enabled: false + because: tmt-reboot does not work with systemd reboot in testing farm environment diff --git a/tmt/tests/booted/test-custom-selinux-policy.nu b/tmt/tests/booted/test-custom-selinux-policy.nu index eb39e9d04..75c786c39 100644 --- a/tmt/tests/booted/test-custom-selinux-policy.nu +++ b/tmt/tests/booted/test-custom-selinux-policy.nu @@ -23,7 +23,7 @@ RUN mkdir /opt123; echo \"/opt123 /opt\" >> /etc/selinux/targeted/contexts/files podman build -t localhost/bootc-derived . bootc switch --soft-reboot=auto --transport containers-storage localhost/bootc-derived - + assert (not ("/opt123" | path exists)) # https://tmt.readthedocs.io/en/stable/stories/features.html#reboot-during-test