aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Moeller <ryan@iXsystems.com>2021-07-22 21:29:27 +0000
committerGitHub <noreply@github.com>2021-07-22 21:29:27 +0000
commit14b43fbd9c13d802409ed886bb6b66fd528fb209 (patch)
treeeffdf9cb5c414a516490952303f5c948ed170dbe
parent46197dc85892fc15a21b409dc78054a28ac85d6e (diff)
downloadsrc-vendor/openzfs/master.tar.gz
src-vendor/openzfs/master.zip
zloop: Add a max iterations option, use default run/pass timesvendor/openzfs/master
It is useful to have control over the number of iterations of zloop so we can easily produce "x core dumps found *in y iterations*" metrics. Using random values for run/pass times doesn't improve coverage in a meaningful way. Randomizing run time could be seen as a compromise between running a greater variety of shorter tests versus a smaller variety of longer tests within a fixed time span. However, it is not desirable when running a fixed number of iterations. Pass time already incorporates randomness within ztest. Either parameter can be passed to ztest explicitly if the defaults are not satisfactory. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #12411
-rw-r--r--.github/workflows/zloop.yml2
-rwxr-xr-xscripts/zloop.sh60
2 files changed, 34 insertions, 28 deletions
diff --git a/.github/workflows/zloop.yml b/.github/workflows/zloop.yml
index b3679e7f7f20..cf81ad4bcafc 100644
--- a/.github/workflows/zloop.yml
+++ b/.github/workflows/zloop.yml
@@ -45,7 +45,7 @@ jobs:
run: |
sudo mkdir -p $TEST_DIR
# run for 20 minutes to have a total runner time of 30 minutes
- sudo /usr/share/zfs/zloop.sh -t 1200 -l -m1
+ sudo /usr/share/zfs/zloop.sh -t 1200 -l -m1 -- -T 120 -P 60
- name: Prepare artifacts
if: failure()
run: |
diff --git a/scripts/zloop.sh b/scripts/zloop.sh
index 546e7001776d..4a572ebab1fc 100755
--- a/scripts/zloop.sh
+++ b/scripts/zloop.sh
@@ -38,25 +38,30 @@ DEFAULTCOREDIR=/var/tmp/zloop
function usage
{
- echo -e "\n$0 [-t <timeout>] [ -s <vdev size> ] [-c <dump directory>]" \
- "[ -- [extra ztest parameters]]\n" \
- "\n" \
- " This script runs ztest repeatedly with randomized arguments.\n" \
- " If a crash is encountered, the ztest logs, any associated\n" \
- " vdev files, and core file (if one exists) are moved to the\n" \
- " output directory ($DEFAULTCOREDIR by default). Any options\n" \
- " after the -- end-of-options marker will be passed to ztest.\n" \
- "\n" \
- " Options:\n" \
- " -t Total time to loop for, in seconds. If not provided,\n" \
- " zloop runs forever.\n" \
- " -s Size of vdev devices.\n" \
- " -f Specify working directory for ztest vdev files.\n" \
- " -c Specify a core dump directory to use.\n" \
- " -m Max number of core dumps to allow before exiting.\n" \
- " -l Create 'ztest.core.N' symlink to core directory.\n" \
- " -h Print this help message.\n" \
- "" >&2
+ cat >&2 <<EOF
+
+$0 [-hl] [-c <dump directory>] [-f <vdev directory>]
+ [-m <max core dumps>] [-s <vdev size>] [-t <timeout>]
+ [-I <max iterations>] [-- [extra ztest parameters]]
+
+ This script runs ztest repeatedly with randomized arguments.
+ If a crash is encountered, the ztest logs, any associated
+ vdev files, and core file (if one exists) are moved to the
+ output directory ($DEFAULTCOREDIR by default). Any options
+ after the -- end-of-options marker will be passed to ztest.
+
+ Options:
+ -c Specify a core dump directory to use.
+ -f Specify working directory for ztest vdev files.
+ -h Print this help message.
+ -l Create 'ztest.core.N' symlink to core directory.
+ -m Max number of core dumps to allow before exiting.
+ -s Size of vdev devices.
+ -t Total time to loop for, in seconds. If not provided,
+ zloop runs forever.
+ -I Max number of iterations to loop before exiting.
+
+EOF
}
function or_die
@@ -185,10 +190,12 @@ timeout=0
size="512m"
coremax=0
symlink=0
-while getopts ":ht:m:s:c:f:l" opt; do
+iterations=0
+while getopts ":ht:m:I:s:c:f:l" opt; do
case $opt in
t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
m ) [[ $OPTARG -gt 0 ]] && coremax=$OPTARG ;;
+ I ) [[ $OPTARG ]] && iterations=$OPTARG ;;
s ) [[ $OPTARG ]] && size=$OPTARG ;;
c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
@@ -233,9 +240,14 @@ ztrc=0 # ztest return value
foundcrashes=0 # number of crashes found so far
starttime=$(date +%s)
curtime=$starttime
+iteration=0
# if no timeout was specified, loop forever.
-while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
+while (( timeout == 0 )) || (( curtime <= (starttime + timeout) )); do
+ if (( iterations > 0 )) && (( iteration++ == iterations )); then
+ break
+ fi
+
zopt="-G -VVVVV"
# start each run with an empty directory
@@ -284,10 +296,6 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
raid_type="draid"
fi
- # run from 30 to 120 seconds
- runtime=$(((RANDOM % 90) + 30))
- passtime=$((RANDOM % (runtime / 3 + 1) + 10))
-
zopt="$zopt -K $raid_type"
zopt="$zopt -m $mirrors"
zopt="$zopt -r $raid_children"
@@ -297,8 +305,6 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
zopt="$zopt -v $vdevs"
zopt="$zopt -a $align"
zopt="$zopt -C $class"
- zopt="$zopt -T $runtime"
- zopt="$zopt -P $passtime"
zopt="$zopt -s $size"
zopt="$zopt -f $workdir"