ZTS: zpool_trim tests throttle trim process

Otherwise trim may finish before progress checks.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes #11296
This commit is contained in:
George Melikov 2020-12-07 21:06:10 +03:00 committed by GitHub
parent 83b698dc42
commit 8e8fdce682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 5 deletions

View File

@ -30,6 +30,23 @@ function trim_progress # pool disk
trim_prog_line "$1" "$2" | sed 's/.*(\([0-9]\{1,\}\)% trimmed.*/\1/g'
}
#
# Write a bit of data and sync several times.
#
function sync_and_rewrite_some_data_a_few_times
{
typeset pool=$1
typeset -i a_few_times=${2:-20}
typeset file="/$pool/tmpfile"
for i in {0..$a_few_times}; do
dd if=/dev/urandom of=${file} bs=128k count=10
sync_pool "$pool"
done
return 0
}
function cleanup
{
if poolexists $TESTPOOL; then

View File

@ -27,7 +27,7 @@
# Trimming automatically resumes across offline/online.
#
# STRATEGY:
# 1. Create a pool with a two-way mirror.
# 1. Create a pool with a two-way mirror, prepare blocks to trim.
# 2. Start trimming one of the disks and verify that trimming is active.
# 3. Offline the disk.
# 4. Online the disk.
@ -39,8 +39,10 @@
DISK1=${DISKS%% *}
DISK2="$(echo $DISKS | cut -d' ' -f2)"
log_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2
log_must zpool trim -r 128M $TESTPOOL $DISK1
log_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2 -O recordsize=4k
sync_and_rewrite_some_data_a_few_times $TESTPOOL
log_must zpool trim -r 1 $TESTPOOL $DISK1
log_must zpool offline $TESTPOOL $DISK1

View File

@ -39,8 +39,10 @@ DISK2="$(echo $DISKS | cut -d' ' -f2)"
DISK3="$(echo $DISKS | cut -d' ' -f3)"
log_must zpool list -v
log_must zpool create -f $TESTPOOL $DISK1 $DISK2 $DISK3
log_must zpool trim -r 128M $TESTPOOL $DISK1
log_must zpool create -f $TESTPOOL $DISK1 $DISK2 $DISK3 -O recordsize=4k
sync_and_rewrite_some_data_a_few_times $TESTPOOL
log_must zpool trim -r 1 $TESTPOOL $DISK1
[[ -z "$(trim_progress $TESTPOOL $DISK1)" ]] && \
log_fail "Trim did not start"