Skip to content

Commit

Permalink
ZTS: Use QEMU for tests on Linux and FreeBSD
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mcmilk committed Jan 29, 2024
1 parent 78e8c1f commit b83d72e
Show file tree
Hide file tree
Showing 8 changed files with 653 additions and 36 deletions.
79 changes: 56 additions & 23 deletions .github/workflows/scripts/generate-summary.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env bash

# for runtime reasons we split functional testings into N parts
# - use a define to check for missing tarfiles
FUNCTIONAL_PARTS="4"

ZTS_REPORT="tests/test-runner/bin/zts-report.py"
chmod +x $ZTS_REPORT

function output() {
echo -e $* >> Summary.md
}
Expand All @@ -16,8 +9,8 @@ function error() {
}

# this function generates the real summary
# - expects a logfile "log" in current directory
function generate() {

# we issued some error already
test ! -s log && return

Expand All @@ -31,7 +24,7 @@ function generate() {
# summary of errors
if [ -s err ]; then
output "<pre>"
$ZTS_REPORT --no-maybes ./list >> Summary.md
./zts-report.py --no-maybes ./list >> Summary.md
output "</pre>"

# generate seperate error logfile
Expand All @@ -45,12 +38,30 @@ function generate() {
output "All tests passed :thumbsup:"
fi

if [ -s uname.txt ]; then
output "<details><summary>Uname -a</summary><pre>"
cat uname.txt >> Summary.md
output "</pre></details>"
fi

if [ -s dmesg-prerun.txt ]; then
output "<details><summary>Dmesg - prerun</summary><pre>"
cat dmesg-prerun.txt >> Summary.md
output "</pre></details>"
fi

if [ -s dmesg-module-load ]; then
output "<details><summary>Dmesg - module loading</summary><pre>"
cat dmesg-module-load.txt >> Summary.md
output "</pre></details>"
fi

output "<details><summary>Full Listing</summary><pre>"
cat list >> Summary.md
output "</pre></details>"

# remove tmp files
rm -f err list log
rm -f err list log *.txt
}

# check tarfiles and untar
Expand All @@ -71,29 +82,42 @@ function check_logfile() {
fi
}

# sanity
function summarize_s() {
headline="$1"
# sanity checks on ubuntu runner
function summarize_sanity() {
headline="Sanity Tests Ubuntu $1"
output "\n## $headline\n"
rm -rf testfiles
check_tarfile "$2/sanity.tar"
check_tarfile "Logs-$1-sanity/sanity.tar"
check_logfile "testfiles/log"
generate
}

# functional
function summarize_f() {
headline="$1"
# functional on ubuntu runner matrix
function summarize_functional() {
headline="Functional Tests Ubuntu $1"
output "\n## $headline\n"
rm -rf testfiles
for i in $(seq 1 $FUNCTIONAL_PARTS); do
tarfile="$2-part$i/part$i.tar"
for i in $(seq 1 4); do
tarfile="Logs-$1-functional-part$i/part$i.tar"
check_tarfile "$tarfile"
check_logfile "testfiles/log"
done
generate
}

# functional tests via qemu
function summarize_qemu() {
for tarfile in Logs-functional*/qemu-*.tar; do
rm -rf current
check_tarfile "$tarfile"
osname=`cat osname.txt`
headline="Functional Tests: $osname"
output "\n## $headline\n"
check_logfile "current/log"
generate
done
}

# https://docs.github.com/en/[email protected]/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits
# Job summaries are isolated between steps and each step is restricted to a maximum size of 1MiB.
# [ ] can not show all error findings here
Expand All @@ -102,11 +126,20 @@ function summarize_f() {
ERRLOGS=0
if [ ! -f Summary/Summary.md ]; then
# first call, we do the default summary (~500k)

# create ./zts-report.py for generate()
if [ ! -x ./zts-report.py ]; then
TEMPLATE="tests/test-runner/bin/zts-report.py.in"
cat $TEMPLATE| sed -e 's|@PYTHON_SHEBANG@|python3|' > ./zts-report.py
chmod +x ./zts-report.py
fi

echo -n > Summary.md
summarize_s "Sanity Tests Ubuntu 20.04" Logs-20.04-sanity
summarize_s "Sanity Tests Ubuntu 22.04" Logs-22.04-sanity
summarize_f "Functional Tests Ubuntu 20.04" Logs-20.04-functional
summarize_f "Functional Tests Ubuntu 22.04" Logs-22.04-functional
summarize_sanity "20.04"
summarize_sanity "22.04"
summarize_functional "20.04"
summarize_functional "22.04"
summarize_qemu

cat Summary.md >> $GITHUB_STEP_SUMMARY
mkdir -p Summary
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/scripts/qemu-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

#####################################################
# 4) configure and build openzfs modules #
#####################################################

set -eu

function freebsd() {
echo "##[group]Autogen.sh"
MAKE="gmake" ./autogen.sh
echo "##[endgroup]"

echo "##[group]Configure"
MAKE="gmake" ./configure \
--prefix=/usr/local \
--with-libintl-prefix=/usr/local \
--enable-debug \
--enable-debuginfo
echo "##[endgroup]"

echo "##[group]Build"
gmake -j`sysctl -n hw.ncpu`
echo "##[endgroup]"

echo "##[group]Install"
sudo gmake install
echo "##[endgroup]"

echo "##[group]Load modules"
# when freebsd zfs is loaded, unload it:
kldstat -n zfs 2>/dev/null && kldunload zfs
sudo dmesg -c > /var/tmp/dmesg-prerun.txt
sudo -E ./scripts/zfs.sh
sudo dmesg
sudo dmesg -c > /var/tmp/dmesg-module-load.txt
echo "Loaded module: "
kldstat -n openzfs
echo "##[endgroup]"
}

function linux_forceload() {
echo "Need to force the module loading!"
# -f tells modprobe to ignore wrong version numbers
sudo modprobe -v -f spl || echo "!! Loading module spl is failing !!"
sudo modprobe -v -f zfs || echo "!! Loading module zfs is failing !!"
}

function linux() {
echo "##[group]Autogen.sh"
./autogen.sh
echo "##[endgroup]"

echo "##[group]Configure"
./configure \
--prefix=/usr \
--enable-debug \
--enable-debuginfo
echo "##[endgroup]"

echo "##[group]Build"
make -j$(nproc)
echo "##[endgroup]"

echo "##[group]Install"
sudo make install
echo "##[endgroup]"

echo "##[group]Load modules"
sudo dmesg -c > /var/tmp/dmesg-prerun.txt
sudo -E ./scripts/zfs.sh
test -d /proc/spl/kstat/zfs || linux_forceload
sudo dmesg
sudo dmesg -c > /var/tmp/dmesg-module-load.txt
echo "##[endgroup]"
}

export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin"
case "$1" in
freebsd*)
freebsd
;;
*)
linux
;;
esac
121 changes: 121 additions & 0 deletions .github/workflows/scripts/qemu-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env bash

#####################################################
# 3) install dependencies for compiling and loading #
#####################################################

set -eu

function archlinux() {
echo "##[group]Running pacman -Syu"
sudo pacman -Syu --noconfirm
echo "##[endgroup]"

# XXX: image must have these installed: linux linux-headers
echo "##[group]Install Development Tools"
sudo pacman -Sy --noconfirm base-devel bc cpio dkms fakeroot fio \
inetutils lsscsi nfs-utils parted pax perf ksh samba sysstat \
rng-tools rsync wget
echo "##[endgroup]"
}

function debian() {
export DEBIAN_FRONTEND=noninteractive

echo "##[group]Running apt-get update+upgrade"
sudo apt-get update -y
sudo apt-get upgrade -y
echo "##[endgroup]"

echo "##[group]Install Development Tools"
yes | sudo apt-get install -y build-essential autoconf libtool \
libtool-bin gdb lcov git alien fakeroot wget curl bc fio acl \
sysstat lsscsi parted gdebi attr dbench watchdog ksh nfs-kernel-server \
samba rng-tools dkms rsync linux-headers-$(uname -r) \
zlib1g-dev uuid-dev libblkid-dev libselinux-dev \
xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \
libssl-dev libaio-dev libffi-dev libelf-dev libmount-dev \
libpam0g-dev pamtester python3-dev python3-setuptools python3 \
python3-dev python3-setuptools python3-cffi libcurl4-openssl-dev \
python3-packaging python3-distlib
echo "##[endgroup]"
}

function freebsd() {
export ASSUME_ALWAYS_YES="YES"

echo "##[group]Install Development Tools"
yes | sudo pkg install autoconf automake autotools git gmake gsed python \
devel/py-sysctl gettext gettext-runtime base64 checkbashisms \
lscpu fio ksh93 pamtester devel/py-flake8 pamtester rsync
echo "##[endgroup]"

echo "##[group]Install Kernel Headers"
ABI=$(uname -p)
VERSION=$(freebsd-version -r)
cd /tmp
fetch https://download.freebsd.org/ftp/snapshots/${ABI}/${VERSION}/src.txz ||
fetch https://download.freebsd.org/ftp/releases/${ABI}/${VERSION}/src.txz
sudo tar xpf src.txz -C /
rm src.txz
echo "##[endgroup]"
}

function rhel() {
echo "##[group]Running dnf update"
sudo dnf update -y
echo "##[endgroup]"

echo "##[group]Install Development Tools"
sudo dnf group install -y "Development Tools"
sudo dnf install -y libtool rpm-build libtirpc-devel libblkid-devel \
libuuid-devel libudev-devel openssl-devel zlib-devel libaio-devel \
libattr-devel elfutils-libelf-devel python3 python3-devel \
python3-setuptools python3-cffi libffi-devel git ncompress \
libcurl-devel python3-packaging
sudo dnf install -y kernel-devel-$(uname -r)
echo "##[endgroup]"

echo "##[group]Install utilities for ZTS"
sudo dnf install -y acl ksh bc bzip2 fio sysstat mdadm lsscsi parted attr \
nfs-utils samba rng-tools perf rsync dbench pamtester
echo "##[endgroup]"
}

case "$1" in
almalinux8|centos-stream8)
echo "##[group]Enable epel and powertools repositories"
sudo dnf config-manager -y --set-enabled powertools
sudo dnf install -y epel-release
echo "##[endgroup]"
rhel
;;
almalinux9|centos-stream9)
echo "##[group]Enable epel and crb repositories"
sudo dnf config-manager -y --set-enabled crb
sudo dnf install -y epel-release
echo "##[endgroup]"
rhel
;;
archlinux)
archlinux
;;
debian*)
debian
echo "##[group]Install linux-perf"
sudo apt-get install -yq linux-perf
echo "##[endgroup]"
;;
fedora*)
rhel
;;
freebsd*)
freebsd
;;
ubuntu*)
debian
echo "##[group]Install linux-tools-common"
sudo apt-get install -yq linux-tools-common
echo "##[endgroup]"
;;
esac
22 changes: 22 additions & 0 deletions .github/workflows/scripts/qemu-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

##########################################################
# 1) setup the action runner to start some qemu instance #
##########################################################

set -eu

# only install qemu, leave the system as it is
sudo apt-get update
sudo apt-get install axel cloud-image-utils guestfs-tools virt-manager

# generate ssh keys
sudo ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -q -N ""

# no swap needed
sudo swapoff -a

# disk usage afterwards
sudo df -h /
sudo df -h /mnt
sudo fstrim -a
Loading

0 comments on commit b83d72e

Please sign in to comment.