From 3fd7ff599719852113fee64b2dc124493c3b53dc Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 20 Dec 2024 15:34:13 +0100 Subject: [PATCH] packit: Move fmf metadata into upstream This moves https://src.fedoraproject.org/tests/systemd into upstream so it's one less moving piece that we need to remember. While we're at it, do various cleanups as well: - Remove non-packit logic - Set NO_BUILD in mkosi.local.conf as it's not picked up from the process environment - Don't set unused environment variables - Remove workdir logic as we run in an ephemeral VM already - Drop --verbose from meson test to reduce noise from passed tests - Use mkosi sandbox and drop duplicated deps from metadata file - Stop running the unit tests as they already run as part of the rpm build and as part of the integration tests. - Various style fixes (cherry picked from commit b0b88f18b3237704d1f6d5b3dcb533367816ce23) --- .packit.yml | 3 +- test/fmf/.fmf/version | 1 + test/fmf/integration-tests/main.fmf | 10 ++++ test/fmf/integration-tests/test.sh | 88 +++++++++++++++++++++++++++++ test/fmf/plans/ci.fmf | 12 ++++ 5 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 test/fmf/.fmf/version create mode 100644 test/fmf/integration-tests/main.fmf create mode 100755 test/fmf/integration-tests/test.sh create mode 100644 test/fmf/plans/ci.fmf diff --git a/.packit.yml b/.packit.yml index 2dcc9e86ca..eef6e48fcf 100644 --- a/.packit.yml +++ b/.packit.yml @@ -57,8 +57,7 @@ jobs: - job: tests trigger: pull_request - fmf_url: https://src.fedoraproject.org/tests/systemd - fmf_ref: main + fmf_path: test/fmf tmt_plan: ci targets: - fedora-rawhide-x86_64 diff --git a/test/fmf/.fmf/version b/test/fmf/.fmf/version new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/fmf/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/test/fmf/integration-tests/main.fmf b/test/fmf/integration-tests/main.fmf new file mode 100644 index 0000000000..a1686c09c3 --- /dev/null +++ b/test/fmf/integration-tests/main.fmf @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +summary: Run the upstream integration test suite +test: ./test.sh +duration: 2h +require: + - coreutils + - distribution-gpg-keys + - dnf + - git-core diff --git a/test/fmf/integration-tests/test.sh b/test/fmf/integration-tests/test.sh new file mode 100755 index 0000000000..51cbab6ec9 --- /dev/null +++ b/test/fmf/integration-tests/test.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later + +set -eux +set -o pipefail + +# Switch SELinux to permissive, since the tests don't set proper contexts +setenforce 0 + +# Prepare systemd source tree +git clone "$PACKIT_TARGET_URL" systemd +pushd systemd +# If we're running in a pull request job, merge the remote branch into the current main +if [[ -n "${PACKIT_SOURCE_URL:-}" ]]; then + git remote add pr "${PACKIT_SOURCE_URL:?}" + git fetch pr "${PACKIT_SOURCE_BRANCH:?}" + git merge "pr/$PACKIT_SOURCE_BRANCH" +fi +git log --oneline -5 +popd + +# Now prepare mkosi, possibly at the same version required by the systemd repo +git clone https://github.com/systemd/mkosi +# If we have it, pin the mkosi version to the same one used by Github Actions, to ensure consistency +if [ -f .github/workflows/mkosi.yml ]; then + mkosi_hash="$(grep systemd/mkosi@ .github/workflows/mkosi.yml | sed "s|.*systemd/mkosi@||g")" + git -C mkosi checkout "$mkosi_hash" +fi + +export PATH="$PWD/mkosi/bin:$PATH" + +pushd systemd + +# shellcheck source=/dev/null +. /etc/os-release || . /usr/lib/os-release + +tee mkosi.local.conf <> /etc/yum.repos.d/copr_build* + +# Disable mkosi's own repository logic +touch /etc/yum.repos.d/mkosi.repo + +# TODO: drop once BTRFS regression is fixed in kernel 6.13 +sed -i "s/Format=btrfs/Format=ext4/" mkosi.repart/10-root.conf + +# If we don't have KVM, skip running in qemu, as it's too slow. But try to load the module first. +modprobe kvm || true +if [[ ! -e /dev/kvm ]]; then + export TEST_NO_QEMU=1 +fi + +# Create missing mountpoint for mkosi sandbox. +mkdir -p /etc/pacman.d/gnupg + +mkosi summary +mkosi -f sandbox true +mkosi -f sandbox meson setup --buildtype=debugoptimized -Dintegration-tests=true build +mkosi genkey +mkosi -f sandbox meson compile -C build mkosi +mkosi -f sandbox \ + meson test \ + -C build \ + --no-rebuild \ + --suite integration-tests \ + --print-errorlogs \ + --no-stdsplit \ + --num-processes "$(($(nproc) - 1))" + +popd diff --git a/test/fmf/plans/ci.fmf b/test/fmf/plans/ci.fmf new file mode 100644 index 0000000000..3e2a16bc89 --- /dev/null +++ b/test/fmf/plans/ci.fmf @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +summary: systemd Fedora test suite +discover: + how: fmf +prepare: + - name: systemd + how: install + exclude: + - systemd-standalone-.* +execute: + how: tmt