Skip to content

Commit 0ad34bb

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 d5e44b5 commit 0ad34bb

File tree

12 files changed

+171
-17
lines changed

12 files changed

+171
-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: 54 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,53 @@ 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: *centos_targets
94+
tf_extra_params:
95+
environments:
96+
- artifacts:
97+
- type: repository-file
98+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
99+
100+
- job: tests
101+
trigger: pull_request
102+
packages: [netavark-rhel]
103+
#notifications:
104+
#failure_comment:
105+
# message: "TMT tests failed. @containers/packit-build please check."
106+
targets:
107+
epel-9-x86_64:
108+
distros: [RHEL-9.4.0-Nightly,RHEL-9-Nightly]
109+
epel-9-aarch64:
110+
distros: [RHEL-9.4.0-Nightly,RHEL-9-Nightly]
111+
use_internal_tf: true
112+
tf_extra_params:
113+
environments:
114+
- artifacts:
115+
- type: repository-file
116+
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/epel-$releasever/rhcontainerbot-podman-next-epel-$releasever.repo
117+
- type: repository-file
118+
id: https://src.fedoraproject.org/rpms/epel-release/raw/epel9/f/epel.repo
119+
73120
# Sync to Fedora
74121
- job: propose_downstream
75122
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
@@ -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

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

0 commit comments

Comments
 (0)