]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh
Enable remaining tests
[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, 2016 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 # See issue: https://github.com/zfsonlinux/zfs/issues/5771
52 if is_linux; then
53 log_unsupported "Requires additional ZED support"
54 fi
55
56 function cleanup
57 {
58 if poolexists $TESTPOOL1; then
59 log_must zpool destroy $TESTPOOL1
60 fi
61
62 for i in 1 2 3; do
63 if datasetexists $VFS/vol$i; then
64 log_must zfs destroy $VFS/vol$i
65 fi
66 done
67 }
68
69 log_onexit cleanup
70
71 log_assert "zpool can be autoexpanded after set autoexpand=on on LUN expansion"
72
73 for i in 1 2 3; do
74 log_must zfs create -V $org_size $VFS/vol$i
75 done
76 block_device_wait
77
78 for type in " " mirror raidz raidz2; do
79
80 log_must zpool create -o autoexpand=on $TESTPOOL1 $type \
81 ${ZVOL_DEVDIR}/$VFS/vol1 ${ZVOL_DEVDIR}/$VFS/vol2 \
82 ${ZVOL_DEVDIR}/$VFS/vol3
83
84 typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)
85 if [[ $autoexp != "on" ]]; then
86 log_fail "zpool $TESTPOOL1 autoexpand should on but is $autoexp"
87 fi
88
89 typeset prev_size=$(get_pool_prop size $TESTPOOL1)
90 typeset zfs_prev_size=$(zfs get -p avail $TESTPOOL1 | tail -1 | \
91 awk '{print $3}')
92
93 for i in 1 2 3; do
94 log_must zfs set volsize=$exp_size $VFS/vol$i
95 done
96
97 sync
98 sleep 10
99 sync
100
101 typeset expand_size=$(get_pool_prop size $TESTPOOL1)
102 typeset zfs_expand_size=$(zfs get -p avail $TESTPOOL1 | tail -1 | \
103 awk '{print $3}')
104
105 log_note "$TESTPOOL1 $type has previous size: $prev_size and " \
106 "expanded size: $expand_size"
107 # compare available pool size from zfs
108 if [[ $zfs_expand_size > $zfs_prev_size ]]; then
109 # check for zpool history for the pool size expansion
110 if [[ $type == " " ]]; then
111 typeset expansion_size=$(($exp_size-$org_size))
112 typeset size_addition=$(zpool history -il $TESTPOOL1 |\
113 grep "pool '$TESTPOOL1' size:" | \
114 grep "vdev online" | \
115 grep "(+${expansion_size}" | wc -l)
116
117 if [[ $size_addition -ne $i ]]; then
118 log_fail "pool $TESTPOOL1 is not autoexpand " \
119 "after LUN expansion"
120 fi
121 elif [[ $type == "mirror" ]]; then
122 typeset expansion_size=$(($exp_size-$org_size))
123 zpool history -il $TESTPOOL1 | \
124 grep "pool '$TESTPOOL1' size:" | \
125 grep "vdev online" | \
126 grep "(+${expansion_size})" >/dev/null 2>&1
127
128 if [[ $? -ne 0 ]] ; then
129 log_fail "pool $TESTPOOL1 is not autoexpand " \
130 "after LUN expansion"
131 fi
132 else
133 typeset expansion_size=$((3*($exp_size-$org_size)))
134 zpool history -il $TESTPOOL1 | \
135 grep "pool '$TESTPOOL1' size:" | \
136 grep "vdev online" | \
137 grep "(+${expansion_size})" >/dev/null 2>&1
138
139 if [[ $? -ne 0 ]]; then
140 log_fail "pool $TESTPOOL is not autoexpand " \
141 "after LUN expansion"
142 fi
143 fi
144 else
145 log_fail "pool $TESTPOOL1 is not autoexpanded after LUN " \
146 "expansion"
147 fi
148
149 log_must zpool destroy $TESTPOOL1
150 for i in 1 2 3; do
151 log_must zfs set volsize=$org_size $VFS/vol$i
152 done
153
154 done
155 log_pass "zpool can be autoexpanded after set autoexpand=on on LUN expansion"