Skip to content

Commit 74f6afc

Browse files
committed
TMT: initial enablement
This commit adds `validate`, `unit`, and `integration` tests using for aarch64 and x86_64 arches on all active Fedora and CentOS Stream versions. Also includes podman revdep test contributed for c9s by Yuhui Jiang <[email protected]>. Ref: https://gitlab.com/redhat/centos-stream/rpms/netavark/-/merge_requests/59 Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent a8bd0a7 commit 74f6afc

File tree

15 files changed

+264
-10
lines changed

15 files changed

+264
-10
lines changed

.fmf/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ vendor/
88
.idea/*
99
contrib/systemd/*/*.service
1010
.vscode*
11+
rpm/RPMS
12+
rpm/SRPMS
13+
rpm/*.tar.gz

.packit.yaml

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,40 @@
55
downstream_package_name: netavark
66
upstream_tag_template: v{version}
77

8+
# These files get synced from upstream to downstream (Fedora / CentOS Stream) on every
9+
# propose-downstream job. This is done so tests maintained upstream can be run
10+
# downstream in Zuul CI and Bodhi.
11+
# Ref: https://packit.dev/docs/configuration#files_to_sync
12+
files_to_sync:
13+
- src: rpm/gating.yaml
14+
dest: gating.yaml
15+
delete: true
16+
- src: plans/
17+
dest: plans/
18+
delete: true
19+
mkpath: true
20+
- src: test/tmt
21+
dest: test/tmt
22+
delete: true
23+
mkpath: true
24+
- src: test-dhcp/tmt
25+
dest: test-dhcp/tmt
26+
delete: true
27+
mkpath: true
28+
- src: .fmf/
29+
dest: .fmf/
30+
delete: true
31+
- .packit.yaml
32+
833
packages:
934
netavark-fedora:
1035
pkg_tool: fedpkg
1136
specfile_path: rpm/netavark.spec
1237
netavark-centos:
1338
pkg_tool: centpkg
1439
specfile_path: rpm/netavark.spec
40+
netavark-eln:
41+
specfile_path: rpm/netavark.spec
1542

1643
srpm_build_deps:
1744
- cargo
@@ -22,12 +49,21 @@ jobs:
2249
- job: copr_build
2350
trigger: pull_request
2451
packages: [netavark-fedora]
25-
notifications: &copr_build_failure_notification
26-
failure_comment:
27-
message: "Ephemeral COPR build failed. @containers/packit-build please check."
52+
#notifications: &copr_build_failure_notification
53+
# failure_comment:
54+
# message: "Ephemeral COPR build failed. @containers/packit-build please check."
55+
targets: &fedora_copr_targets
56+
- fedora-all-x86_64
57+
- fedora-all-aarch64
58+
enable_net: true
59+
60+
- job: copr_build
61+
trigger: ignore
62+
packages: [netavark-eln]
63+
#notifications: &copr_build_failure_notification
64+
# failure_comment:
65+
# message: "Ephemeral COPR build failed. @containers/packit-build please check."
2866
targets:
29-
fedora-all-x86_64: {}
30-
fedora-all-aarch64: {}
3167
fedora-eln-x86_64:
3268
additional_repos:
3369
- "https://kojipkgs.fedoraproject.org/repos/eln-build/latest/x86_64/"
@@ -39,8 +75,8 @@ jobs:
3975
- job: copr_build
4076
trigger: pull_request
4177
packages: [netavark-centos]
42-
notifications: *copr_build_failure_notification
43-
targets:
78+
#notifications: *copr_build_failure_notification
79+
targets: &centos_copr_targets
4480
- centos-stream-9-x86_64
4581
- centos-stream-9-aarch64
4682
- centos-stream-10-x86_64
@@ -59,6 +95,47 @@ jobs:
5995
project: podman-next
6096
enable_net: true
6197

98+
# validate and unit tests
99+
# rpm independent and sufficient to run on only one env
100+
- job: tests
101+
trigger: pull_request
102+
packages: [netavark-fedora] # Include this else it will create multiple jobs
103+
skip_build: true
104+
targets:
105+
- fedora-latest-stable
106+
tmt_plan: "/plans/no-rpm"
107+
identifier: "no-rpm"
108+
109+
- job: tests
110+
trigger: pull_request
111+
packages: [netavark-fedora]
112+
#notifications:
113+
#failure_comment:
114+
# message: "TMT tests failed. @containers/packit-build please check."
115+
targets: *fedora_copr_targets
116+
tf_extra_params:
117+
environments:
118+
- artifacts:
119+
- type: repository-file
120+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
121+
tmt_plan: "/plans/rpm"
122+
identifier: "rpm-fedora"
123+
124+
- job: tests
125+
trigger: pull_request
126+
packages: [netavark-centos]
127+
#notifications:
128+
#failure_comment:
129+
# message: "TMT tests failed. @containers/packit-build please check."
130+
targets: *centos_copr_targets
131+
tf_extra_params:
132+
environments:
133+
- artifacts:
134+
- type: repository-file
135+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
136+
tmt_plan: "/plans/rpm"
137+
identifier: "rpm-centos"
138+
62139
# Sync to Fedora
63140
- job: propose_downstream
64141
trigger: release

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ NV_UNIT_FILES = contrib/systemd/system/netavark-dhcp-proxy.service \
9696
.PHONY: install
9797
install: $(NV_UNIT_FILES)
9898
install ${SELINUXOPT} -D -m0755 bin/netavark $(DESTDIR)$(LIBEXECPODMAN)/netavark
99+
install ${SELINUXOPT} -D -m0755 bin/netavark-dhcp-proxy-client $(DESTDIR)$(LIBEXECPODMAN)/netavark-dhcp-proxy-client
99100
$(MAKE) -C docs install
100101
install ${SELINUXOPT} -m 755 -d ${DESTDIR}${SYSTEMDDIR}
101102
install ${SELINUXOPT} -m 644 contrib/systemd/system/netavark-dhcp-proxy.socket ${DESTDIR}${SYSTEMDDIR}/netavark-dhcp-proxy.socket

plans/main.fmf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
discover:
2+
how: fmf
3+
execute:
4+
how: tmt
5+
prepare:
6+
- when: distro == centos-stream or distro == rhel
7+
how: shell
8+
script: |
9+
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm --eval '%{?rhel}').noarch.rpm
10+
dnf -y config-manager --set-enabled epel
11+
order: 10
12+
- when: initiator == packit
13+
how: shell
14+
script: |
15+
COPR_REPO_FILE="/etc/yum.repos.d/*podman-next*.repo"
16+
if compgen -G $COPR_REPO_FILE > /dev/null; then
17+
sed -i -n '/^priority=/!p;$apriority=1' $COPR_REPO_FILE
18+
fi
19+
dnf -y upgrade --allowerasing
20+
order: 20
21+
22+
/no-rpm:
23+
summary: Run tests independent of rpm
24+
discover+:
25+
filter: tag:no-rpm
26+
adjust+:
27+
- enabled: false
28+
when: initiator is not defined or initiator != packit
29+
30+
/rpm:
31+
summary: Run tests on the rpm
32+
discover+:
33+
filter: tag:rpm

rpm/gating.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- !Policy
2+
product_versions:
3+
- fedora-*
4+
decision_context:
5+
- bodhi_update_push_stable
6+
- bodhi_update_push_testing
7+
subject_type: koji_build
8+
rules:
9+
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}
10+
11+
--- !Policy
12+
product_versions:
13+
- rhel-*
14+
decision_context: osci_compose_gate
15+
rules:
16+
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

rpm/netavark.spec

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,29 @@ Its features include:
8888
* Support for IPv4 and IPv6
8989
* Support for container DNS resolution via aardvark-dns.
9090

91+
# Only intended to be used for gating tests
92+
# End user usecases not supported
93+
%package tests
94+
Summary: Tests for %{name}
95+
Requires: %{name} = %{epoch}:%{version}-%{release}
96+
%if %{defined bats_ofc}
97+
Requires: bats
98+
%else
99+
Recommends: bats
100+
%endif
101+
Requires: bind-utils
102+
Requires: dbus-daemon
103+
Requires: dnsmasq
104+
Requires: firewalld
105+
Requires: iptables
106+
Requires: jq
107+
Requires: net-tools
108+
Requires: nftables
109+
Requires: nmap-ncat
110+
111+
%description tests
112+
%{summary}
113+
91114
%prep
92115
%autosetup -Sgit %{name}-%{version}
93116
# Following steps are only required on environments like koji which have no
@@ -104,18 +127,30 @@ tar fx %{SOURCE1}
104127

105128
%build
106129
NETAVARK_DEFAULT_FW=%{default_fw} %{__make} CARGO="%{__cargo}" build
130+
%{__make} CARGO="%{__cargo}" build_proxy_client
107131
%if (0%{?fedora} || 0%{?rhel} >= 10) && !%{defined copr_username}
108132
%cargo_license_summary
109133
%{cargo_license} > LICENSE.dependencies
110134
%cargo_vendor_manifest
111135
%endif
112136

137+
# Build examples package for tests
138+
%{__make} CARGO="%{__cargo}" examples
139+
113140
cd docs
114141
%{__make}
115142

116143
%install
117144
%{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} install
118145

146+
%{__install} -d -p %{buildroot}%{_datadir}/%{name}/{examples,test,test-dhcp}
147+
%{__cp} -rpav targets/release/examples/* %{buildroot}%{_datadir}/%{name}/examples
148+
%{__cp} -rpav test/* %{buildroot}%{_datadir}/%{name}/test
149+
%{__cp} -rpav test-dhcp/* %{buildroot}%{_datadir}/%{name}/test-dhcp
150+
151+
%{__rm} -rf %{buildroot}%{_datadir}/%{name}/test/tmt
152+
%{__rm} -rf %{buildroot}%{_datadir}/%{name}/test-dhcp/tmt
153+
119154
%preun
120155
%systemd_preun %{name}-dhcp-proxy.service
121156
%systemd_preun %{name}-firewalld-reload.service
@@ -138,5 +173,14 @@ cd docs
138173
%{_unitdir}/%{name}-dhcp-proxy.socket
139174
%{_unitdir}/%{name}-firewalld-reload.service
140175

176+
%files tests
177+
%dir %{_datadir}/%{name}
178+
%dir %{_datadir}/%{name}/examples
179+
%dir %{_datadir}/%{name}/test
180+
%dir %{_datadir}/%{name}/test-dhcp
181+
%{_datadir}/%{name}/examples/*
182+
%{_datadir}/%{name}/test/*
183+
%{_datadir}/%{name}/test-dhcp/*
184+
141185
%changelog
142186
%autochangelog

test-dhcp/helpers.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TMP_TESTDIR=
1111

1212
# Netavark binary to run
1313
NETAVARK=${NETAVARK:-./bin/netavark}
14-
14+
NETAVARK_DHCP_PROXY_CLIENT=${NETAVARK_DHCP_PROXY_CLIENT:-./bin/netavark-dhcp-proxy-client}
1515
TESTSDIR=${TESTSDIR:-$(dirname ${BASH_SOURCE})}
1616

1717
# export RUST_BACKTRACE so that we get a helpful stack trace
@@ -407,7 +407,7 @@ function run_teardown(){
407407
function run_client(){
408408
local verb=$1
409409
local conf=$2
410-
run_in_container_netns "./bin/netavark-dhcp-proxy-client" --uds "$TMP_TESTDIR/nv-proxy.sock" -f "${conf}" "${verb}"
410+
run_in_container_netns "$NETAVARK_DHCP_PROXY_CLIENT" --uds "$TMP_TESTDIR/nv-proxy.sock" -f "${conf}" "${verb}"
411411
}
412412

413413
###################

test-dhcp/tmt/integration.fmf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Only common dependencies that are NOT required to run test_integration.sh are
2+
# specified here. Everything else is in test_integration.sh.
3+
require:
4+
- iptables
5+
- netavark-tests
6+
7+
adjust:
8+
duration: 10m
9+
when: arch == aarch64
10+
11+
tag: [ upstream, downstream ]
12+
summary: Integration tests
13+
test: bash integration.sh
14+
environment:
15+
NETAVARK: /usr/libexec/podman/netavark
16+
NETAVARK_DHCP_PROXY_CLIENT: /usr/libexec/podman/netavark-dhcp-proxy-client
17+
TEST_PLUGINS: /usr/share/netavark/examples

test-dhcp/tmt/integration.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
rpm -q aardvark-dns cargo netavark
6+
7+
# Run tests
8+
bats /usr/share/netavark/test-dhcp

0 commit comments

Comments
 (0)