]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh
Add the ZFS Test Suite
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_expand / zpool_expand_001_pos.ksh
1 #! /bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zpool_expand/zpool_expand.cfg
34
35 #
36 # DESCRIPTION:
37 # Once zpool set autoexpand=on poolname, zpool can autoexpand by
38 # Dynamic LUN Expansion
39 #
40 #
41 # STRATEGY:
42 # 1) Create a pool
43 # 2) Create volume on top of the pool
44 # 3) Create pool by using the zvols and set autoexpand=on
45 # 4) Expand the vol size by 'zfs set volsize'
46 # 5) Check that the pool size was expanded
47 #
48
49 verify_runnable "global"
50
51 function cleanup
52 {
53 if poolexists $TESTPOOL1; then
54 log_must $ZPOOL destroy $TESTPOOL1
55 fi
56
57 for i in 1 2 3; do
58 if datasetexists $VFS/vol$i; then
59 log_must $ZFS destroy $VFS/vol$i
60 fi
61 done
62 }
63
64 log_onexit cleanup
65
66 log_assert "zpool can be autoexpanded after set autoexpand=on on LUN expansion"
67
68 for i in 1 2 3; do
69 log_must $ZFS create -V $org_size $VFS/vol$i
70 done
71
72 for type in " " mirror raidz raidz2; do
73
74 log_must $ZPOOL create -o autoexpand=on $TESTPOOL1 $type \
75 ${ZVOL_DEVDIR}/$VFS/vol1 ${ZVOL_DEVDIR}/$VFS/vol2 \
76 ${ZVOL_DEVDIR}/$VFS/vol3
77
78 typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)
79 if [[ $autoexp != "on" ]]; then
80 log_fail "zpool $TESTPOOL1 autoexpand should on but is $autoexp"
81 fi
82
83 typeset prev_size=$(get_pool_prop size $TESTPOOL1)
84 typeset zfs_prev_size=$($ZFS get -p avail $TESTPOOL1 | $TAIL -1 | \
85 $AWK '{print $3}')
86
87 for i in 1 2 3; do
88 log_must $ZFS set volsize=$exp_size $VFS/vol$i
89 done
90
91 $SYNC
92 $SLEEP 10
93 $SYNC
94
95 typeset expand_size=$(get_pool_prop size $TESTPOOL1)
96 typeset zfs_expand_size=$($ZFS get -p avail $TESTPOOL1 | $TAIL -1 | \
97 $AWK '{print $3}')
98
99 log_note "$TESTPOOL1 $type has previous size: $prev_size and " \
100 "expanded size: $expand_size"
101 # compare available pool size from zfs
102 if [[ $zfs_expand_size > $zfs_prev_size ]]; then
103 # check for zpool history for the pool size expansion
104 if [[ $type == " " ]]; then
105 typeset size_addition=$($ZPOOL history -il $TESTPOOL1 |\
106 $GREP "pool '$TESTPOOL1' size:" | \
107 $GREP "vdev online" | \
108 $GREP "(+${EX_1GB}" | wc -l)
109
110 if [[ $size_addition -ne $i ]]; then
111 log_fail "pool $TESTPOOL1 is not autoexpand " \
112 "after LUN expansion"
113 fi
114 elif [[ $type == "mirror" ]]; then
115 $ZPOOL history -il $TESTPOOL1 | \
116 $GREP "pool '$TESTPOOL1' size:" | \
117 $GREP "vdev online" | \
118 $GREP "(+${EX_1GB})" >/dev/null 2>&1
119
120 if [[ $? -ne 0 ]] ; then
121 log_fail "pool $TESTPOOL1 is not autoexpand " \
122 "after LUN expansion"
123 fi
124 else
125 $ZPOOL history -il $TESTPOOL1 | \
126 $GREP "pool '$TESTPOOL1' size:" | \
127 $GREP "vdev online" | \
128 $GREP "(+${EX_3GB})" >/dev/null 2>&1
129
130 if [[ $? -ne 0 ]]; then
131 log_fail "pool $TESTPOOL is not autoexpand " \
132 "after LUN expansion"
133 fi
134 fi
135 else
136 log_fail "pool $TESTPOOL1 is not autoexpanded after LUN " \
137 "expansion"
138 fi
139
140 log_must $ZPOOL destroy $TESTPOOL1
141 for i in 1 2 3; do
142 log_must $ZFS set volsize=$org_size $VFS/vol$i
143 done
144
145 done
146 log_pass "zpool can be autoexpanded after set autoexpand=on on LUN expansion"