From 431af61c0586ea0495e113fa3939f3515823118d Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 22 Nov 2024 02:24:47 +0000 Subject: [PATCH 1/7] Switch to mkosi based runner for integration tests --- integration/upstream-tests/main.fmf | 45 +++----------- integration/upstream-tests/test.sh | 96 ++++++++++++++++++++--------- 2 files changed, 75 insertions(+), 66 deletions(-) diff --git a/integration/upstream-tests/main.fmf b/integration/upstream-tests/main.fmf index 5cb6bc3..488a4f7 100644 --- a/integration/upstream-tests/main.fmf +++ b/integration/upstream-tests/main.fmf @@ -2,67 +2,38 @@ summary: Run the upstream integration test suite test: ./test.sh duration: 2h require: - - acl - - attr - - bind-utils - coreutils - - cryptsetup - - curl - - dhcp-client - - diffutils + - distribution-gpg-keys - dnf - dnsmasq - dosfstools - e2fsprogs - elfutils - findutils + - gcc - git-core + - gperf - integritysetup - - iscsi-initiator-utils - - jq - - knot - - knot-dnssecutils + - libcap-devel + - libmount-devel - koji - - libarchive-devel - - lvm2 - - make - - mdadm - - net-tools - - nmap-ncat - - nvme-cli - - python3-pexpect - - python3-pyparsing + - meson + - python3-jinja2 - python3-pytest - qemu-kvm - qemu-system-aarch64 - - quota - rpm-build - - screen - - socat - squashfs-tools - strace - - stress - - stress-ng - swtpm - - systemd + - swtpm-tools - systemd-container - - systemd-libs - - systemd-pam - - systemd-tests - systemd-udev - systemd-ukify - - time - tpm2-tools - util-linux - - util-linux-script - - veritysetup - - wget - zstd recommend: - dnf-plugins-core - dnf5-plugins - - systemd-boot-unsigned - systemd-journal-remote - - systemd-networkd - - systemd-oom-defaults - - systemd-resolved diff --git a/integration/upstream-tests/test.sh b/integration/upstream-tests/test.sh index 1c6655c..513f06a 100755 --- a/integration/upstream-tests/test.sh +++ b/integration/upstream-tests/test.sh @@ -3,12 +3,25 @@ set -eux set -o pipefail -WORKDIR="$(mktemp -d)" +WORKDIR="$(mktemp --directory --tmpdir=/var/tmp)" pushd "$WORKDIR" +cleanup () { + if [ -f "${WORKDIR}/systemd/build/meson-logs/testlog.txt" ]; then + cp "${WORKDIR}/systemd/build/meson-logs/testlog.txt" "$TMT_TEST_DATA" + fi + if [ -d "${WORKDIR}/systemd/build/test/journal" ]; then + cp -r "${WORKDIR}/systemd/build/test/journal" "$TMT_TEST_DATA" + fi + + chmod -R o+rX "$TMT_TEST_DATA" + + rm -rf "$WORKDIR" +} + # Workaround for https://gitlab.com/testing-farm/oculus/-/issues/19 # shellcheck disable=SC2064 -trap "chmod -R o+rX $TMT_TEST_DATA" EXIT +trap cleanup EXIT # Switch SELinux to permissive, since the tests don't set proper contexts setenforce 0 @@ -17,7 +30,6 @@ setenforce 0 if [[ -n "${PACKIT_TARGET_URL:-}" ]]; then # Install systemd's build dependencies, as some of the integration tests setup stuff # requires pkg-config files - dnf builddep --allowerasing -y systemd git clone "$PACKIT_TARGET_URL" systemd cd systemd git checkout "$PACKIT_TARGET_BRANCH" @@ -28,55 +40,81 @@ if [[ -n "${PACKIT_TARGET_URL:-}" ]]; then git merge "pr/$PACKIT_SOURCE_BRANCH" fi git log --oneline -5 + + # Now prepare mkosi, possibly at the same version required by the systemd repo + mkosi_tree="${PWD}/../mkosi" + git clone https://github.com/systemd/mkosi.git "$mkosi_tree" + # 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_tree" checkout "$mkosi_hash" + fi + export PATH="${mkosi_tree}/bin:$PATH" else # If we're running outside of Packit, download SRPM for the currently installed build if ! dnf download --source "$(rpm -q systemd)"; then # If the build is recent enough it might not be on the mirrors yet, so try koji as well koji download-build --arch=src "$(rpm -q systemd --qf "%{sourcerpm}")" fi - dnf builddep --allowerasing -y ./systemd-*.src.rpm + dnf install --allowerasing -y mkosi rpmbuild --nodeps --define="_topdir $PWD" -rp ./systemd-*.src.rpm # Little hack to get to the correct directory without having to figure out # the exact name cd BUILD/*/test/../ - - # NO_BUILD=1 support for Fedora was introduced in v255 - if ! grep -q "LOOKS_LIKE_FEDORA" test/test-functions; then - # Try to apply necessary patches before giving up completely - if ! curl -Ls https://github.com/systemd/systemd/commit/b54bc139ae91b417996ddc85585710ebf3324237.patch | git apply || - ! curl -Ls https://github.com/systemd/systemd/commit/8ddbd9e07811e434fb24bc0d04812aae24fa78be.patch | git apply; then - echo "Source tree doesn't support NO_BUILD=1 on Fedora, skipping the tests" - exit 0 - fi - fi fi -# Temporarily build custom initrd with libkmod installed explicitly, as it became -# a dlopen() dep -# See: https://github.com/systemd/systemd/pull/31131 -export INITRD="$(mktemp /var/tmp/ci-XXX.initrd)" -cp -fv "/boot/initramfs-$(uname -r).img" "$INITRD" -dracut -f -v -a crypt --install /usr/lib64/libkmod.so.2 --rebuild "$INITRD" +. /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_KVM=1 + export TEST_NO_QEMU=1 +fi -export DENY_LIST_MARKERS=fedora-skip # Skip TEST-64-UDEV-STORAGE for now, as it takes a really long time without KVM -touch test/TEST-64-UDEV-STORAGE/fedora-skip # FIXME: screen 5.0.0 is FUBAR and break this test, re-enable once the issue is fixed # See: https://bugzilla.redhat.com/show_bug.cgi?id=2309284 -touch test/TEST-69-SHUTDOWN/fedora-skip - +export TEST_SKIP="TEST-64-UDEV-STORAGE TEST-69-SHUTDOWN" export ARTIFACT_DIRECTORY="${TMT_TEST_DATA:?}" export SPLIT_TEST_LOGS=1 export TEST_SAVE_JOURNAL=fail export TEST_SHOW_JOURNAL=warning -export TEST_REQUIRE_INSTALL_TESTS=0 -export TEST_PREFER_NSPAWN=1 -export TEST_NESTED_KVM=1 export NO_BUILD=1 export QEMU_TIMEOUT=1800 export NSPAWN_TIMEOUT=1200 +export SYSTEMD_INTEGRATION_TESTS=1 -test/run-integration-tests.sh +mkosi summary +meson setup build -Dintegration-tests=true -Dtests=true +mkosi --debug genkey +cp mkosi.key mkosi.crt build +meson compile -C build mkosi +meson test -C build -v --no-rebuild --suite integration-tests --print-errorlogs --no-stdsplit popd -rm -rf "$WORKDIR" From ac3ce2ba5516fc5fb8c848b13580c3ae4940432b Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 27 Nov 2024 21:38:04 +0000 Subject: [PATCH 2/7] Fix Release= parsing and setting --- integration/upstream-tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/upstream-tests/test.sh b/integration/upstream-tests/test.sh index 513f06a..d39732e 100755 --- a/integration/upstream-tests/test.sh +++ b/integration/upstream-tests/test.sh @@ -71,7 +71,7 @@ Format=disk [Distribution] PackageManagerTrees=/etc/yum.repos.d/:/etc/yum.repos.d/ -${RELEASE:+"Release=${VERSION_CODENAME}"} +Release=${VERSION_ID:-rawhide} [Build] Environment=NO_BUILD=1 ARTIFACT_DIRECTORY="${TMT_TEST_DATA:?}" TEST_SAVE_JOURNAL=fail TEST_SHOW_JOURNAL=warning From 7a0007bed1e575a168b1b658f53b151f89ad4a03 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 29 Nov 2024 22:54:07 +0900 Subject: [PATCH 3/7] mkosi: replace PackageManagerTrees= with SandboxTrees= To suppress the following warnings: /var/tmp/tmp.pU16C1yBvj/systemd/mkosi.local.conf: Setting PackageManagerTrees should be configured in [Build], not [Distribution]. /var/tmp/tmp.pU16C1yBvj/systemd/mkosi.local.conf: Setting PackageManagerTrees is deprecated, please use SandboxTrees instead. --- integration/upstream-tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/upstream-tests/test.sh b/integration/upstream-tests/test.sh index d39732e..5a223a2 100755 --- a/integration/upstream-tests/test.sh +++ b/integration/upstream-tests/test.sh @@ -70,10 +70,10 @@ tee mkosi.local.conf < Date: Fri, 29 Nov 2024 16:39:31 +0000 Subject: [PATCH 4/7] Move dependency on util-linux-script to Recommends, not available in F40 --- integration/upstream-tests/main.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/upstream-tests/main.fmf b/integration/upstream-tests/main.fmf index 5cb6bc3..92e3ef4 100644 --- a/integration/upstream-tests/main.fmf +++ b/integration/upstream-tests/main.fmf @@ -54,7 +54,6 @@ require: - time - tpm2-tools - util-linux - - util-linux-script - veritysetup - wget - zstd @@ -66,3 +65,4 @@ recommend: - systemd-networkd - systemd-oom-defaults - systemd-resolved + - util-linux-script From 6cfdcedf183a4af3b1ac4f63964f668d84d8c3f3 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 5 Dec 2024 15:49:32 +0000 Subject: [PATCH 5/7] Add /var/share/test-artifacts to the mkosi sandbox Part of the dnf repos: >>> Curl error (37): Could not read a file:// file for file:///var/share/test-ar >>> Librepo error: Cannot download repomd.xml: Cannot download repodata/repomd.x --- integration/upstream-tests/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/upstream-tests/test.sh b/integration/upstream-tests/test.sh index 5a223a2..7b5eb9f 100755 --- a/integration/upstream-tests/test.sh +++ b/integration/upstream-tests/test.sh @@ -74,6 +74,7 @@ Release=${VERSION_ID:-rawhide} [Build] SandboxTrees=/etc/yum.repos.d/:/etc/yum.repos.d/ +SandboxTrees=/var/share/test-artifacts/:/var/share/test-artifacts/ Environment=NO_BUILD=1 ARTIFACT_DIRECTORY="${TMT_TEST_DATA:?}" TEST_SAVE_JOURNAL=fail TEST_SHOW_JOURNAL=warning Incremental=no From 1f9a7c46e779d377b4aede6ae6bc53a6ee07fcd6 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 5 Dec 2024 15:50:15 +0000 Subject: [PATCH 6/7] Ensure a new line is added to dnf repo config The config file might not have a trailing new line, ensure we are not appending to the end of an existing line, breaking the config --- integration/upstream-tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/upstream-tests/test.sh b/integration/upstream-tests/test.sh index 7b5eb9f..e27b57b 100755 --- a/integration/upstream-tests/test.sh +++ b/integration/upstream-tests/test.sh @@ -83,7 +83,7 @@ RuntimeBuildSources=no EOF # Ensure packages built for this test have highest priority -echo "priority=1" >> /etc/yum.repos.d/copr_build* +echo -e "\npriority=1" >> /etc/yum.repos.d/copr_build* # Disable mkosi's own repository logic touch /etc/yum.repos.d/mkosi.repo From 531c815646006b8503e547f2da10862426d1d5b4 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 20 Dec 2024 17:20:49 +0100 Subject: [PATCH 7/7] Explicitly disable usage of tools tree We want to enable the tools tree by default upstream but the packit job can't yet run with the tools tree enabled, so explicitly disable it in the packit CI config for now. --- integration/upstream-tests/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/upstream-tests/test.sh b/integration/upstream-tests/test.sh index e27b57b..e439b85 100755 --- a/integration/upstream-tests/test.sh +++ b/integration/upstream-tests/test.sh @@ -73,6 +73,7 @@ Format=disk Release=${VERSION_ID:-rawhide} [Build] +ToolsTree= SandboxTrees=/etc/yum.repos.d/:/etc/yum.repos.d/ SandboxTrees=/var/share/test-artifacts/:/var/share/test-artifacts/ Environment=NO_BUILD=1 ARTIFACT_DIRECTORY="${TMT_TEST_DATA:?}" TEST_SAVE_JOURNAL=fail TEST_SHOW_JOURNAL=warning