]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Use file-based pools for zpool_expand test 002 and enable it
authorOlaf Faaland <faaland1@llnl.gov>
Mon, 13 Feb 2017 23:30:22 +0000 (15:30 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 13 Feb 2017 23:30:22 +0000 (15:30 -0800)
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 shell variables EX_1GB and EX_2GB used to recognize correct expansion,
and instead calculate the appropriate values based on the variables used to
control file or volume size, org_size and exp_size.  This change is also
made in test 001 although that test is not enabled because it depends on
FMA.

Finally, enable zpool_expand_002_pos.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Don Brady <don.brady@intel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #5757

tests/runfiles/linux.run
tests/zfs-tests/include/default.cfg.in
tests/zfs-tests/include/libtest.shlib
tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand.cfg
tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh

index 06bd8b6a421ff656193222118bf2e67827f25c04..1ef1ccf3c7a444c02ff7536dd7649e66bc54666a 100644 (file)
@@ -275,10 +275,10 @@ 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
+# zpool_expand_003_pos - https://github.com/zfsonlinux/zfs/issues/2437
+[tests/functional/cli_root/zpool_expand]
+tests = ['zpool_expand_002_pos']
 
 # DISABLED:
 # zpool_export_004_pos - https://github.com/zfsonlinux/zfs/issues/3484
index ef34d2b90b620a3a0fbcf16f53b35e0c6dc61a99..a3e4881df0d3aa8cb418e07f3fe615a22eeb637f 100644 (file)
@@ -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
@@ -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$$
index da80407a962f04d01b596ac975f502e579b83d11..4493d97cdb28e4804b8bfcfb6fbae0bbdcc01ac5 100644 (file)
@@ -25,6 +25,7 @@
 # Use is subject to license terms.
 # Copyright (c) 2012, 2015 by Delphix. All rights reserved.
 # Copyright 2016 Nexenta Systems, Inc.
+# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
 #
 
 . ${STF_TOOLS}/include/logapi.shlib
@@ -1041,6 +1042,8 @@ 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
@@ -1048,7 +1051,7 @@ function get_pool_prop # property pool
        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 " \
index 16df1d91d3220d1ee870f0754b1bd21c7b497a33..e15471e227434b759ab0843b3042bfa2e5057361 100644 (file)
 #
 
 
-export org_size=1g
-export exp_size=2g
+export org_size=$MINVDEVSIZE
+export exp_size=$((2*$org_size))
 
 export VFS=$TESTPOOL/$TESTFS
-
-export EX_1GB=1073741824
-export EX_3GB=3221225472
index a063b083bfd7421586a8fe4e578929ccd33d6a78..06ff6f9d5b8a0ab5091f802ca661dce2b56a82f0 100755 (executable)
@@ -102,30 +102,33 @@ for type in " " mirror raidz raidz2; do
        if [[ $zfs_expand_size > $zfs_prev_size ]]; then
        # check for zpool history for the pool size expansion
                if [[ $type == " " ]]; then
+                       typeset expansion_size=$(($exp_size-$org_size))
                        typeset size_addition=$($ZPOOL history -il $TESTPOOL1 |\
                            $GREP "pool '$TESTPOOL1' size:" | \
                            $GREP "vdev online" | \
-                           $GREP "(+${EX_1GB}" | wc -l)
+                           $GREP "(+${expansion_size}" | wc -l)
 
                        if [[ $size_addition -ne $i ]]; then
                                log_fail "pool $TESTPOOL1 is not autoexpand " \
                                    "after LUN expansion"
                        fi
                elif [[ $type == "mirror" ]]; then
+                       typeset expansion_size=$(($exp_size-$org_size))
                        $ZPOOL history -il $TESTPOOL1 | \
                            $GREP "pool '$TESTPOOL1' size:" | \
                            $GREP "vdev online" | \
-                           $GREP "(+${EX_1GB})" >/dev/null 2>&1
+                           $GREP "(+${expansion_size})" >/dev/null 2>&1
 
                        if [[ $? -ne 0 ]] ; then
                                log_fail "pool $TESTPOOL1 is not autoexpand " \
                                    "after LUN expansion"
                        fi
                else
+                       typeset expansion_size=$((3*($exp_size-$org_size)))
                        $ZPOOL history -il $TESTPOOL1 | \
                            $GREP "pool '$TESTPOOL1' size:" | \
                            $GREP "vdev online" | \
-                           $GREP "(+${EX_3GB})" >/dev/null 2>&1
+                           $GREP "(+${expansion_size})" >/dev/null 2>&1
 
                        if [[ $? -ne 0 ]]; then
                                log_fail "pool $TESTPOOL is not autoexpand " \
index ce27e22320b8e955d6ce7491072b82dc4c99ff07..180bc85489d055ffff82b0062166539c1fb2f32e 100755 (executable)
@@ -27,6 +27,7 @@
 
 #
 # Copyright (c) 2012, 2015 by Delphix. All rights reserved.
+# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
 #
 
 . $STF_SUITE/include/libtest.shlib
 #
 #
 # 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"
@@ -56,9 +56,7 @@ 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
 }
 
@@ -66,13 +64,14 @@ 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)
 
@@ -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
@@ -106,30 +105,33 @@ for type in " " mirror raidz raidz2; do
        if [[ $zfs_expand_size -gt $zfs_prev_size ]]; then
        # check for zpool history for the pool size expansion
                if [[ $type == " " ]]; then
+                       typeset expansion_size=$(($exp_size-$org_size))
                        typeset size_addition=$($ZPOOL history -il $TESTPOOL1 \
                            | $GREP "pool '$TESTPOOL1' size:" | \
                            $GREP "vdev online" | \
-                           $GREP "(+${EX_1GB}" | wc -l)
+                           $GREP "(+${expansion_size}" | wc -l)
 
                        if [[ $size_addition -ne $i ]]; then
                                log_fail "pool $TESTPOOL1 is not autoexpand " \
                                    "after LUN expansion"
                        fi
                elif [[ $type == "mirror" ]]; then
+                       typeset expansion_size=$(($exp_size-$org_size))
                        $ZPOOL history -il $TESTPOOL1 | \
                            $GREP "pool '$TESTPOOL1' size:" | \
                            $GREP "vdev online" | \
-                           $GREP "(+${EX_1GB})" >/dev/null 2>&1
+                           $GREP "(+${expansion_size})" >/dev/null 2>&1
 
                        if [[ $? -ne 0 ]]; then
                                log_fail "pool $TESTPOOL1 is not autoexpand " \
                                    "after LUN expansion"
                        fi
                else
+                       typeset expansion_size=$((3*($exp_size-$org_size)))
                        $ZPOOL history -il $TESTPOOL1 | \
                            $GREP "pool '$TESTPOOL1' size:" | \
                            $GREP "vdev online" | \
-                           $GREP "(+${EX_3GB})" >/dev/null 2>&1
+                           $GREP "(+${expansion_size})" >/dev/null 2>&1
 
                        if [[ $? -ne 0 ]] ; then
                                log_fail "pool $TESTPOOL1 is not autoexpand " \
@@ -141,8 +143,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"