zloop: Add a max iterations option, use default run/pass times
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
This commit is contained in:
parent
46197dc858
commit
14b43fbd9c
|
@ -45,7 +45,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo mkdir -p $TEST_DIR
|
sudo mkdir -p $TEST_DIR
|
||||||
# run for 20 minutes to have a total runner time of 30 minutes
|
# 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
|
- name: Prepare artifacts
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -38,25 +38,30 @@ DEFAULTCOREDIR=/var/tmp/zloop
|
||||||
|
|
||||||
function usage
|
function usage
|
||||||
{
|
{
|
||||||
echo -e "\n$0 [-t <timeout>] [ -s <vdev size> ] [-c <dump directory>]" \
|
cat >&2 <<EOF
|
||||||
"[ -- [extra ztest parameters]]\n" \
|
|
||||||
"\n" \
|
$0 [-hl] [-c <dump directory>] [-f <vdev directory>]
|
||||||
" This script runs ztest repeatedly with randomized arguments.\n" \
|
[-m <max core dumps>] [-s <vdev size>] [-t <timeout>]
|
||||||
" If a crash is encountered, the ztest logs, any associated\n" \
|
[-I <max iterations>] [-- [extra ztest parameters]]
|
||||||
" vdev files, and core file (if one exists) are moved to the\n" \
|
|
||||||
" output directory ($DEFAULTCOREDIR by default). Any options\n" \
|
This script runs ztest repeatedly with randomized arguments.
|
||||||
" after the -- end-of-options marker will be passed to ztest.\n" \
|
If a crash is encountered, the ztest logs, any associated
|
||||||
"\n" \
|
vdev files, and core file (if one exists) are moved to the
|
||||||
" Options:\n" \
|
output directory ($DEFAULTCOREDIR by default). Any options
|
||||||
" -t Total time to loop for, in seconds. If not provided,\n" \
|
after the -- end-of-options marker will be passed to ztest.
|
||||||
" zloop runs forever.\n" \
|
|
||||||
" -s Size of vdev devices.\n" \
|
Options:
|
||||||
" -f Specify working directory for ztest vdev files.\n" \
|
-c Specify a core dump directory to use.
|
||||||
" -c Specify a core dump directory to use.\n" \
|
-f Specify working directory for ztest vdev files.
|
||||||
" -m Max number of core dumps to allow before exiting.\n" \
|
-h Print this help message.
|
||||||
" -l Create 'ztest.core.N' symlink to core directory.\n" \
|
-l Create 'ztest.core.N' symlink to core directory.
|
||||||
" -h Print this help message.\n" \
|
-m Max number of core dumps to allow before exiting.
|
||||||
"" >&2
|
-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
|
function or_die
|
||||||
|
@ -185,10 +190,12 @@ timeout=0
|
||||||
size="512m"
|
size="512m"
|
||||||
coremax=0
|
coremax=0
|
||||||
symlink=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
|
case $opt in
|
||||||
t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
|
t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
|
||||||
m ) [[ $OPTARG -gt 0 ]] && coremax=$OPTARG ;;
|
m ) [[ $OPTARG -gt 0 ]] && coremax=$OPTARG ;;
|
||||||
|
I ) [[ $OPTARG ]] && iterations=$OPTARG ;;
|
||||||
s ) [[ $OPTARG ]] && size=$OPTARG ;;
|
s ) [[ $OPTARG ]] && size=$OPTARG ;;
|
||||||
c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
|
c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
|
||||||
f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
|
f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
|
||||||
|
@ -233,9 +240,14 @@ ztrc=0 # ztest return value
|
||||||
foundcrashes=0 # number of crashes found so far
|
foundcrashes=0 # number of crashes found so far
|
||||||
starttime=$(date +%s)
|
starttime=$(date +%s)
|
||||||
curtime=$starttime
|
curtime=$starttime
|
||||||
|
iteration=0
|
||||||
|
|
||||||
# if no timeout was specified, loop forever.
|
# 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"
|
zopt="-G -VVVVV"
|
||||||
|
|
||||||
# start each run with an empty directory
|
# start each run with an empty directory
|
||||||
|
@ -284,10 +296,6 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
|
||||||
raid_type="draid"
|
raid_type="draid"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run from 30 to 120 seconds
|
|
||||||
runtime=$(((RANDOM % 90) + 30))
|
|
||||||
passtime=$((RANDOM % (runtime / 3 + 1) + 10))
|
|
||||||
|
|
||||||
zopt="$zopt -K $raid_type"
|
zopt="$zopt -K $raid_type"
|
||||||
zopt="$zopt -m $mirrors"
|
zopt="$zopt -m $mirrors"
|
||||||
zopt="$zopt -r $raid_children"
|
zopt="$zopt -r $raid_children"
|
||||||
|
@ -297,8 +305,6 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
|
||||||
zopt="$zopt -v $vdevs"
|
zopt="$zopt -v $vdevs"
|
||||||
zopt="$zopt -a $align"
|
zopt="$zopt -a $align"
|
||||||
zopt="$zopt -C $class"
|
zopt="$zopt -C $class"
|
||||||
zopt="$zopt -T $runtime"
|
|
||||||
zopt="$zopt -P $passtime"
|
|
||||||
zopt="$zopt -s $size"
|
zopt="$zopt -s $size"
|
||||||
zopt="$zopt -f $workdir"
|
zopt="$zopt -f $workdir"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue