Skip to content

Commit cb49e77

Browse files
authored
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 <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes: #17259
1 parent 5f5321e commit cb49e77

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,17 @@ DISKLIST=$(get_disklist $TESTPOOL)
5050

5151
function cleanup
5252
{
53+
kill $killpid >/dev/null 2>&1
54+
5355
#
5456
# Ensure we don't leave disks in the offline state
5557
#
5658
for disk in $DISKLIST; do
5759
log_must zpool online $TESTPOOL $disk
5860
log_must check_state $TESTPOOL $disk "online"
59-
6061
done
62+
log_must zpool wait -t resilver $TESTPOOL
6163

62-
kill $killpid >/dev/null 2>&1
6364
[[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
6465
}
6566

@@ -77,8 +78,7 @@ for disk in $DISKLIST; do
7778
log_must zpool online $TESTPOOL $disk
7879
log_must check_state $TESTPOOL $disk "online"
7980

80-
# Delay for resilver to complete
81-
sleep 3
81+
log_must zpool wait -t resilver $TESTPOOL
8282
done
8383

8484
log_must kill $killpid

tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ DISKLIST=$(get_disklist $TESTPOOL)
5151

5252
function cleanup
5353
{
54+
kill $killpid >/dev/null 2>&1
55+
5456
#
5557
# Ensure we don't leave disks in the offline state
5658
#
5759
for disk in $DISKLIST; do
5860
log_must zpool online $TESTPOOL $disk
5961
log_must check_state $TESTPOOL $disk "online"
6062
done
63+
log_must zpool wait -t resilver $TESTPOOL
6164

62-
kill $killpid >/dev/null 2>&1
6365
[[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
6466
}
6567

tests/zfs-tests/tests/functional/online_offline/online_offline_003_neg.ksh

+1-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ function cleanup
4949
destroy_pool $TESTPOOL1
5050
fi
5151

52-
kill $killpid >/dev/null 2>&1
5352
[[ -e $TESTDIR ]] && log_must rm -rf $TESTDIR/*
5453
}
5554

@@ -59,7 +58,7 @@ log_onexit cleanup
5958

6059
specials_list=""
6160
for i in 0 1 2; do
62-
mkfile $MINVDEVSIZE $TESTDIR/$TESTFILE1.$i
61+
log_must mkfile $MINVDEVSIZE $TESTDIR/$TESTFILE1.$i
6362
specials_list="$specials_list $TESTDIR/$TESTFILE1.$i"
6463
done
6564
disk=($specials_list)
@@ -68,15 +67,9 @@ create_pool $TESTPOOL1 $specials_list
6867
log_must zfs create $TESTPOOL1/$TESTFS1
6968
log_must zfs set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1
7069

71-
file_trunc -f $((64 * 1024 * 1024)) -b 8192 -c 0 -r $TESTDIR/$TESTFILE1 &
72-
typeset killpid="$! "
73-
7470
for i in 0 1 2; do
7571
log_mustnot zpool offline $TESTPOOL1 ${disk[$i]}
7672
check_state $TESTPOOL1 ${disk[$i]} "online"
7773
done
7874

79-
log_must kill $killpid
80-
sync_all_pools
81-
8275
log_pass

0 commit comments

Comments
 (0)