Skip to content

Commit

Permalink
Testing variable number of VM launches
Browse files Browse the repository at this point in the history
Requires-builders: none
Signed-off-by: Tony Hutter <[email protected]>
  • Loading branch information
tonyhutter committed Jul 25, 2024
1 parent a543c8b commit d4b2660
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 127 deletions.
File renamed without changes.
File renamed without changes.
10 changes: 8 additions & 2 deletions .github/workflows/scripts/merge_summary.awk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ BEGIN {
/SKIP/{ if (state=="pass_count") {skip += $2}}
/Running Time/{
state="";
running[i]=$3;
running[running_lines]=$3;
running_lines++
split($3, arr, ":")
total += arr[1] * 60 * 60;
total += arr[2] * 60;
Expand Down Expand Up @@ -86,7 +87,12 @@ END {
print "FAIL\t"fail
print "SKIP\t"skip
print ""
print "Running Time:\t"strftime("%T", total, 1)
# Print total run time of all VMs together, then individual VM test
# totals.
printf("Running Time:\t%s (", strftime("%T", total, 1))
for (j in running)
printf(" %s", running[j])
print " )"
if (pass+fail+skip > 0) {
percent_passed=(pass/(pass+fail+skip) * 100)
}
Expand Down
43 changes: 28 additions & 15 deletions .github/workflows/scripts/qemu-5-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
######################################################################

set -eu
NUM_VMS=$1

# machine not needed anymore
while pidof /usr/bin/qemu-system-x86_64 >/dev/null; do sleep 1; done
Expand All @@ -17,16 +18,18 @@ sudo virsh undefine openzfs
PUBKEY=`cat ~/.ssh/id_ed25519.pub`
OSv=`cat /var/tmp/osvariant.txt`
OS=`cat /var/tmp/os.txt`
for vm in `seq 1 3`; do
echo "Generating disk for vm$vm ..."
sudo qemu-img create -q -f qcow2 -F qcow2 \
-o compression_type=zstd,cluster_size=128k \
-b /mnt/openzfs.qcow2 "/mnt/vm$vm.qcow2"

for i in `seq 1 $NUM_VMS`; do

OPTS="-q -f qcow2 -o compression_type=zstd,preallocation=off,cluster_size=128k"

echo "Generating vm$i disks."
sudo qemu-img create $OPTS -b /mnt/openzfs.qcow2 -F qcow2 "/mnt/vm$i.qcow2"

cat <<EOF > /tmp/user-data
#cloud-config
fqdn: vm$vm
fqdn: vm$i
# user:zfs password:1
users:
Expand All @@ -46,23 +49,33 @@ growpart:
ignore_growroot_disabled: false
EOF

# Each runner has 4 CPUs and 8GB RAM
CPUS=4
MEMGB=8

sudo virt-install \
--os-variant $OSv \
--name "vm$vm" \
--name "vm$i" \
--cpu host-passthrough \
--virt-type=kvm --hvm \
--vcpus=2,sockets=1 \
--memory $((1024*4)) \
--vcpus=$CPUS,sockets=1 \
--memory $((1024*$MEMGB)) \
--memballoon model=none \
--graphics none \
--cloud-init user-data=/tmp/user-data \
--network bridge=virbr0,model=e1000,mac="52:54:00:83:79:0$vm" \
--disk /mnt/vm$vm.qcow2,bus=virtio,cache=writeback,format=qcow2,driver.discard=unmap \
--network bridge=virbr0,model=e1000,mac="52:54:00:83:79:0$i" \
--disk /mnt/vm$i.qcow2,bus=virtio,cache=writeback,format=qcow2,driver.discard=unmap \
--import --noautoconsole >/dev/null
done

# check if the machines are okay
echo "Waiting for vm's to come up..."
while true; do ssh 2>/dev/null [email protected] "uname -a" && break; done
while true; do ssh 2>/dev/null [email protected] "uname -a" && break; done
while true; do ssh 2>/dev/null [email protected] "uname -a" && break; done
echo "Waiting for VMs to come up..."

for i in $(seq 1 $NUM_VMS); do
LAST=$(($i + 10))
while true; do
ssh 2>/dev/null [email protected].$LAST "uname -a" && break
done
done

echo "All done waiting for $NUM_VMS VMs"
147 changes: 53 additions & 94 deletions .github/workflows/scripts/qemu-6-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,89 +6,66 @@

set -o pipefail

# force unsing these tests only:
TESTS="tests_functional"

# you can switch to some debugging tests here:
# TESTS="tests_debug"
function tests_debug() {
TF="$TDIR/zfs-tests/tests/functional"
echo -n "-T "
case "$1" in
part1)
echo "checksum"
;;
part2)
echo "casenorm,trim"
;;
part3)
echo "cp_files"
;;
esac
}

function tests_functional() {
TF="$TDIR/zfs-tests/tests/functional"
echo -n "-T "
case "$1" in
part1)
# ~1h 30m @ Almalinux 9
echo "cli_root"
;;
part2)
# ~1h 40m @ Almalinux 9
ls $TF|grep '^[a-p]'|grep -v "cli_root"|xargs|tr -s ' ' ','
;;
part3)
# ~1h 50m @ Almalinux 9
ls $TF|grep '^[q-z]'|xargs|tr -s ' ' ','
;;
esac
}

if [ -z "$1" ]; then
# There's two ways this script gets run, on the runner or on the VM.
# The args are a little different
#
# On the runner
# ./qemu-6-tests.sh [OS] [num_vms]
#
# On the VM
# ./qemu-6-tests.sh [group/all]
#
# Examples:
#
# Run tests on three VMs
# ./qemu-6-tests.sh 3
#
# Divide the test list up into thirds, and run the 2nd group of tests
# of the three on fedora40.
# ./qemu-6-tests.sh fedora40 2/3

if [ -z "$2" ]; then
NUM_VMS=$1

# called directly on the runner
P="/var/tmp"
cd $P
df -h /mnt > df-prerun.txt

# start as daemon and log stdout
SSH=`which ssh`
IP1="192.168.122.11"
IP2="192.168.122.12"
IP3="192.168.122.13"
OS=`cat os.txt`
SSH=`which ssh`
CMD='$HOME/zfs/.github/workflows/scripts/qemu-6-tests.sh'

daemonize -c $P -p vm1.pid -o vm1log.txt -- \
$SSH zfs@$IP1 $CMD $OS part1
daemonize -c $P -p vm2.pid -o vm2log.txt -- \
$SSH zfs@$IP2 $CMD $OS part2
daemonize -c $P -p vm3.pid -o vm3log.txt -- \
$SSH zfs@$IP3 $CMD $OS part3

# give us the output of stdout + stderr - with prefix ;)
BASE="$HOME/work/zfs/zfs"
CMD="$BASE/scripts/zfs-tests-color.sh"
tail -fq vm1log.txt | $CMD | sed -e "s/^/vm1: /g" &
tail -fq vm2log.txt | $CMD | sed -e "s/^/vm2: /g" &
tail -fq vm3log.txt | $CMD | sed -e "s/^/vm3: /g" &

# wait for all vm's to finnish
tail --pid=`cat vm1.pid` -f /dev/null
tail --pid=`cat vm2.pid` -f /dev/null
tail --pid=`cat vm3.pid` -f /dev/null
df -h /mnt > df-prerun.txt
for i in $(seq 1 $NUM_VMS) ; do
LAST=$((10 + $i))
IP="192.168.122.$LAST"

# start as daemon and log stdout
daemonize -c $P -p vm$i.pid -o vm${i}log.txt -- \
$SSH zfs@$IP $CMD $OS "$i/$NUM_VMS"

# give us the output of stdout + stderr - with prefix ;)
tail -fq vm${i}log.txt | sed -e "s/^/vm"$i": /g" &
done

for i in $(seq 1 $NUM_VMS) ; do
# wait for all vm's to finnish
tail --pid=`cat vm${i}.pid` -f /dev/null
done

df -h /mnt > df-postrun.txt
du -sh /mnt/openzfs.qcow2 >> df-postrun.txt
du -sh /mnt/vm1.qcow2 >> df-postrun.txt
du -sh /mnt/vm2.qcow2 >> df-postrun.txt
du -sh /mnt/vm3.qcow2 >> df-postrun.txt

for i in $(seq 1 $NUM_VMS) ; do
du -sh /mnt/vm$i.qcow2 >> df-postrun.txt
done

# kill the tail/sed combo
killall tail
exit 0
else
# Called from inside VM
OS="$1"
FRACTION="$2"
fi

function freebsd() {
Expand Down Expand Up @@ -116,37 +93,19 @@ case "$1" in
freebsd
;;
*)
TDIR="/usr/share/zfs"
linux
;;
esac

# this part runs inside qemu, finally: run tests
cd /var/tmp
uname -a > /var/tmp/uname.txt

# -h Show this message
# -v Verbose zfs-tests.sh output
# -q Quiet test-runner output
# -D Debug; show all test output immediately (noisy)
# -x Remove all testpools, dm, lo, and files (unsafe)
# -k Disable cleanup after test failure
# -K Log test names to /dev/kmsg
# -f Use files only, disables block device tests
# -S Enable stack tracer (negative performance impact)
# -c Only create and populate constrained path
# -R Automatically rerun failing tests
# -m Enable kmemleak reporting (Linux only)
# -n NFSFILE Use the nfsfile to determine the NFS configuration
# -I NUM Number of iterations
# -d DIR Use world-writable DIR for files and loopback devices
# -s SIZE Use vdevs of SIZE (default: 4G)
# -r RUNFILES Run tests in RUNFILES (default: common.run,freebsd.run)
# -t PATH|NAME Run single test at PATH relative to test suite or search for test by NAME
# -T TAGS Comma separated list of tags (default: 'functional')
# -u USER Run single test as USER (default: root)
OPTS=`$TESTS $2`
$TDIR/zfs-tests.sh -vK -s 3G $OPTS

cd $HOME/zfs
echo "Test command: $TDIR/zfs-tests.sh -vK -s 3G -T $FRACTION"
$TDIR/zfs-tests.sh -vKR -s 3G -T $FRACTION | scripts/zfs-tests-color.sh
RV=$?
echo $RV > /var/tmp/exitcode.txt
exit $RV

# exit $RV
exit 0
9 changes: 6 additions & 3 deletions .github/workflows/scripts/qemu-7-reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 7) output the results of the previous stage in an ordered way
######################################################################

NUM_VMS=$1

set -o pipefail
cd /var/tmp

Expand All @@ -20,7 +22,7 @@ BASE="$HOME/work/zfs/zfs"
MERGE="$BASE/.github/workflows/scripts/merge_summary.awk"
EXIT=0

for i in `seq 1 3`; do
for i in `seq 1 $NUM_VMS`; do
f="exitcode.vm$i"
scp 2>/dev/null [email protected]$i:/var/tmp/exitcode.txt $f
test -f $f || echo 2 > $f
Expand All @@ -37,6 +39,7 @@ for i in `seq 1 3`; do
echo "##[endgroup]"
done


# all tests without grouping:
$MERGE vm{1,2,3}log.txt | $BASE/scripts/zfs-tests-color.sh
exit $EXIT
cat vm*log.txt | $MERGE | $BASE/scripts/zfs-tests-color.sh
exit 0
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d4b2660

Please sign in to comment.