Skip to content

Commit 0db8f31

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 d81a5d6 commit 0db8f31

15 files changed

+262
-12
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
@@ -7,3 +7,6 @@ vendor/
77
.idea/*
88
contrib/systemd/*/*.service
99
.vscode*
10+
rpm/RPMS
11+
rpm/SRPMS
12+
rpm/*.tar.gz

.packit.yaml

Lines changed: 73 additions & 9 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,12 +75,14 @@ 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
46-
- centos-stream-10-x86_64
47-
- centos-stream-10-aarch64
82+
# FIXME: EPEL-10 doesn't have bridge-utils yet
83+
# https://bugzilla.redhat.com/show_bug.cgi?id=2334212
84+
#- centos-stream-10-x86_64
85+
#- centos-stream-10-aarch64
4886
enable_net: true
4987

5088
# Run on commit to main branch
@@ -59,6 +97,32 @@ jobs:
5997
project: podman-next
6098
enable_net: true
6199

100+
- job: tests
101+
trigger: pull_request
102+
packages: [netavark-fedora]
103+
#notifications:
104+
#failure_comment:
105+
# message: "TMT tests failed. @containers/packit-build please check."
106+
targets: *fedora_copr_targets
107+
tf_extra_params:
108+
environments:
109+
- artifacts:
110+
- type: repository-file
111+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
112+
113+
- job: tests
114+
trigger: pull_request
115+
packages: [netavark-centos]
116+
#notifications:
117+
#failure_comment:
118+
# message: "TMT tests failed. @containers/packit-build please check."
119+
targets: *centos_copr_targets
120+
tf_extra_params:
121+
environments:
122+
- artifacts:
123+
- type: repository-file
124+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
125+
62126
# Sync to Fedora
63127
- job: propose_downstream
64128
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
discover:
2+
how: fmf
3+
execute:
4+
how: tmt
5+
adjust:
6+
- when: initiator == packit
7+
because: "We need to test with updated packages from rhcontainerbot/podman-next copr"
8+
prepare+:
9+
how: shell
10+
script: |
11+
sed -i -n '/^priority=/!p;$apriority=1' /etc/yum.repos.d/*podman-next*.repo
12+
dnf -y upgrade --allowerasing
13+
# FIXME: Use epel10 once bats is available there
14+
- when: distro == centos-stream-10 or distro == rhel-10
15+
because: "bats isn't yet available on epel10"
16+
prepare+:
17+
how: install
18+
copr: rhcontainerbot/bats-el10
19+
package: bats
20+
- when: distro == centos-stream or distro == rhel
21+
because: "bats and bridge-utils are present on EPEL"
22+
prepare+:
23+
how: feature
24+
epel: enabled
25+
26+
/upstream:
27+
summary: Run tests on upstream PRs
28+
discover+:
29+
filter: tag:upstream
30+
adjust+:
31+
- enabled: false
32+
when: initiator is not defined or initiator != packit
33+
34+
/downstream:
35+
summary: Run tests on bodhi / errata and dist-git PRs
36+
discover+:
37+
filter: tag:downstream
38+
adjust+:
39+
- enabled: false
40+
when: initiator == packit

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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ 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: bridge-utils
103+
Requires: dbus-daemon
104+
Requires: dnsmasq
105+
Requires: firewalld
106+
Requires: iptables
107+
Requires: jq
108+
Requires: net-tools
109+
Requires: nftables
110+
Requires: nmap-ncat
111+
112+
%description tests
113+
%{summary}
114+
91115
%prep
92116
%autosetup -Sgit %{name}-%{version}
93117
# Following steps are only required on environments like koji which have no
@@ -104,18 +128,30 @@ tar fx %{SOURCE1}
104128

105129
%build
106130
NETAVARK_DEFAULT_FW=%{default_fw} %{__make} CARGO="%{__cargo}" build
131+
%{__make} CARGO="%{__cargo}" build_proxy_client
107132
%if (0%{?fedora} || 0%{?rhel} >= 10) && !%{defined copr_username}
108133
%cargo_license_summary
109134
%{cargo_license} > LICENSE.dependencies
110135
%cargo_vendor_manifest
111136
%endif
112137

138+
# Build examples package for tests
139+
%{__make} CARGO="%{__cargo}" examples
140+
113141
cd docs
114142
%{__make}
115143

116144
%install
117145
%{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} install
118146

147+
%{__install} -d -p %{buildroot}%{_datadir}/%{name}/{examples,test,test-dhcp}
148+
%{__cp} -rpav targets/release/examples/* %{buildroot}%{_datadir}/%{name}/examples
149+
%{__cp} -rpav test/* %{buildroot}%{_datadir}/%{name}/test
150+
%{__cp} -rpav test-dhcp/* %{buildroot}%{_datadir}/%{name}/test-dhcp
151+
152+
%{__rm} -rf %{buildroot}%{_datadir}/%{name}/test/tmt
153+
%{__rm} -rf %{buildroot}%{_datadir}/%{name}/test-dhcp/tmt
154+
119155
%preun
120156
%systemd_preun %{name}-dhcp-proxy.service
121157
%systemd_preun %{name}-firewalld-reload.service
@@ -137,5 +173,14 @@ cd docs
137173
%{_unitdir}/%{name}-dhcp-proxy.socket
138174
%{_unitdir}/%{name}-firewalld-reload.service
139175

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+
140185
%changelog
141186
%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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
/integration:
12+
tag: [ upstream, downstream ]
13+
summary: Integration tests
14+
test: bash integration.sh
15+
environment:
16+
NETAVARK: /usr/libexec/podman/netavark
17+
NETAVARK_DHCP_PROXY_CLIENT: /usr/libexec/podman/netavark-dhcp-proxy-client
18+
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

test/500-plugin.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ EOF
3333
}
3434

3535
function run_netavark_plugins() {
36-
run_netavark --plugin-directory ./targets/release/examples/ "$@"
36+
run_netavark --plugin-directory $TEST_PLUGINS "$@"
3737
}
3838

3939
@test "plugin - test error message" {

test/helpers.bash

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

33
# Netavark binary to run
44
NETAVARK=${NETAVARK:-./bin/netavark}
5+
TEST_PLUGINS=${TEST_PLUGINS:-./targets/release/examples}
56

67
TESTSDIR=${TESTSDIR:-$(dirname ${BASH_SOURCE})}
78

test/tmt/integration.fmf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require:
2+
- cargo
3+
- clippy
4+
- go-md2man
5+
- git-core
6+
- iptables
7+
- make
8+
- netavark-tests
9+
- protobuf-compiler
10+
- rustfmt
11+
12+
adjust+:
13+
- duration: 10m
14+
when: arch == aarch64
15+
16+
/validate:
17+
tag: upstream
18+
summary: Validate test
19+
test: make -C $TMT_TREE validate
20+
21+
/unit:
22+
tag: upstream
23+
summary: Unit test
24+
test: make -C $TMT_TREE unit
25+
26+
/integration:
27+
tag: [ upstream, downstream ]
28+
summary: Integration tests
29+
test: bash integration.sh
30+
environment:
31+
NETAVARK: /usr/libexec/podman/netavark
32+
TEST_PLUGINS: /usr/share/netavark/examples

test/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

test/tmt/podman.fmf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
summary: Podman tests dependent on netavark
2+
require:
3+
- netavark
4+
- podman-tests
5+
6+
tag: [upstream, downstream]
7+
8+
test: |
9+
/usr/bin/bats -t /usr/share/podman/test/system/030-run.bats
10+
/usr/bin/bats -t /usr/share/podman/test/system/075-exec.bats
11+
/usr/bin/bats -t /usr/share/podman/test/system/500-networking.bats
12+
13+
duration: 15m

0 commit comments

Comments
 (0)