Running zfs tests

Setup VM with:
CPU - 4
Memory - 8GB
Hard disk - 100GB (for software installation) SATA
Three additional hard drives - 8GB (for zfs test) SATA or NVME

names of other pools

Do not create pools with names that can be used in the tests, i.e. testpool*. otherwise the tests work incorrectly.

Have to use DEBUG build, where we have debug macro

Create user:
useradd -m -d /var/ztest -g staff -s /bin/bash ztest
# add password for remote ssh
passwd ztest
Add user to sudo:
echo "ztest ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/ztest
Install packages for zfs tests:
apt update
apt install system-test-zfstest testrunner system-file-system-zfs-tests python3
Update /etc/sudoers:
# update /etc/sudoers:
sudo -E /usr/bin/sed -i.bak '/secure_path/a\Defaults exempt_group+=staff' /etc/sudoers
sudo -E /usr/bin/sed -i.bak 's/ requiretty/ !requiretty/' /etc/sudoers
login by user ztest and run tests and run script z.sh:
#!/bin/bash

# we need 3 x 8G drives with 512b sector size
export DISKS="c0t600144F0A31AAA6200005B2ECCE00004d0 c0t600144F0A31AAA6200005B2ECCF30005d0 c0t600144F0A31AAA6200005B2ECCFF0006d0"

# cleanup drives before tests:
sudo -E /sbin/zpool create -f test123321 $DISKS
sudo -E /sbin/zpool destroy test123321

# run tests
/bin/ksh /opt/zfs-tests/bin/zfstest

wait about 5h-6h or more for full tests and found full logs at:

/var/tmp/test_results/<ISO TIME>

Note for cli_user tests:

These tests require the creation of files in /usr/share/zfs/zpool.d:

upath

/usr/share/zfs/zpool.d/upath
#!/bin/sh
if [ "$1" = "-h" ] ; then
        echo "Show the underlying path for a device."
        exit
fi

# shellcheck disable=SC2154
echo upath="$VDEV_UPATH"

iostat, iostat-10s, iostat-1s (the content is the same)

/usr/share/zfs/zpool.d/iostat
#!/bin/sh
#
# Display most relevant iostat bandwidth/latency numbers.  The output is
# dependent on the name of the script/symlink used to call it.
# 
helpstr="
iostat:         Show iostat values since boot (summary page).
iostat-1s:      Do a single 1-second iostat sample and show values.
iostat-10s:     Do a single 10-second iostat sample and show values."
script="${0##*/}"
if [ "$1" = "-h" ] ; then
    echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
    exit
fi
if [ "$script" = "iostat-1s" ] ; then
    # Do a single one-second sample
    interval=1
    # Don't show summary stats
    brief="yes"
elif [ "$script" = "iostat-10s" ] ; then
    # Do a single ten-second sample
    interval=10
    # Don't show summary stats
    brief="yes"
fi
if [ -f "$VDEV_UPATH" ] ; then
    # We're a file-based vdev, iostat doesn't work on us.  Do nothing.
    exit
fi
out=$(iostat -x "${VDEV_UPATH##*/}" \
    ${interval:+"$interval"} \
    ${interval:+"1"} | tail -n 2)
    
# Sample output (we want the last two lines):
#   
# Linux 2.6.32-642.13.1.el6.x86_64 (centos68)   03/09/2017      _x86_64_        (6 CPU)
#
# avg-cpu:  %user   %nice %system %iowait  %steal   %idle
#           0.00    0.00    0.00    0.00    0.00  100.00
# 
# Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
# sdb               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00
#
# Get the column names
cols=$(echo "$out" | head -n 1)
# Get the values and tab separate them to make them cut-able.
vals=$(echo "$out" | tail -n 1 | tr -s '[:space:]' '\t')
i=0
for col in $cols ; do
    i=$((i+1))
    # Skip the first column since it's just the device name
    if [ $i -eq 1 ]; then
        continue
    fi
    # Get i'th value
    val=$(echo "$vals" | cut -f "$i")
    echo "$col=$val"
done

and set attribute "execute" (chmod +x upath iostat iostat-10s iostat-1s)