Skip to content

Commit

Permalink
[skip-ci] RPM/TMT: use tests subpackage
Browse files Browse the repository at this point in the history
This makes fetching and running of gating tests similar to podman,
buildah and skopeo.

Signed-off-by: Lokesh Mandvekar <[email protected]>
  • Loading branch information
lsm5 committed Dec 25, 2024
1 parent 91f7cb2 commit f29b9d0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 41 deletions.
19 changes: 7 additions & 12 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
31 changes: 24 additions & 7 deletions plans/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 36 additions & 0 deletions rpm/aardvark-dns.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,6 +59,29 @@ BuildRequires: rust-srpm-macros
Forwards other request to configured resolvers.
Read more about configuration in `src/backend/mod.rs`.

%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
Expand All @@ -78,6 +107,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}
Expand All @@ -87,5 +120,8 @@ tar fx %{SOURCE1}
%dir %{_libexecdir}/podman
%{_libexecdir}/podman/%{name}

%files tests
%{_datadir}/%{name}/test

%changelog
%autochangelog
13 changes: 3 additions & 10 deletions test/tmt/main.fmf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -33,3 +24,5 @@ adjust:
tag: [ upstream, downstream]
summary: Integration tests
test: bash test_integration.sh
environment:
AARDVARK: /usr/libexec/podman/aardvark-dns
15 changes: 3 additions & 12 deletions test/tmt/test_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/

0 comments on commit f29b9d0

Please sign in to comment.