Skip to content

Commit

Permalink
Convert raidz_expand_test.sh to appropriate testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor Uporov authored and fuporovvStack committed Jul 21, 2020
1 parent 36c1310 commit 3b0dc52
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 140 deletions.
139 changes: 0 additions & 139 deletions scripts/raidz_expand_test.sh

This file was deleted.

3 changes: 2 additions & 1 deletion tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ tests = ['redacted_compressed', 'redacted_contents', 'redacted_deleted',
tags = ['functional', 'redacted_send']

[tests/functional/raidz]
tests = ['raidz_001_neg', 'raidz_002_pos', 'raidz_003_pos', 'raidz_004_pos']
tests = ['raidz_001_neg', 'raidz_002_pos', 'raidz_003_pos', 'raidz_004_pos',
'raidz_expand.ksh']
tags = ['functional', 'raidz']

[tests/functional/redundancy]
Expand Down
1 change: 1 addition & 0 deletions tests/zfs-tests/include/tunables.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ MULTIHOST_HISTORY UNSUPPORTED zfs_multihost_history
MULTIHOST_IMPORT_INTERVALS multihost.import_intervals zfs_multihost_import_intervals
MULTIHOST_INTERVAL UNSUPPORTED zfs_multihost_interval
OVERRIDE_ESTIMATE_RECORDSIZE send.override_estimate_recordsize zfs_override_estimate_recordsize
PREFETCH_DISABLE prefetch_disable zfs_prefetch_disable
REMOVAL_SUSPEND_PROGRESS removal_suspend_progress zfs_removal_suspend_progress
REMOVE_MAX_SEGMENT remove_max_segment zfs_remove_max_segment
RESILVER_MIN_TIME_MS resilver_min_time_ms zfs_resilver_min_time_ms
Expand Down
232 changes: 232 additions & 0 deletions tests/zfs-tests/tests/functional/raidz/raidz_expand.ksh
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2020 by vStack. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib

#
# DESCRIPTION:
# 'zpool attach poolname raidz ...' should attach new devive to the pool.
#
# STRATEGY:
# 1. Create block device files for the test raidz pool
# 2. For each parity value [1..3]
# - create raidz pool
# - fill it with some directories/files
# - attach device to the raidz pool
# - verify that device attached and the raidz pool size increase
# - verify resilver by replacing parity devices
# - verify resilver by replacing data devices
# - verify scrub by zeroing parity devices
# - verify scrub by zeroing data devices
# - verify the raidz pool
# - destroy the raidz pool

typeset -r devs=6
typeset -r dev_size_mb=512

typeset -a disks

prefetch_disable=$(get_tunable PREFETCH_DISABLE)

function cleanup
{
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"

for i in {0..$devs}; do
log_must rm -f "$TEST_BASE_DIR/dev-$i"
done

log_must set_tunable32 PREFETCH_DISABLE $prefetch_disable
}

function wait_expand_completion
{
while zpool status $TESTPOOL | grep 'raidz expand:' | \
grep 'in progress'; do
sleep 1
done
}

function test_resilver # <pool> <parity> <dir>
{
typeset pool=$1
typeset nparity=$2
typeset dir=$3

for (( i=0; i<$nparity; i=i+1 )); do
log_must zpool offline $pool $dir/dev-$i
done

log_must zpool export $pool

for (( i=0; i<$nparity; i=i+1 )); do
log_must zpool labelclear -f $dir/dev-$i
done

log_must zpool import -o cachefile=none -d $dir $pool

for (( i=0; i<$nparity; i=i+1 )); do
log_must zpool replace -f $pool $dir/dev-$i
done

while ! is_pool_resilvered $pool; do
sleep 1
done

log_must check_pool_status $pool "errors" "No known data errors"

log_must zpool clear $pool

for (( i=$nparity; i<$nparity*2; i=i+1 )); do
log_must zpool offline $pool $dir/dev-$i
done

log_must zpool export $pool

for (( i=$nparity; i<$nparity*2; i=i+1 )); do
log_must zpool labelclear -f $dir/dev-$i
done

log_must zpool import -o cachefile=none -d $dir $pool

for (( i=$nparity; i<$nparity*2; i=i+1 )); do
log_must zpool replace -f $pool $dir/dev-$i
done

while ! is_pool_resilvered $pool; do
sleep 1
done

log_must check_pool_status $pool "errors" "No known data errors"

log_must zpool clear $pool
}

function test_scrub # <pool> <parity> <dir>
{
typeset pool=$1
typeset nparity=$2
typeset dir=$3
typeset combrec=$4

log_must zpool export $pool

for (( i=0; i<$nparity; i=i+1 )); do
dd conv=notrunc if=/dev/zero of=$dir/dev-$i \
bs=1M seek=4 count=$(($dev_size_mb-4))
done

log_must zpool import -o cachefile=none -d $dir $pool

log_must zpool scrub $pool

while ! is_pool_scrubbed $pool; do
sleep 1
done

log_must zpool clear $pool

log_must zpool export $pool

for (( i=$nparity; i<$nparity*2; i=i+1 )); do
dd conv=notrunc if=/dev/zero of=$dir/dev-$i \
bs=1M seek=4 count=$(($dev_size_mb-4))
done

log_must zpool import -o cachefile=none -d $dir $pool

log_must zpool scrub $pool

while ! is_pool_scrubbed $pool; do
sleep 1
done

log_must check_pool_status $pool "errors" "No known data errors"

log_must zpool clear $pool
}

log_onexit cleanup

log_must set_tunable32 PREFETCH_DISABLE 1

# Disk files which will be used by pool
for i in {0..$(($devs - 1))}; do
device=$TEST_BASE_DIR/dev-$i
log_must truncate -s ${dev_size_mb}M $device
disks[${#disks[*]}+1]=$device
done

# Disk file which will be attached
log_must truncate -s 512M $TEST_BASE_DIR/dev-$devs

for nparity in 1 2 3; do
raid=raidz$nparity
dir=$TEST_BASE_DIR

log_must zpool create -f -o cachefile=none $TESTPOOL $raid ${disks[@]}
log_must zfs set primarycache=metadata $TESTPOOL

log_must zfs create $TESTPOOL/fs
log_must fill_fs /$TESTPOOL/fs 1 512 100 1024 R

log_must zfs create -o compress=on $TESTPOOL/fs2
log_must fill_fs /$TESTPOOL/fs2 1 512 100 1024 R

log_must zfs create -o compress=on -o recordsize=8k $TESTPOOL/fs3
log_must fill_fs /$TESTPOOL/fs3 1 512 100 1024 R

typeset pool_size=$(get_pool_prop size $TESTPOOL)

log_must zpool attach $TESTPOOL ${raid}-0 $dir/dev-$devs

wait_expand_completion

log_must zpool export $TESTPOOL
log_must zpool import -o cachefile=none -d $dir $TESTPOOL

typeset disk_attached=$(get_disklist $TESTPOOL | grep dev-$devs)
if [[ -z $disk_attached ]]; then
log_fail "pool $TESTPOOL attached disk not found"
fi

typeset expand_size=$(get_pool_prop size $TESTPOOL)
if [[ "$expand_size" -le "$pool_size" ]]; then
log_fail "pool $TESTPOOL not expanded"
fi

log_must zpool export $TESTPOOL
log_must zpool import -o cachefile=none -d $dir $TESTPOOL

log_must check_pool_status $TESTPOOL "errors" "No known data errors"

test_resilver $TESTPOOL $nparity $dir
test_scrub $TESTPOOL $nparity $dir

zpool destroy "$TESTPOOL"
done

log_pass "raidz expansion test succeeded."

0 comments on commit 3b0dc52

Please sign in to comment.