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.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or https://opensource.org/licenses/CDDL-1.0.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_create
/zpool_create.shlib
37 # Verify zpool add succeed when adding vdevs with matching redundancy.
40 # 1. Create several files == $MINVDEVSIZE.
41 # 2. Verify 'zpool add' succeeds with matching redundancy.
42 # 3. Verify 'zpool add' warns with differing redundancy.
43 # 4. Verify 'zpool add' warns with differing redundancy after removal.
46 verify_runnable
"global"
50 datasetexists
$TESTPOOL1 && destroy_pool
$TESTPOOL1
54 rm -f $TEST_BASE_DIR/vdev
$i
60 log_assert
"Verify 'zpool add' succeed with keywords combination."
63 # 1. Create several files == $MINVDEVSIZE.
66 log_must truncate
-s $MINVDEVSIZE $TEST_BASE_DIR/vdev
$i
68 eval vdev
$i=$TEST_BASE_DIR/vdev
$i
72 set -A redundancy0_create_args \
75 set -A redundancy1_create_args \
76 "mirror $vdev0 $vdev1" \
77 "raidz1 $vdev0 $vdev1"
79 set -A redundancy2_create_args \
80 "mirror $vdev0 $vdev1 $vdev2" \
81 "raidz2 $vdev0 $vdev1 $vdev2"
83 set -A redundancy3_create_args \
84 "mirror $vdev0 $vdev1 $vdev2 $vdev3" \
85 "raidz3 $vdev0 $vdev1 $vdev2 $vdev3"
87 set -A redundancy0_add_args \
91 set -A redundancy1_add_args \
92 "mirror $vdev5 $vdev6" \
93 "raidz1 $vdev5 $vdev6" \
94 "raidz1 $vdev5 $vdev6 mirror $vdev7 $vdev8" \
95 "mirror $vdev5 $vdev6 raidz1 $vdev7 $vdev8"
97 set -A redundancy2_add_args \
98 "mirror $vdev5 $vdev6 $vdev7" \
99 "raidz2 $vdev5 $vdev6 $vdev7"
101 set -A redundancy3_add_args \
102 "mirror $vdev5 $vdev6 $vdev7 $vdev8" \
103 "raidz3 $vdev5 $vdev6 $vdev7 $vdev8"
105 set -A log_args
"log" "$vdev4"
106 set -A cache_args
"cache" "$vdev4"
107 set -A spare_args
"spare" "$vdev4"
111 function zpool_create_add
113 typeset
-n create_args
=$1
114 typeset
-n add_args
=$2
117 while ((i
< ${#create_args[@]})); do
119 while ((j
< ${#add_args[@]})); do
120 log_must zpool create
$TESTPOOL1 ${create_args[$i]}
121 log_must zpool add
$TESTPOOL1 ${add_args[$j]}
122 log_must zpool destroy
-f $TESTPOOL1
130 function zpool_create_forced_add
132 typeset
-n create_args
=$1
133 typeset
-n add_args
=$2
136 while ((i
< ${#create_args[@]})); do
138 while ((j
< ${#add_args[@]})); do
139 log_must zpool create
$TESTPOOL1 ${create_args[$i]}
140 log_mustnot zpool add
$TESTPOOL1 ${add_args[$j]}
141 log_must zpool add
-f $TESTPOOL1 ${add_args[$j]}
142 log_must zpool destroy
-f $TESTPOOL1
150 function zpool_create_rm_add
152 typeset
-n create_args
=$1
153 typeset
-n add_args
=$2
154 typeset
-n rm_args
=$3
157 while ((i
< ${#create_args[@]})); do
159 while ((j
< ${#add_args[@]})); do
160 log_must zpool create
$TESTPOOL1 ${create_args[$i]}
161 log_must zpool add
$TESTPOOL1 ${rm_args[0]} ${rm_args[1]}
162 log_must zpool add
$TESTPOOL1 ${add_args[$j]}
163 log_must zpool remove
$TESTPOOL1 ${rm_args[1]}
164 log_mustnot zpool add
$TESTPOOL1 ${rm_args[1]}
165 log_must zpool add
$TESTPOOL1 ${rm_args[0]} ${rm_args[1]}
166 log_must zpool destroy
-f $TESTPOOL1
174 # 2. Verify 'zpool add' succeeds with matching redundancy.
175 zpool_create_add redundancy0_create_args redundancy0_add_args
176 zpool_create_add redundancy1_create_args redundancy1_add_args
177 zpool_create_add redundancy2_create_args redundancy2_add_args
178 zpool_create_add redundancy3_create_args redundancy3_add_args
180 # 3. Verify 'zpool add' warns with differing redundancy.
181 zpool_create_forced_add redundancy0_create_args redundancy1_add_args
182 zpool_create_forced_add redundancy0_create_args redundancy2_add_args
183 zpool_create_forced_add redundancy0_create_args redundancy3_add_args
185 zpool_create_forced_add redundancy1_create_args redundancy0_add_args
186 zpool_create_forced_add redundancy1_create_args redundancy2_add_args
187 zpool_create_forced_add redundancy1_create_args redundancy3_add_args
189 zpool_create_forced_add redundancy2_create_args redundancy0_add_args
190 zpool_create_forced_add redundancy2_create_args redundancy1_add_args
191 zpool_create_forced_add redundancy2_create_args redundancy3_add_args
193 zpool_create_forced_add redundancy3_create_args redundancy0_add_args
194 zpool_create_forced_add redundancy3_create_args redundancy1_add_args
195 zpool_create_forced_add redundancy3_create_args redundancy2_add_args
197 # 4. Verify 'zpool add' warns with differing redundancy after removal.
198 zpool_create_rm_add redundancy1_create_args redundancy1_add_args log_args
199 zpool_create_rm_add redundancy2_create_args redundancy2_add_args log_args
200 zpool_create_rm_add redundancy3_create_args redundancy3_add_args log_args
202 zpool_create_rm_add redundancy1_create_args redundancy1_add_args cache_args
203 zpool_create_rm_add redundancy2_create_args redundancy2_add_args cache_args
204 zpool_create_rm_add redundancy3_create_args redundancy3_add_args cache_args
206 zpool_create_rm_add redundancy1_create_args redundancy1_add_args spare_args
207 zpool_create_rm_add redundancy2_create_args redundancy2_add_args spare_args
208 zpool_create_rm_add redundancy3_create_args redundancy3_add_args spare_args
210 log_pass
"'zpool add' succeed with keywords combination."