Skip to content

Commit 702642f

Browse files
mcmilktonyhutter
andcommitted
ZTS: Use QEMU for tests on Linux and FreeBSD
This commit adds functional tests for these systems: - AlmaLinux 8, AlmaLinux 9 - ArchLinux - CentOS Stream 9 - Fedora 39, Fedora 40 - Debian 11, Debian 12 - FreeBSD 13, FreeBSD 14, FreeBSD 15 - Ubuntu 22.04, Ubuntu 24.04 Workflow for each operating system: - install QEMU on the github runner - download current cloud image - start and init that image via cloud-init - install deps and poweroff system - start system and build openzfs and then poweroff again - clone the system and start 3 qemu machines for tests - use trimable virtual disks (3x 2GB) - do the functional testings in < 3h Signed-off-by: Tino Reichardt <[email protected]> Co-authored-by: Tony Hutter <[email protected]>
1 parent c98295e commit 702642f

File tree

16 files changed

+1133
-391
lines changed

16 files changed

+1133
-391
lines changed

.github/workflows/scripts/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
Workflow for each operating system:
3+
- install QEMU on the github runner
4+
- download current cloud image
5+
- start and init that image via cloud-init
6+
- install deps and poweroff system
7+
- start system and build openzfs and then poweroff again
8+
- clone the system and start 4 qemu workers for the testings (4x 3GB RAM)
9+
- use trimable virtual disks (3x 1GB) for each testing system
10+
- do the functional testings < 3h for each os
Lines changed: 167 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,195 @@
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"
6-
7-
ZTS_REPORT="tests/test-runner/bin/zts-report.py"
8-
chmod +x $ZTS_REPORT
3+
######################################################################
4+
# generate github summary page of all the testings
5+
# /tr 2024-06-17
6+
######################################################################
97

108
function output() {
11-
echo -e $* >> Summary.md
12-
}
13-
14-
function error() {
15-
output ":bangbang: $* :bangbang:\n"
9+
echo -e $* >> "out-$logfile.md"
1610
}
1711

18-
# this function generates the real summary
19-
# - expects a logfile "log" in current directory
20-
function generate() {
21-
# we issued some error already
22-
test ! -s log && return
23-
24-
# for overview and zts-report
25-
cat log | grep '^Test' > list
26-
27-
# error details
28-
awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; }
29-
/\[SKIP\]|\[PASS\]/{ show=0; } show' log > err
30-
31-
# summary of errors
32-
if [ -s err ]; then
33-
output "<pre>"
34-
$ZTS_REPORT --no-maybes ./list >> Summary.md
35-
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
44-
else
45-
output "All tests passed :thumbsup:"
12+
function outfile() {
13+
if [ -f $1 ]; then
14+
CUR=`stat --printf="%s" "out-$logfile.md"`
15+
ADD=`stat --printf="%s" "$1"`
16+
X=$((CUR+ADD))
17+
if [ $X -lt $((1024*1023)) ]; then
18+
cat "$1" >> "out-$logfile.md"
19+
else
20+
logfile=$((logfile+1))
21+
cat "$1" >> "out-$logfile.md"
22+
fi
4623
fi
47-
48-
output "<details><summary>Full Listing</summary><pre>"
49-
cat list >> Summary.md
50-
output "</pre></details>"
51-
52-
# remove tmp files
53-
rm -f err list log
5424
}
5525

56-
# check tarfiles and untar
57-
function check_tarfile() {
58-
if [ -f "$1" ]; then
59-
tar xf "$1" || error "Tarfile $1 returns some error"
60-
else
61-
error "Tarfile $1 not found"
62-
fi
26+
function showfile() {
27+
filename="$1"
28+
headline="$2"
29+
echo "<details><summary>$headline</summary><pre>" > tmp
30+
cat $filename >> tmp
31+
echo "</pre></details>" >> tmp
32+
outfile tmp
33+
rm -f tmp
6334
}
6435

65-
# check logfile and concatenate test results
66-
function check_logfile() {
67-
if [ -f "$1" ]; then
68-
cat "$1" >> log
69-
else
70-
error "Logfile $1 not found"
71-
fi
36+
function send2github() {
37+
test -f "$1" && dd if="$1" bs=1023k count=1 >> $GITHUB_STEP_SUMMARY
7238
}
7339

74-
# sanity
75-
function summarize_s() {
76-
headline="$1"
40+
# generate summary of one test
41+
function generate() {
42+
VMs=3
43+
####################################################################
44+
# osname.txt -> used for headline
45+
# disk-before.txt -> used together with uname
46+
# disk-afterwards.txt -> used together with uname
47+
# vm{1,2,3}log.txt (colored, used when current/log isn't there)
48+
####################################################################
49+
# vm{1,2,3}/uname.txt -> used once
50+
# vm{1,2,3}/build-stderr.txt -> used once
51+
# vm{1,2,3}/dmesg-prerun.txt -> used once
52+
# vm{1,2,3}/dmesg-module-load.txt -> used once
53+
# vm{1,2,3}/console.txt -> all 3 used
54+
####################################################################
55+
# vm{1,2,3}/current/log -> if not there, kernel panic loading
56+
# vm{1,2,3}/current/results -> if not there, kernel panic testings
57+
# vm{1,2,3}/exitcode.txt
58+
####################################################################
59+
60+
# headline of this summary
7761
output "\n## $headline\n"
78-
rm -rf testfiles
79-
check_tarfile "$2/sanity.tar"
80-
check_logfile "testfiles/log"
81-
generate
62+
63+
for i in `seq 1 $VMs`; do
64+
if [ -s vm$i/uname.txt ]; then
65+
output "<pre>"
66+
outfile vm$i/uname.txt
67+
output "\nVM disk usage before:"
68+
outfile disk-afterwards.txt
69+
output "\nand afterwards:"
70+
outfile disk-before.txt
71+
output "</pre>"
72+
break
73+
fi
74+
done
75+
76+
for i in `seq 1 $VMs`; do
77+
if [ -s vm$i/build-stderr.txt ]; then
78+
showfile "vm$i/build-stderr.txt" "Module build (stderr output)"
79+
break
80+
fi
81+
done
82+
83+
for i in `seq 1 $VMs`; do
84+
if [ -s vm$i/dmesg-prerun.txt ]; then
85+
showfile "vm$i/dmesg-prerun.txt" "Dmesg output - before tests"
86+
break
87+
fi
88+
done
89+
90+
for i in `seq 1 $VMs`; do
91+
if [ -s vm$i/dmesg-module-load.txt ]; then
92+
showfile "vm$i/dmesg-module-load.txt" "Dmesg output - module loading"
93+
break
94+
fi
95+
done
96+
97+
for i in `seq 1 $VMs`; do
98+
log="vm$i/current/log"
99+
if [ ! -f $log ]; then
100+
output ":exclamation: Logfile of vm$i tests is missing :exclamation:"
101+
102+
# some out may be generated
103+
if [ -s vm${i}log.txt ]; then
104+
cat vm${i}log.txt | \
105+
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > "vm${i}log"
106+
showfile "vm${i}log" "Generated tests output of vm$i"
107+
fi
108+
109+
# output the console contents and continue with next vm
110+
if [ -s "vm$i/console.txt" ]; then
111+
cat "vm$i/console.txt" | \
112+
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > "vm${i}log"
113+
showfile "vm${i}log" "Serial console output of vm$i"
114+
fi
115+
116+
rm -f "vm${i}log"
117+
continue
118+
fi
119+
120+
cat $log | grep '^Test[: ]' > tests.txt
121+
results="vm$i/current/results"
122+
if [ ! -s "$results" ]; then
123+
output ":exclamation: Results file of vm$i tests is missing :exclamation:"
124+
# generate results file from log
125+
./zts-report.py --no-maybes ./tests.txt > $results
126+
# Running Time: 01:30:09
127+
# Running Time: not finished!!
128+
echo -e "\nRunning Time:\tKernel panic!" >> $results
129+
fi
130+
cat $results | awk '/Results Summary/ { show=1; print; next; } show' > summary.txt
131+
runtime=`cat $results | grep '^Running Time:' | cut -f2`
132+
133+
awk '/\[FAIL\]|\[KILLED\]/{ show=1; print; next; } \
134+
/\[SKIP\]|\[PASS\]/{ show=0; } show' $log > debug.txt
135+
136+
output "\n### Tests on vm$i ($runtime)\n\n"
137+
138+
if [ -s summary.txt ]; then
139+
showfile "summary.txt" "Summary of all tests"
140+
fi
141+
142+
if [ -s "vm$i/console.txt" ]; then
143+
showfile "vm$i/console.txt" "Serial console output"
144+
fi
145+
146+
if [ -s tests.txt ]; then
147+
showfile "tests.txt" "List of all tests"
148+
fi
149+
150+
MAX="300"
151+
if [ -s debug.txt ]; then
152+
S=`stat --printf="%s" "debug.txt"`
153+
if [ $S -gt $((1024*$MAX)) ]; then
154+
dd if=debug.txt of=debug.txt2 count=$MAX bs=1024 2>/dev/null
155+
mv -f debug.txt2 debug.txt
156+
echo "..." >> debug.txt
157+
echo "!!! THIS FILE IS BIGGER !!!" >> debug.txt
158+
echo "Please download the zip archiv for full content!" >> debug.txt
159+
fi
160+
showfile "debug.txt" "Debug list for failed tests (vm$i, $runtime)"
161+
fi
162+
done
82163
}
83164

84-
# functional
85-
function summarize_f() {
86-
headline="$1"
87-
output "\n## $headline\n"
88-
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"
165+
# functional tests via qemu
166+
function summarize() {
167+
for tarfile in Logs-functional-*/qemu-*.tar; do
168+
rm -rf vm* *.txt
169+
tar xf "$tarfile"
170+
osname=`cat osname.txt`
171+
headline="Functional Tests: $osname"
172+
generate
93173
done
94-
generate
95174
}
96175

97176
# https://docs.github.com/en/[email protected]/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits
98177
# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB.
99178
# [ ] can not show all error findings here
100179
# [x] split files into smaller ones and create additional steps
101180

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
181+
# first call, generate all summaries
182+
if [ ! -f out-0.md ]; then
183+
# create ./zts-report.py for generate()
184+
TEMPLATE="tests/test-runner/bin/zts-report.py.in"
185+
cat $TEMPLATE| sed -e 's|@PYTHON_SHEBANG@|python3|' > ./zts-report.py
186+
chmod +x ./zts-report.py
187+
188+
logfile="0"
189+
summarize
190+
send2github out-0.md
114191
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
192+
send2github out-$1.md
117193
fi
118194

119195
exit 0
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
######################################################################
4+
# 1) setup the action runner to start some qemu instance
5+
######################################################################
6+
7+
set -eu
8+
9+
# docker isn't needed, free some memory
10+
sudo systemd-run --wait docker system prune --force --all --volumes
11+
sudo systemctl stop docker.socket
12+
sudo apt-get remove docker-ce-cli docker-ce podman
13+
14+
# remove unneeded things
15+
sudo apt-get remove google-chrome-stable snapd
16+
17+
# install needed packages
18+
sudo apt-get update
19+
sudo apt-get install axel cloud-image-utils daemonize guestfs-tools \
20+
virt-manager linux-modules-extra-`uname -r`
21+
22+
# remove unused software
23+
df -h /
24+
sudo systemd-run --wait rm -rf \
25+
/opt/* \
26+
/usr/local/* \
27+
/usr/share/az* \
28+
/usr/share/dotnet \
29+
/usr/share/gradle* \
30+
/usr/share/miniconda \
31+
/usr/share/swift \
32+
/var/lib/gems \
33+
/var/lib/mysql \
34+
/var/lib/snapd
35+
36+
# disk usage afterwards
37+
sudo df -h /
38+
sudo df -h /mnt
39+
sudo fstrim -a
40+
41+
# generate ssh keys
42+
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -q -N ""

0 commit comments

Comments
 (0)