From f5388becb610976fc529c0aabb0d9b89090ccc19 Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Tue, 24 Dec 2024 17:30:38 +0530 Subject: [PATCH] [skip-ci] RPM/TMT: use tests subpackage This makes fetching and running of gating tests similar to podman, buildah and skopeo. Signed-off-by: Lokesh Mandvekar --- .packit.yaml | 19 +++++++----------- plans/main.fmf | 31 ++++++++++++++++++++++------- rpm/aardvark-dns.spec | 38 ++++++++++++++++++++++++++++++++++++ rpm/gating.yaml | 8 ++++++-- test/tmt/main.fmf | 13 +++--------- test/tmt/test_integration.sh | 15 +++----------- 6 files changed, 81 insertions(+), 43 deletions(-) diff --git a/.packit.yaml b/.packit.yaml index e3e0afc4..627df45e 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -16,6 +16,11 @@ files_to_sync: - src: plans/ dest: plans/ delete: true + mkpath: true + - src: test/tmt + dest: test/tmt + delete: true + mkpath: true - src: .fmf/ dest: .fmf/ delete: true @@ -43,7 +48,7 @@ jobs: notifications: &copr_build_failure_notification failure_comment: message: "Ephemeral COPR build failed. @containers/packit-build please check." - targets: + targets: &fedora_copr_targets - fedora-all-x86_64 - fedora-all-aarch64 enable_net: true @@ -92,15 +97,7 @@ jobs: notifications: &test_failure_notification failure_comment: message: "Tests failed. @containers/packit-build please check." - targets: - - fedora-development-x86_64 - - fedora-development-aarch64 - - fedora-latest-x86_64 - - fedora-latest-aarch64 - - fedora-latest-stable-x86_64 - - fedora-latest-stable-aarch64 - - fedora-40-x86_64 - - fedora-40-aarch64 + targets: *fedora_copr_targets tf_extra_params: environments: - artifacts: @@ -118,8 +115,6 @@ jobs: - artifacts: - type: repository-file id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo - - type: repository-file - id: https://src.fedoraproject.org/rpms/epel-release/raw/epel$releasever/f/epel.repo # Sync to Fedora - job: propose_downstream diff --git a/plans/main.fmf b/plans/main.fmf index 5f468c55..bd16e4b6 100644 --- a/plans/main.fmf +++ b/plans/main.fmf @@ -2,22 +2,39 @@ discover: how: fmf execute: how: tmt +adjust: + - when: initiator == packit + because: "We need to test with updated packages from rhcontainerbot/podman-next copr" + prepare+: + how: shell + script: | + sed -i -n '/^priority=/!p;$apriority=1' /etc/yum.repos.d/*podman-next*.repo + dnf -y upgrade --allowerasing + # FIXME: Use epel10 once bats is available there + - when: distro == centos-stream-10 or distro == rhel-10 + because: "bats isn't yet available on epel10" + prepare+: + how: install + copr: rhcontainerbot/bats-el10 + package: bats + - when: distro == centos-stream-9 or distro == rhel-9 + because: "bats is present on EPEL on rhel9 / c9s" + prepare+: + how: feature + epel: enabled /upstream: summary: Run tests on upstream PRs discover+: filter: tag:upstream adjust+: - enabled: false - when: initiator is not defined or initiator != packit + - enabled: false + when: initiator is not defined or initiator != packit /downstream: summary: Run tests on bodhi / errata and dist-git PRs discover+: filter: tag:downstream - dist-git-install-builddeps: true - dist-git-source: true - dist-git-remove-fmf-root: true adjust+: - enabled: false - when: initiator == packit + - enabled: false + when: initiator == packit diff --git a/rpm/aardvark-dns.spec b/rpm/aardvark-dns.spec index 0f8cc289..e3b32da7 100644 --- a/rpm/aardvark-dns.spec +++ b/rpm/aardvark-dns.spec @@ -10,6 +10,12 @@ %global debug_package %{nil} %endif +# Adjust/Remove after epel10 gets bats +# Ref: https://bugzilla.redhat.com/show_bug.cgi?id=2329315 +%if %{defined fedora} || %{defined rhel} && 0%{?rhel} == 9 +%define bats_ofc 1 +%endif + Name: aardvark-dns %if %{defined copr_username} Epoch: 102 @@ -53,6 +59,31 @@ BuildRequires: rust-srpm-macros Forwards other request to configured resolvers. Read more about configuration in `src/backend/mod.rs`. +# Only intended to be used for gating tests +# End user usecases not supported +%package tests +Summary: Tests for %{name} + +Requires: %{name} = %{epoch}:%{version}-%{release} +%if %{defined bats_ofc} +Requires: bats +%else +Recommends: bats +%endif +Requires: bind-utils +Requires: iptables +Requires: jq +Requires: make +Requires: netavark +Requires: nftables +Requires: nmap-ncat +Requires: dnsmasq + +%description tests +%{summary} + +This package contains system tests for %{name} + %prep %autosetup -Sgit %{name}-%{version} # Following steps are only required on environments like koji which have no @@ -78,6 +109,10 @@ tar fx %{SOURCE1} %install %{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} install +%{__install} -d -p %{buildroot}%{_datadir}/%{name}/test +%{__cp} -rp test/* %{buildroot}%{_datadir}/%{name}/test/ +%{__rm} -rf %{buildroot}%{_datadir}/%{name}/test/tmt/ + %files %license LICENSE %if (0%{?fedora} || 0%{?rhel} >= 10) && !%{defined copr_username} @@ -87,5 +122,8 @@ tar fx %{SOURCE1} %dir %{_libexecdir}/podman %{_libexecdir}/podman/%{name} +%files tests +%{_datadir}/%{name}/test + %changelog %autochangelog diff --git a/rpm/gating.yaml b/rpm/gating.yaml index dbb1d913..6e93959a 100644 --- a/rpm/gating.yaml +++ b/rpm/gating.yaml @@ -1,7 +1,10 @@ --- !Policy product_versions: - fedora-* -decision_context: bodhi_update_push_stable +decision_context: + - bodhi_update_push_stable + - bodhi_update_push_testing +subject_type: koji_build rules: - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} @@ -9,4 +12,5 @@ rules: product_versions: - rhel-* decision_context: osci_compose_gate -rules: [] +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/test/tmt/main.fmf b/test/tmt/main.fmf index 84f49c44..54840665 100644 --- a/test/tmt/main.fmf +++ b/test/tmt/main.fmf @@ -1,19 +1,10 @@ # Only common dependencies that are NOT required to run netavark-tests.sh are # specified here. Everything else is in netavark-tests.sh. require: - - bats - - bind-utils + - aardvark-dns-tests - cargo - clippy - - go-md2man - - iptables - - jq - - make - - netavark - - nftables - - nmap-ncat - rustfmt - - dnsmasq adjust: duration: 10m @@ -33,3 +24,5 @@ adjust: tag: [ upstream, downstream] summary: Integration tests test: bash test_integration.sh + environment: + AARDVARK: /usr/libexec/podman/aardvark-dns diff --git a/test/tmt/test_integration.sh b/test/tmt/test_integration.sh index 9ecfb6e2..c3825fad 100644 --- a/test/tmt/test_integration.sh +++ b/test/tmt/test_integration.sh @@ -2,16 +2,7 @@ set -exo pipefail -# Remove testing-farm repos if they exist because they interfere with the -# podman-next copr. The default distro repos will not be removed and can be -# used wherever relevant. -rm -f /etc/yum.repos.d/tag-repository.repo +rpm -q aardvark-dns aardvark-dns-tests netavark nftables -# We want the netavark build from podman-next, so we update it after removing -# testing-farm repo. -dnf -y update netavark - -rpm -q aardvark-dns cargo netavark nftables - -# Run tests -make -C ../.. AARDVARK=/usr/libexec/podman/aardvark-dns integration +cd /usr/share/aardvark-dns/ +bats test/