Skip to content

Commit 31bc099

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 f17d903 commit 31bc099

File tree

12 files changed

+189
-17
lines changed

12 files changed

+189
-17
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: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
- job: copr_build
2525
trigger: pull_request
2626
packages: [netavark-fedora]
27-
notifications: &copr_build_failure_notification
28-
failure_comment:
29-
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."
3030
targets:
3131
fedora-all-x86_64: {}
3232
fedora-all-aarch64: {}
@@ -41,8 +41,8 @@ jobs:
4141
- job: copr_build
4242
trigger: pull_request
4343
packages: [netavark-centos]
44-
notifications: *copr_build_failure_notification
45-
targets:
44+
#notifications: *copr_build_failure_notification
45+
targets: &centos_targets
4646
- centos-stream-9-x86_64
4747
- centos-stream-9-aarch64
4848
- centos-stream-10-x86_64
@@ -52,8 +52,8 @@ jobs:
5252
- job: copr_build
5353
trigger: pull_request
5454
packages: [netavark-rhel]
55-
notifications: *copr_build_failure_notification
56-
targets:
55+
#notifications: *copr_build_failure_notification
56+
targets: &rhel_targets
5757
- epel-9-x86_64
5858
- epel-9-aarch64
5959
enable_net: true
@@ -70,6 +70,74 @@ jobs:
7070
project: podman-next
7171
enable_net: true
7272

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-all
81+
tf_extra_params:
82+
environments:
83+
- artifacts:
84+
- type: repository-file
85+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
86+
87+
- job: tests
88+
trigger: pull_request
89+
packages: [netavark-centos]
90+
#notifications:
91+
#failure_comment:
92+
# message: "TMT tests failed. @containers/packit-build please check."
93+
targets:
94+
# TODO: enable centos-stream-9 after
95+
# https://github.com/fedora-copr/copr/issues/3334 is fixed
96+
- centos-stream-10
97+
tf_extra_params:
98+
environments:
99+
- artifacts:
100+
- type: repository-file
101+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
102+
103+
- job: tests
104+
trigger: pull_request
105+
packages: [netavark-centos]
106+
#notifications:
107+
#failure_comment:
108+
# message: "TMT tests failed. @containers/packit-build please check."
109+
targets:
110+
# TODO: fold centos-stream-9 into previous job after
111+
# https://github.com/fedora-copr/copr/issues/3334 is fixed
112+
- centos-stream-9
113+
tf_extra_params:
114+
environments:
115+
- artifacts:
116+
- type: repository-file
117+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-9/rhcontainerbot-podman-next-centos-stream-9.repo
118+
- type: repository-file
119+
id: https://src.fedoraproject.org/rpms/epel-release/raw/epel9/f/epel.repo
120+
121+
- job: tests
122+
trigger: pull_request
123+
packages: [netavark-rhel]
124+
#notifications:
125+
#failure_comment:
126+
# message: "TMT tests failed. @containers/packit-build please check."
127+
targets:
128+
epel-9-x86_64:
129+
distros: [RHEL-9.4.0-Nightly,RHEL-9-Nightly]
130+
epel-9-aarch64:
131+
distros: [RHEL-9.4.0-Nightly,RHEL-9-Nightly]
132+
use_internal_tf: true
133+
tf_extra_params:
134+
environments:
135+
- artifacts:
136+
- type: repository-file
137+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/epel-$releasever/rhcontainerbot-podman-next-epel-$releasever.repo
138+
- type: repository-file
139+
id: https://src.fedoraproject.org/rpms/epel-release/raw/epel9/f/epel.repo
140+
73141
# Sync to Fedora
74142
- job: propose_downstream
75143
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/all.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
@@ -83,6 +83,13 @@ Its features include:
8383
* Support for IPv4 and IPv6
8484
* Support for container DNS resolution via aardvark-dns.
8585

86+
%package tests
87+
Summary: Tests for %{name}
88+
Requires: %{name} = %{epoch}:%{version}-%{release}
89+
90+
%description tests
91+
%{summary}
92+
8693
%prep
8794
%autosetup -Sgit %{name}-%{version}
8895
# Following steps are only required on environments like koji which have no
@@ -105,12 +112,18 @@ NETAVARK_DEFAULT_FW=%{default_fw} %{__make} CARGO="%{__cargo}" build
105112
%cargo_vendor_manifest
106113
%endif
107114

115+
# Build examples package for tests
116+
%{__make} CARGO="%{__cargo}" examples
117+
108118
cd docs
109119
%{__make}
110120

111121
%install
112122
%{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} install
113123

124+
install -d -p %{buildroot}%{_datadir}/%{name}/test/examples
125+
cp -pav targets/release/examples/* %{buildroot}%{_datadir}/%{name}/test/examples
126+
114127
%preun
115128
%systemd_preun %{name}-dhcp-proxy.service
116129
%systemd_preun %{name}-firewalld-reload.service
@@ -132,6 +145,12 @@ cd docs
132145
%{_unitdir}/%{name}-dhcp-proxy.socket
133146
%{_unitdir}/%{name}-firewalld-reload.service
134147

148+
%files tests
149+
%dir %{_datadir}/%{name}
150+
%dir %{_datadir}/%{name}/test
151+
%dir %{_datadir}/%{name}/test/examples
152+
%{_datadir}/%{name}/test/examples/*
153+
135154
%changelog
136155
%if %{defined autochangelog}
137156
%autochangelog

src/dhcp_proxy/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ pub mod g_rpc {
4040
impl From<DhcpV4Lease> for Lease {
4141
fn from(l: DhcpV4Lease) -> Lease {
4242
// Since these fields are optional as per mozim. Match them first and then set them
43-
let domain_name = match l.domain_name {
44-
None => String::from(""),
45-
Some(l) => l,
46-
};
43+
let domain_name = l.domain_name.unwrap_or_default();
4744
let mtu = l.mtu.unwrap_or(0) as u32;
4845

4946
Lease {

test-dhcp/001-basic.bats

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@
55

66
load helpers
77

8-
@test "simple example" {
9-
10-
}
11-
8+
@test "simple example" {}

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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
- make
6+
- protobuf-compiler
7+
8+
adjust:
9+
duration: 10m
10+
when: arch == aarch64
11+
12+
/validate:
13+
tag: upstream
14+
summary: Validate test
15+
test: make -C ../.. validate
16+
17+
/unit:
18+
tag: upstream
19+
summary: Unit test
20+
test: make -C ../.. unit
21+
22+
/integration:
23+
tag: [ upstream, downstream ]
24+
summary: Integration tests
25+
test: bash test_integration.sh

test/tmt/test_integration.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
cat /etc/redhat-release
6+
7+
# Remove testing-farm repos if they exist because they interfere with the
8+
# podman-next copr. The default distro repos will not be removed and can be
9+
# used wherever relevant.
10+
rm -f /etc/yum.repos.d/tag-repository.repo
11+
12+
# Install dependencies for running tests
13+
dnf -y install \
14+
bats \
15+
bind-utils \
16+
bridge-utils \
17+
cargo \
18+
clippy \
19+
dbus-daemon \
20+
dnsmasq \
21+
firewalld \
22+
go-md2man \
23+
iptables \
24+
jq \
25+
make \
26+
net-tools \
27+
nftables \
28+
nmap-ncat \
29+
rustfmt
30+
31+
rpm -q aardvark-dns cargo netavark
32+
33+
# Run tests
34+
make -C ../.. NETAVARK=/usr/libexec/podman/netavark TEST_PLUGINS=/usr/share/netavark/test/examples integration

0 commit comments

Comments
 (0)