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 Jan 28, 2025
1 parent 7f536cd commit fed0226
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 43 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
27 changes: 20 additions & 7 deletions plans/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,35 @@ discover:
how: fmf
execute:
how: tmt
prepare:
- when: distro == centos-stream or distro == rhel
how: shell
script: |
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm --eval '%{?rhel}').noarch.rpm
dnf -y config-manager --set-enabled epel
order: 10
- when: initiator == packit
how: shell
script: |
COPR_REPO_FILE="/etc/yum.repos.d/*podman-next*.repo"
if compgen -G $COPR_REPO_FILE > /dev/null; then
sed -i -n '/^priority=/!p;$apriority=1' $COPR_REPO_FILE
fi
dnf -y upgrade --allowerasing
order: 20

/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
25 changes: 25 additions & 0 deletions rpm/aardvark-dns.spec
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ 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}
Requires: bats
Requires: bind-utils
Requires: iptables
Requires: jq
Requires: netavark
Requires: nmap-ncat
Requires: dnsmasq

%description tests
%{summary}

This package contains system tests for %{name} and is only intended to be used
for gating tests.

%prep
%autosetup -Sgit %{name}-%{version}
# Following steps are only required on environments like koji which have no
Expand All @@ -78,6 +96,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/

# Add empty check section to silence rpmlint warning.
# No tests meant to be run here.
%check
Expand All @@ -91,5 +113,8 @@ tar fx %{SOURCE1}
%dir %{_libexecdir}/podman
%{_libexecdir}/podman/%{name}

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

%changelog
%autochangelog
8 changes: 6 additions & 2 deletions rpm/gating.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
--- !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}

--- !Policy
product_versions:
- rhel-*
decision_context: osci_compose_gate
rules: []
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
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 fed0226

Please sign in to comment.