Skip to content

Commit 6e98139

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. Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent d81a5d6 commit 6e98139

File tree

11 files changed

+186
-8
lines changed

11 files changed

+186
-8
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: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ packages:
1212
netavark-centos:
1313
pkg_tool: centpkg
1414
specfile_path: rpm/netavark.spec
15+
netavark-eln:
16+
specfile_path: rpm/netavark.spec
1517

1618
srpm_build_deps:
1719
- cargo
@@ -22,12 +24,21 @@ jobs:
2224
- job: copr_build
2325
trigger: pull_request
2426
packages: [netavark-fedora]
25-
notifications: &copr_build_failure_notification
26-
failure_comment:
27-
message: "Ephemeral COPR build failed. @containers/packit-build please check."
27+
#notifications: &copr_build_failure_notification
28+
# failure_comment:
29+
# message: "Ephemeral COPR build failed. @containers/packit-build please check."
30+
targets: &fedora_copr_targets
31+
- fedora-all-x86_64
32+
- fedora-all-aarch64
33+
enable_net: true
34+
35+
- job: copr_build
36+
trigger: ignore
37+
packages: [netavark-eln]
38+
#notifications: &copr_build_failure_notification
39+
# failure_comment:
40+
# message: "Ephemeral COPR build failed. @containers/packit-build please check."
2841
targets:
29-
fedora-all-x86_64: {}
30-
fedora-all-aarch64: {}
3142
fedora-eln-x86_64:
3243
additional_repos:
3344
- "https://kojipkgs.fedoraproject.org/repos/eln-build/latest/x86_64/"
@@ -39,8 +50,8 @@ jobs:
3950
- job: copr_build
4051
trigger: pull_request
4152
packages: [netavark-centos]
42-
notifications: *copr_build_failure_notification
43-
targets:
53+
#notifications: *copr_build_failure_notification
54+
targets: &centos_copr_targets
4455
- centos-stream-9-x86_64
4556
- centos-stream-9-aarch64
4657
- centos-stream-10-x86_64
@@ -59,6 +70,32 @@ jobs:
5970
project: podman-next
6071
enable_net: true
6172

73+
- job: tests
74+
trigger: pull_request
75+
packages: [netavark-fedora]
76+
#notifications:
77+
#failure_comment:
78+
# message: "TMT tests failed. @containers/packit-build please check."
79+
targets: *fedora_copr_targets
80+
tf_extra_params:
81+
environments:
82+
- artifacts:
83+
- type: repository-file
84+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
85+
86+
- job: tests
87+
trigger: pull_request
88+
packages: [netavark-centos]
89+
#notifications:
90+
#failure_comment:
91+
# message: "TMT tests failed. @containers/packit-build please check."
92+
targets: *centos_copr_targets
93+
tf_extra_params:
94+
environments:
95+
- artifacts:
96+
- type: repository-file
97+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
98+
6299
# Sync to Fedora
63100
- job: propose_downstream
64101
trigger: release

plans/main.fmf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
discover:
2+
how: fmf
3+
execute:
4+
how: tmt
5+
6+
/upstream:
7+
summary: Run tests on upstream PRs
8+
discover+:
9+
filter: tag:upstream
10+
adjust+:
11+
enabled: false
12+
when: initiator is not defined or initiator != packit
13+
14+
/downstream:
15+
summary: Run tests on bodhi / errata and dist-git PRs
16+
discover+:
17+
filter: tag:downstream
18+
adjust+:
19+
enabled: false
20+
when: initiator == packit

rpm/netavark.spec

Lines changed: 44 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
@@ -110,12 +134,23 @@ NETAVARK_DEFAULT_FW=%{default_fw} %{__make} CARGO="%{__cargo}" build
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
@@ -137,5 +172,14 @@ cd docs
137172
%{_unitdir}/%{name}-dhcp-proxy.socket
138173
%{_unitdir}/%{name}-firewalld-reload.service
139174

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

test-dhcp/tmt/main.fmf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
- cargo
5+
- clippy
6+
- go-md2man
7+
- git-core
8+
- make
9+
- netavark-tests
10+
- protobuf-compiler
11+
- rustfmt
12+
13+
adjust:
14+
duration: 10m
15+
when: arch == aarch64
16+
17+
/integration:
18+
tag: [ upstream, downstream ]
19+
summary: Integration tests
20+
test: bash test_integration.sh
21+
environment:
22+
NETAVARK: /usr/libexec/podman/netavark
23+
TEST_PLUGINS: /usr/share/netavark/examples

test-dhcp/tmt/test_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/main.fmf

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

0 commit comments

Comments
 (0)