Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZTS: Improve redundancy/* test scripts #11906

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function setup_test_env
typeset -i i=0
typeset file=$TESTDIR/file
typeset -i limit
(( limit = $(get_prop available $pool) / 4 ))
(( limit = $(get_prop available $pool) / 2 ))

while true ; do
[[ $(get_prop available $pool) -lt $limit ]] && break
Expand All @@ -162,6 +162,7 @@ function setup_test_env
function refill_test_env
{
log_note "Re-filling the filesystem ..."
typeset pool=$1
typeset -i ret=0
typeset -i i=0
typeset mntpnt
Expand Down Expand Up @@ -217,8 +218,13 @@ function is_data_valid
{
typeset pool=$1

log_must zpool scrub -w $pool

record_data $pool $PST_RECORD_FILE
if ! diff $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null 2>&1; then
log_must cat $PRE_RECORD_FILE
log_must cat $PST_RECORD_FILE
diff -u $PRE_RECORD_FILE $PST_RECORD_FILE
return 1
fi

Expand All @@ -237,7 +243,7 @@ function get_vdevs #pool cnt
typeset -i cnt=$2

typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}'| \
egrep -v "^pool$|^capacity$|^mirror$|^raidz1$|^raidz2$|---" | \
egrep -v "^pool$|^capacity$|^mirror$|^raidz1$|^raidz2$|^raidz3$|^draid1.*|^draid2.*|^draid3.*|---" | \
egrep -v "/old$|^$pool$")
typeset -i i=0
typeset vdevs
Expand Down Expand Up @@ -265,9 +271,9 @@ function replace_missing_devs

typeset vdev
for vdev in $@; do
log_must gnudd if=/dev/zero of=$vdev \
bs=1024k count=$(($MINDEVSIZE / (1024 * 1024))) \
oflag=fdatasync
log_must dd if=/dev/zero of=$vdev \
bs=1024k count=$((MINVDEVSIZE / (1024 * 1024))) \
conv=fdatasync
log_must zpool replace -wf $pool $vdev $vdev
done
}
Expand All @@ -286,19 +292,19 @@ function damage_devs
typeset -i cnt=$2
typeset label="$3"
typeset vdevs
typeset -i bs_count=$((64 * 1024))
typeset -i bs_count=$(((MINVDEVSIZE / 1024) - 4096))

vdevs=$(get_vdevs $pool $cnt)
typeset dev
if [[ -n $label ]]; then
for dev in $vdevs; do
dd if=/dev/zero of=$dev seek=512 bs=1024 \
log_must dd if=/dev/zero of=$dev seek=512 bs=1024 \
count=$bs_count conv=notrunc >/dev/null 2>&1
done
else
for dev in $vdevs; do
dd if=/dev/zero of=$dev bs=1024 count=$bs_count \
conv=notrunc >/dev/null 2>&1
log_must dd if=/dev/zero of=$dev bs=1024 \
count=$bs_count conv=notrunc >/dev/null 2>&1
done
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# 2. Create draid3 pool based on the virtual disk files.
# 3. Fill the filesystem with directories and files.
# 4. Record all the files and directories checksum information.
# 5. Damaged at most two of the virtual disk files.
# 5. Damaged at most three of the virtual disk files.
# 6. Verify the data is correct to prove draid3 can withstand 3 devices
# are failing.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ setup_test_env $TESTPOOL "" $cnt
damage_devs $TESTPOOL 1 "keep_label"
log_must zpool scrub -w $TESTPOOL

log_mustnot is_healthy $TESTPOOL
if is_healthy $TESTPOOL ; then
log_fail "$pool should not be healthy."
fi

log_pass "Striped pool has no data redundancy as expected."