ZTS: Polish online_offline tests

- Kill workload first for faster cleanup.
 - Use `zpool wait` for resilver instead of `sleep`.
 - Remove irrelevant workload from `online_offline_003_neg`.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes: #17259
This commit is contained in:
Alexander Motin 2025-04-22 21:02:31 -04:00 committed by GitHub
parent 5f5321effa
commit cb49e7701f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 13 deletions

View File

@ -50,16 +50,17 @@ DISKLIST=$(get_disklist $TESTPOOL)
function cleanup function cleanup
{ {
kill $killpid >/dev/null 2>&1
# #
# Ensure we don't leave disks in the offline state # Ensure we don't leave disks in the offline state
# #
for disk in $DISKLIST; do for disk in $DISKLIST; do
log_must zpool online $TESTPOOL $disk log_must zpool online $TESTPOOL $disk
log_must check_state $TESTPOOL $disk "online" log_must check_state $TESTPOOL $disk "online"
done done
log_must zpool wait -t resilver $TESTPOOL
kill $killpid >/dev/null 2>&1
[[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/* [[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
} }
@ -77,8 +78,7 @@ for disk in $DISKLIST; do
log_must zpool online $TESTPOOL $disk log_must zpool online $TESTPOOL $disk
log_must check_state $TESTPOOL $disk "online" log_must check_state $TESTPOOL $disk "online"
# Delay for resilver to complete log_must zpool wait -t resilver $TESTPOOL
sleep 3
done done
log_must kill $killpid log_must kill $killpid

View File

@ -51,6 +51,8 @@ DISKLIST=$(get_disklist $TESTPOOL)
function cleanup function cleanup
{ {
kill $killpid >/dev/null 2>&1
# #
# Ensure we don't leave disks in the offline state # Ensure we don't leave disks in the offline state
# #
@ -58,8 +60,8 @@ function cleanup
log_must zpool online $TESTPOOL $disk log_must zpool online $TESTPOOL $disk
log_must check_state $TESTPOOL $disk "online" log_must check_state $TESTPOOL $disk "online"
done done
log_must zpool wait -t resilver $TESTPOOL
kill $killpid >/dev/null 2>&1
[[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/* [[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
} }

View File

@ -49,7 +49,6 @@ function cleanup
destroy_pool $TESTPOOL1 destroy_pool $TESTPOOL1
fi fi
kill $killpid >/dev/null 2>&1
[[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/* [[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
} }
@ -59,7 +58,7 @@ log_onexit cleanup
specials_list="" specials_list=""
for i in 0 1 2; do for i in 0 1 2; do
mkfile $MINVDEVSIZE $TESTDIR/$TESTFILE1.$i log_must mkfile $MINVDEVSIZE $TESTDIR/$TESTFILE1.$i
specials_list="$specials_list $TESTDIR/$TESTFILE1.$i" specials_list="$specials_list $TESTDIR/$TESTFILE1.$i"
done done
disk=($specials_list) disk=($specials_list)
@ -68,15 +67,9 @@ create_pool $TESTPOOL1 $specials_list
log_must zfs create $TESTPOOL1/$TESTFS1 log_must zfs create $TESTPOOL1/$TESTFS1
log_must zfs set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1 log_must zfs set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1
file_trunc -f $((64 * 1024 * 1024)) -b 8192 -c 0 -r $TESTDIR/$TESTFILE1 &
typeset killpid="$! "
for i in 0 1 2; do for i in 0 1 2; do
log_mustnot zpool offline $TESTPOOL1 ${disk[$i]} log_mustnot zpool offline $TESTPOOL1 ${disk[$i]}
check_state $TESTPOOL1 ${disk[$i]} "online" check_state $TESTPOOL1 ${disk[$i]} "online"
done done
log_must kill $killpid
sync_all_pools
log_pass log_pass