Skip to content

Commit 92a4f0b

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 5ab4cb1 commit 92a4f0b

File tree

10 files changed

+158
-9
lines changed

10 files changed

+158
-9
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
src/proto-build/netavark_proxy.rs
99
contrib/systemd/*/*.service
1010
.vscode*
11+
rpm/RPMS
12+
rpm/SRPMS
13+
rpm/*.tar.gz

.packit.yaml

Lines changed: 49 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:
31+
- fedora-all-x86_64
32+
- fedora-all-aarch64
33+
enable_net: true
34+
35+
- job: copr_build
36+
trigger: pull_request
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_targets
4455
- centos-stream-9-x86_64
4556
- centos-stream-9-aarch64
4657
- centos-stream-10-x86_64
@@ -59,6 +70,37 @@ 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:
80+
- fedora-development
81+
- fedora-latest
82+
- fedora-latest-stable
83+
tf_extra_params:
84+
environments:
85+
- artifacts:
86+
- type: repository-file
87+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
88+
89+
- job: tests
90+
trigger: pull_request
91+
packages: [netavark-centos]
92+
#notifications:
93+
#failure_comment:
94+
# message: "TMT tests failed. @containers/packit-build please check."
95+
targets: *centos_targets
96+
tf_extra_params:
97+
environments:
98+
- artifacts:
99+
- type: repository-file
100+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
101+
- type: repository-file
102+
id: https://src.fedoraproject.org/rpms/epel-release/raw/epel$releasever/f/epel.repo
103+
62104
# Sync to Fedora
63105
- job: propose_downstream
64106
trigger: release

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ build_netavark: bin $(CARGO_TARGET_DIR)
5959

6060
.PHONY: examples
6161
examples: bin $(CARGO_TARGET_DIR)
62-
cargo build --examples $(release)
62+
$(CARGO) build --examples $(release)
6363

6464
.PHONY: crate-publish
6565
crate-publish:
@@ -122,7 +122,14 @@ unit: $(CARGO_TARGET_DIR)
122122
$(CARGO) test
123123

124124
.PHONY: integration
125+
# The TEST_PLUGINS envvar is used by bats to specify path to test-plugins
126+
# directory
127+
ifdef TEST_PLUGINS
128+
$(info Skipping examples build as TEST_PLUGINS is set)
129+
integration: $(CARGO_TARGET_DIR)
130+
else
125131
integration: $(CARGO_TARGET_DIR) examples
132+
endif
126133
# needs to be run as root or with podman unshare --rootless-netns
127134
bats test/
128135
bats test-dhcp/

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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ Its features include:
8888
* Support for IPv4 and IPv6
8989
* Support for container DNS resolution via aardvark-dns.
9090

91+
%package tests
92+
Summary: Tests for %{name}
93+
Requires: %{name} = %{epoch}:%{version}-%{release}
94+
95+
%description tests
96+
%{summary}
97+
9198
%prep
9299
%autosetup -Sgit %{name}-%{version}
93100
# Following steps are only required on environments like koji which have no
@@ -110,12 +117,18 @@ NETAVARK_DEFAULT_FW=%{default_fw} %{__make} CARGO="%{__cargo}" build
110117
%cargo_vendor_manifest
111118
%endif
112119

120+
# Build examples package for tests
121+
%{__make} CARGO="%{__cargo}" examples
122+
113123
cd docs
114124
%{__make}
115125

116126
%install
117127
%{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} install
118128

129+
install -d -p %{buildroot}%{_datadir}/%{name}/test/examples
130+
cp -pav targets/release/examples/* %{buildroot}%{_datadir}/%{name}/test/examples
131+
119132
%preun
120133
%systemd_preun %{name}-dhcp-proxy.service
121134
%systemd_preun %{name}-firewalld-reload.service
@@ -137,6 +150,12 @@ cd docs
137150
%{_unitdir}/%{name}-dhcp-proxy.socket
138151
%{_unitdir}/%{name}-firewalld-reload.service
139152

153+
%files tests
154+
%dir %{_datadir}/%{name}
155+
%dir %{_datadir}/%{name}/test
156+
%dir %{_datadir}/%{name}/test/examples
157+
%{_datadir}/%{name}/test/examples/*
158+
140159
%changelog
141160
%if %{defined autochangelog}
142161
%autochangelog

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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
- bats
5+
- bind-utils
6+
- bridge-utils
7+
- cargo
8+
- clippy
9+
- dbus-daemon
10+
- dnsmasq
11+
- firewalld
12+
- go-md2man
13+
- git-core
14+
- iptables
15+
- jq
16+
- make
17+
- net-tools
18+
- nftables
19+
- nmap-ncat
20+
- protobuf-compiler
21+
- rustfmt
22+
23+
adjust:
24+
duration: 10m
25+
when: arch == aarch64
26+
27+
/validate:
28+
tag: upstream
29+
summary: Validate test
30+
test: make -C ../.. validate
31+
32+
/unit:
33+
tag: upstream
34+
summary: Unit test
35+
test: make -C ../.. unit
36+
37+
/integration:
38+
tag: [ upstream, downstream ]
39+
summary: Integration tests
40+
test: bash test_integration.sh

test/tmt/test_integration.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
# Remove testing-farm repos if they exist because they interfere with the
6+
# podman-next copr. The default distro repos will not be removed and can be
7+
# used wherever relevant.
8+
rm -f /etc/yum.repos.d/tag-repository.repo
9+
10+
# Install dependencies for running tests
11+
dnf -y update aardvark-dns
12+
13+
rpm -q aardvark-dns cargo netavark
14+
15+
# Run tests
16+
make -C ../.. NETAVARK=/usr/libexec/podman/netavark TEST_PLUGINS=/usr/share/netavark/test/examples integration

0 commit comments

Comments
 (0)