Skip to content

Commit

Permalink
Enable zfs-tests zpool_expand_002 and 003
Browse files Browse the repository at this point in the history
Use -pH flags in get_pool_prop so that numeric properties such as size
can be compared.  The zpool_expand test suite is currently the only one
which uses get_pool_prop for a numeric property.

Add TEMPFILE and TEMPFILE{0,1,2} to default.cfg for tests that must
build pools on top of files, such as this one where expansion is
necessary but the entries in DISKS may not point to entities that can be
expanded.

Base the pool used for testing on file-type VDEVs instead of using zvols
within an underlying pool, to avoid issues that come up when pools are
backed by other pools.

Remove unnecessary setup.ksh and cleanup.ksh.  They were creating and
destroying the underlying pool used to create the zvols upon which the
test pool was created.  This pool is no longer used.

Finally, enable zpool_expand_002_pos and zpool_expand_003_neg

Signed-off-by: Olaf Faaland <[email protected]>

removed unnecessary setup and cleanup files
  • Loading branch information
ofaaland committed Feb 9, 2017
1 parent d834b9c commit 8d2b47d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 117 deletions.
9 changes: 5 additions & 4 deletions tests/runfiles/linux.run
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,11 @@ post =
tests = ['zpool_detach_001_neg']

# DISABLED: Requires full FMA support in ZED
# zpool_expand_* - https://github.com/zfsonlinux/zfs/issues/2437
#[tests/functional/cli_root/zpool_expand]
#tests = ['zpool_expand_001_pos', 'zpool_expand_002_pos',
# 'zpool_expand_003_neg']
# zpool_expand_001_pos - https://github.com/zfsonlinux/zfs/issues/2437
[tests/functional/cli_root/zpool_expand]
tests = ['zpool_expand_002_pos', 'zpool_expand_003_neg']
pre =
post =

# DISABLED:
# zpool_export_004_pos - https://github.com/zfsonlinux/zfs/issues/3484
Expand Down
7 changes: 7 additions & 0 deletions tests/zfs-tests/include/default.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#
# Copyright (c) 2016 by Delphix. All rights reserved.
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
#

. $STF_SUITE/include/commands.cfg
Expand Down Expand Up @@ -129,6 +130,12 @@ export TESTDIR0=${TEST_BASE_DIR%%/}/testdir0$$
export TESTDIR1=${TEST_BASE_DIR%%/}/testdir1$$
export TESTDIR2=${TEST_BASE_DIR%%/}/testdir2$$

# some temp files
export TEMPFILE=${TEST_BASE_DIR%%/}/tempfile$$
export TEMPFILE0=${TEST_BASE_DIR%%/}/tempfile0$$
export TEMPFILE1=${TEST_BASE_DIR%%/}/tempfile1$$
export TEMPFILE2=${TEST_BASE_DIR%%/}/tempfile2$$

export ZFSROOT=

export TESTSNAP=testsnap$$
Expand Down
5 changes: 4 additions & 1 deletion tests/zfs-tests/include/libtest.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
#

. ${STF_TOOLS}/include/logapi.shlib
Expand Down Expand Up @@ -1043,14 +1044,16 @@ function get_prop # property dataset
# Simple function to get the specified property of pool. If unable to
# get the property then exits.
#
# Note property is in 'parsable' format (-p)
#
function get_pool_prop # property pool
{
typeset prop_val
typeset prop=$1
typeset pool=$2

if poolexists $pool ; then
prop_val=$($ZPOOL get $prop $pool 2>/dev/null | $TAIL -1 | \
prop_val=$($ZPOOL get -pH $prop $pool 2>/dev/null | $TAIL -1 | \
$AWK '{print $3}')
if [[ $? -ne 0 ]]; then
log_note "Unable to get $prop property for pool " \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_expand
dist_pkgdata_SCRIPTS = \
zpool_expand.cfg \
setup.ksh \
cleanup.ksh \
zpool_expand_001_pos.ksh \
zpool_expand_002_pos.ksh \
zpool_expand_003_neg.ksh
32 changes: 0 additions & 32 deletions tests/zfs-tests/tests/functional/cli_root/zpool_expand/cleanup.ksh

This file was deleted.

34 changes: 0 additions & 34 deletions tests/zfs-tests/tests/functional/cli_root/zpool_expand/setup.ksh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
#

. $STF_SUITE/include/libtest.shlib
Expand All @@ -39,12 +40,11 @@
#
#
# STRATEGY:
# 1) Create a pool
# 2) Create volume on top of the pool
# 3) Create pool by using the zvols
# 4) Expand the vol size by zfs set volsize
# 5 Use zpool online -e to online the zvol vdevs
# 6) Check that the pool size was expaned
# 1) Create 3 files
# 2) Create a pool backed by the files
# 3) Expand the files' size with truncate
# 4) Use zpool online -e to online the vdevs
# 5) Check that the pool size was expanded
#

verify_runnable "global"
Expand All @@ -56,23 +56,22 @@ function cleanup
fi

for i in 1 2 3; do
if datasetexists $VFS/vol$i; then
log_must $ZFS destroy $VFS/vol$i
fi
[ -e ${TEMPFILE}.$i ] && log_must $RM ${TEMPFILE}.$i
done
}

log_onexit cleanup

log_assert "zpool can expand after zpool online -e zvol vdevs on LUN expansion"

for i in 1 2 3; do
log_must $ZFS create -V $org_size $VFS/vol$i
done

for type in " " mirror raidz raidz2; do
log_must $ZPOOL create $TESTPOOL1 $type ${ZVOL_DEVDIR}/$VFS/vol1 \
${ZVOL_DEVDIR}/$VFS/vol2 ${ZVOL_DEVDIR}/$VFS/vol3
for i in 1 2 3; do
log_must $TRUNCATE -s $org_size ${TEMPFILE}.$i
done

log_must $ZPOOL create $TESTPOOL1 $type $TEMPFILE.1 \
$TEMPFILE.2 $TEMPFILE.3

typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)

Expand All @@ -85,11 +84,11 @@ for type in " " mirror raidz raidz2; do
$AWK '{print $3}')

for i in 1 2 3; do
log_must $ZFS set volsize=$exp_size $VFS/vol$i
log_must $TRUNCATE -s $exp_size ${TEMPFILE}.$i
done

for i in 1 2 3; do
log_must $ZPOOL online -e $TESTPOOL1 ${ZVOL_DEVDIR}/$VFS/vol$i
log_must $ZPOOL online -e $TESTPOOL1 ${TEMPFILE}.$i
done

$SYNC
Expand All @@ -103,7 +102,7 @@ for type in " " mirror raidz raidz2; do
"expanded size: $expand_size"

# compare available pool size from zfs
if [[ $zfs_expand_size > $zfs_prev_size ]]; then
if [[ $zfs_expand_size -gt $zfs_prev_size ]]; then
# check for zpool history for the pool size expansion
if [[ $type == " " ]]; then
typeset size_addition=$($ZPOOL history -il $TESTPOOL1 \
Expand Down Expand Up @@ -141,8 +140,5 @@ for type in " " mirror raidz raidz2; do
"expansion"
fi
log_must $ZPOOL destroy $TESTPOOL1
for i in 1 2 3; do
log_must $ZFS set volsize=$org_size $VFS/vol$i
done
done
log_pass "zpool can expand after zpool online -e zvol vdevs on LUN expansion"
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@

#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_expand/zpool_expand.cfg

#
# Description:
# DESCRIPTION:
# Once set zpool autoexpand=off, zpool can *NOT* autoexpand by
# Dynamic LUN Expansion
#
#
# STRATEGY:
# 1) Create a pool
# 2) Create volumes on top of the pool
# 3) Create pool by using the zvols and set autoexpand=off
# 4) Expand the vol size by zfs set volsize
# 5) Check that the pool size is not changed
# 1) Create 3 files
# 2) Create a pool backed by the files and verify autoexpand=off
# 3) Expand the files' size with truncate
# 4) Check that the pool size is not changed
#

verify_runnable "global"
Expand All @@ -55,34 +55,32 @@ function cleanup
fi

for i in 1 2 3; do
if datasetexists $VFS/vol$i; then
log_must $ZFS destroy $VFS/vol$i
fi
[ -e ${TEMPFILE}.$i ] && log_must $RM ${TEMPFILE}.$i
done
}

log_onexit cleanup

log_assert "zpool can not expand if set autoexpand=off after LUN expansion"

for i in 1 2 3; do
log_must $ZFS create -V $org_size $VFS/vol$i
done

for type in " " mirror raidz raidz2; do
log_must $ZPOOL create $TESTPOOL1 $type ${ZVOL_DEVDIR}/$VFS/vol1 \
${ZVOL_DEVDIR}/$VFS/vol2 ${ZVOL_DEVDIR}/$VFS/vol3
for i in 1 2 3; do
log_must $TRUNCATE -s $org_size ${TEMPFILE}.$i
done

log_must $ZPOOL create $TESTPOOL1 $type $TEMPFILE.1 \
$TEMPFILE.2 $TEMPFILE.3

typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)

if [[ $autoexp != "off" ]]; then
log_fail "zpool $TESTPOOL1 autoexpand should off but is " \
"$autoexp"
fi

typeset prev_size=$(get_pool_prop size $TESTPOOL1)

for i in 1 2 3; do
log_must $ZFS set volsize=$exp_size $VFS/vol$i
log_must $TRUNCATE -s $exp_size ${TEMPFILE}.$i
done

$SYNC
Expand All @@ -103,13 +101,6 @@ for type in " " mirror raidz raidz2; do
if [[ "$prev_size" != "$expand_size" ]]; then
log_fail "pool $TESTPOOL1 size changed after LUN expansion"
fi

log_must $ZPOOL destroy $TESTPOOL1

for i in 1 2 3; do
log_must $ZFS set volsize=$org_size $VFS/vol$i
done

done

log_pass "zpool can not expand if set autoexpand=off after LUN expansion"

0 comments on commit 8d2b47d

Please sign in to comment.