Skip to content

Commit 1f48419

Browse files
committed
ZTS: Use QEMU for tests on Linux and FreeBSD
This commit adds functional tests for these systems: - AlmaLinux 8, AlmaLinux 9 - CentOS Stream 8, CentOS Stream 9 - Fedora 38, Fedora 39 - Debian 11, Debian 12 - FreeBSD 13, FreeBSD 14, FreeBSD 15 - Ubuntu 22.04, Ubuntu 24.04 Workflow for each operating system: - install QEMU - download cloud image for this system - start and init that image via cloud-init - start a new github action runner within qemu - do the functional testings (~4h) Signed-off-by: Tino Reichardt <[email protected]>
1 parent 78e8c1f commit 1f48419

File tree

8 files changed

+712
-74
lines changed

8 files changed

+712
-74
lines changed
Lines changed: 110 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,169 @@
11
#!/usr/bin/env bash
22

3-
# for runtime reasons we split functional testings into N parts
4-
# - use a define to check for missing tarfiles
5-
FUNCTIONAL_PARTS="4"
3+
function output() {
4+
echo -e $* >> "out-$logfile.md"
5+
}
66

7-
ZTS_REPORT="tests/test-runner/bin/zts-report.py"
8-
chmod +x $ZTS_REPORT
7+
function outfile() {
8+
cat "$1" >> "out-$logfile.md"
9+
}
910

10-
function output() {
11-
echo -e $* >> Summary.md
11+
function send2github() {
12+
test -f "$1" && dd if="$1" bs=999k count=1 >> $GITHUB_STEP_SUMMARY
1213
}
1314

1415
function error() {
1516
output ":bangbang: $* :bangbang:\n"
1617
}
1718

18-
# this function generates the real summary
19-
# - expects a logfile "log" in current directory
19+
# generate summary of one test
2020
function generate() {
2121
# we issued some error already
2222
test ! -s log && return
2323

24-
# for overview and zts-report
25-
cat log | grep '^Test' > list
24+
######################################################
25+
# input:
26+
# - log -> full debug output
27+
# - results -> full list with summary in the end
28+
######################################################
29+
# output:
30+
# - info.txt -> short summary list (zts-report)
31+
# - list.txt -> full list, but without debugging
32+
# - debug.txt -> full list with debugging info
33+
######################################################
34+
35+
if [ -s results ]; then
36+
cat results | grep '^Test[: ]' > list.txt
37+
cat results | grep -v '^Test[: ]' > info.txt
38+
else
39+
cat log | grep '^Test[: ]' > list.txt
40+
./zts-report.py --no-maybes ./list.txt > info.txt
41+
fi
2642

2743
# error details
2844
awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }
29-
/\[SKIP\]|\[PASS\]/{ show=0; } show' log > err
45+
/\[SKIP\]|\[PASS\]/{ show=0; } show' log > debug.txt
3046

31-
# summary of errors
32-
if [ -s err ]; then
47+
# headline of this summary
48+
output "\n## $headline\n"
49+
50+
if [ -s info.txt ]; then
3351
output "<pre>"
34-
$ZTS_REPORT --no-maybes ./list >> Summary.md
52+
outfile info.txt
3553
output "</pre>"
36-
37-
# generate seperate error logfile
38-
ERRLOGS=$((ERRLOGS+1))
39-
errfile="err-$ERRLOGS.md"
40-
echo -e "\n## $headline (debugging)\n" >> $errfile
41-
echo "<details><summary>Error Listing - with dmesg and dbgmsg</summary><pre>" >> $errfile
42-
dd if=err bs=999k count=1 >> $errfile
43-
echo "</pre></details>" >> $errfile
4454
else
4555
output "All tests passed :thumbsup:"
4656
fi
4757

48-
output "<details><summary>Full Listing</summary><pre>"
49-
cat list >> Summary.md
50-
output "</pre></details>"
58+
if [ -s uname.txt ]; then
59+
output "<details><summary>Uname -a</summary><pre>"
60+
outfile uname.txt
61+
output "</pre></details>"
62+
fi
63+
64+
if [ -s dmesg-prerun.txt ]; then
65+
output "<details><summary>Dmesg - prerun</summary><pre>"
66+
outfile dmesg-prerun.txt
67+
output "</pre></details>"
68+
fi
69+
70+
if [ -s dmesg-module-load.txt ]; then
71+
output "<details><summary>Dmesg - module loading</summary><pre>"
72+
outfile dmesg-module-load.txt
73+
output "</pre></details>"
74+
fi
75+
76+
if [ -s list.txt ]; then
77+
output "<details><summary>List of all tests</summary><pre>"
78+
outfile list.txt
79+
output "</pre></details>"
80+
fi
81+
82+
if [ -s debug.txt ]; then
83+
output "<details><summary>Debug list with dmesg and dbgmsg</summary><pre>"
84+
outfile debug.txt
85+
output "</pre></details>"
86+
fi
5187

5288
# remove tmp files
53-
rm -f err list log
89+
rm -f log results *.txt
90+
logfile=$((logfile+1))
5491
}
5592

5693
# check tarfiles and untar
57-
function check_tarfile() {
94+
function my_untar() {
5895
if [ -f "$1" ]; then
5996
tar xf "$1" || error "Tarfile $1 returns some error"
6097
else
6198
error "Tarfile $1 not found"
6299
fi
63100
}
64101

65-
# check logfile and concatenate test results
66-
function check_logfile() {
102+
# check file and copy
103+
function my_copy() {
67104
if [ -f "$1" ]; then
68-
cat "$1" >> log
105+
cat "$1" >> "$2"
69106
else
70-
error "Logfile $1 not found"
107+
error "File $1 not found"
71108
fi
72109
}
73110

74-
# sanity
75-
function summarize_s() {
76-
headline="$1"
77-
output "\n## $headline\n"
111+
# sanity checks on ubuntu runner
112+
function summarize_sanity() {
113+
headline="Sanity Tests Ubuntu $1"
78114
rm -rf testfiles
79-
check_tarfile "$2/sanity.tar"
80-
check_logfile "testfiles/log"
115+
my_untar "Logs-$1-sanity/sanity.tar"
116+
my_copy "testfiles/log" log
81117
generate
82118
}
83119

84-
# functional
85-
function summarize_f() {
86-
headline="$1"
87-
output "\n## $headline\n"
120+
# functional on ubuntu runner matrix
121+
function summarize_functional() {
122+
headline="Functional Tests Ubuntu $1"
88123
rm -rf testfiles
89-
for i in $(seq 1 $FUNCTIONAL_PARTS); do
90-
tarfile="$2-part$i/part$i.tar"
91-
check_tarfile "$tarfile"
92-
check_logfile "testfiles/log"
124+
for i in $(seq 1 4); do
125+
tarfile="Logs-$1-functional-part$i/part$i.tar"
126+
my_untar "$tarfile"
127+
my_copy "testfiles/log" log
93128
done
94129
generate
95130
}
96131

132+
# functional tests via qemu
133+
function summarize_qemu() {
134+
for tarfile in Logs-functional*/qemu-*.tar; do
135+
rm -rf current
136+
my_untar "$tarfile"
137+
osname=`cat osname.txt`
138+
headline="Functional Tests: $osname"
139+
my_copy "current/log" log
140+
my_copy "current/results" results
141+
generate
142+
done
143+
}
144+
97145
# https://docs.github.com/en/[email protected]/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits
98146
# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB.
99147
# [ ] can not show all error findings here
100148
# [x] split files into smaller ones and create additional steps
101149

102-
ERRLOGS=0
103-
if [ ! -f Summary/Summary.md ]; then
104-
# first call, we do the default summary (~500k)
105-
echo -n > Summary.md
106-
summarize_s "Sanity Tests Ubuntu 20.04" Logs-20.04-sanity
107-
summarize_s "Sanity Tests Ubuntu 22.04" Logs-22.04-sanity
108-
summarize_f "Functional Tests Ubuntu 20.04" Logs-20.04-functional
109-
summarize_f "Functional Tests Ubuntu 22.04" Logs-22.04-functional
110-
111-
cat Summary.md >> $GITHUB_STEP_SUMMARY
112-
mkdir -p Summary
113-
mv *.md Summary
150+
# first call, generate all summaries
151+
if [ ! -f out-0.md ]; then
152+
# create ./zts-report.py for generate()
153+
TEMPLATE="tests/test-runner/bin/zts-report.py.in"
154+
cat $TEMPLATE| sed -e 's|@PYTHON_SHEBANG@|python3|' > ./zts-report.py
155+
chmod +x ./zts-report.py
156+
157+
logfile="0"
158+
summarize_sanity "20.04"
159+
summarize_sanity "22.04"
160+
summarize_functional "20.04"
161+
summarize_functional "22.04"
162+
summarize_qemu
163+
164+
send2github out-0.md
114165
else
115-
# here we get, when errors where returned in first call
116-
test -f Summary/err-$1.md && cat Summary/err-$1.md >> $GITHUB_STEP_SUMMARY
166+
send2github out-$1.md
117167
fi
118168

119169
exit 0
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
3+
#####################################################
4+
# 4) configure and build openzfs modules #
5+
#####################################################
6+
7+
set -eu
8+
9+
function freebsd() {
10+
echo "##[group]Autogen.sh"
11+
MAKE="gmake" ./autogen.sh
12+
echo "##[endgroup]"
13+
14+
echo "##[group]Configure"
15+
MAKE="gmake" ./configure \
16+
--prefix=/usr/local \
17+
--with-libintl-prefix=/usr/local \
18+
--enable-debug \
19+
--enable-debuginfo
20+
echo "##[endgroup]"
21+
22+
echo "##[group]Build"
23+
gmake -j`sysctl -n hw.ncpu`
24+
echo "##[endgroup]"
25+
26+
echo "##[group]Install"
27+
sudo gmake install
28+
echo "##[endgroup]"
29+
30+
echo "##[group]Load modules"
31+
# when freebsd zfs is loaded, unload it:
32+
kldstat -n zfs 2>/dev/null && kldunload zfs
33+
sudo dmesg -c > /var/tmp/dmesg-prerun.txt
34+
sudo -E ./scripts/zfs.sh
35+
sudo dmesg
36+
sudo dmesg -c > /var/tmp/dmesg-module-load.txt
37+
echo "Loaded module: "
38+
kldstat -n openzfs
39+
echo "##[endgroup]"
40+
}
41+
42+
function linux_forceload() {
43+
echo "Need to force the module loading!"
44+
# -f tells modprobe to ignore wrong version numbers
45+
sudo modprobe -v -f spl || echo "!! Loading module spl is failing !!"
46+
sudo modprobe -v -f zfs || echo "!! Loading module zfs is failing !!"
47+
}
48+
49+
function linux() {
50+
echo "##[group]Autogen.sh"
51+
./autogen.sh
52+
echo "##[endgroup]"
53+
54+
echo "##[group]Configure"
55+
./configure \
56+
--prefix=/usr \
57+
--enable-debug \
58+
--enable-debuginfo
59+
echo "##[endgroup]"
60+
61+
echo "##[group]Build"
62+
make -j$(nproc)
63+
echo "##[endgroup]"
64+
65+
echo "##[group]Install"
66+
sudo make install
67+
echo "##[endgroup]"
68+
69+
echo "##[group]Load modules"
70+
sudo dmesg -c > /var/tmp/dmesg-prerun.txt
71+
sudo -E ./scripts/zfs.sh
72+
test -d /proc/spl/kstat/zfs || linux_forceload
73+
sudo dmesg
74+
sudo dmesg -c > /var/tmp/dmesg-module-load.txt
75+
echo "##[endgroup]"
76+
}
77+
78+
export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
79+
case "$1" in
80+
freebsd*)
81+
freebsd
82+
;;
83+
*)
84+
linux
85+
;;
86+
esac

0 commit comments

Comments
 (0)