]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_010_pos.ksh
f949e8ae9c6d12e8758d4ce232e8fa23484c08dc
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cli_root / zpool_add / zpool_add_010_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_create/zpool_create.shlib
34
35 #
36 # DESCRIPTION:
37 # Verify zpool add succeed when adding vdevs with matching redundancy.
38 #
39 # STRATEGY:
40 # 1. Create base filesystem to hold virtual disk files.
41 # 2. Create several files == $MINVDEVSIZE.
42 # 3. Create pool with given redundancy.
43 # 3. Verify 'zpool add' succeed with with matching redundancy.
44 #
45
46 verify_runnable "global"
47
48 function cleanup
49 {
50 datasetexists $TESTPOOL1 && destroy_pool $TESTPOOL1
51 datasetexists $TESTPOOL && destroy_pool $TESTPOOL
52 }
53
54
55 log_assert "Verify 'zpool add' succeed with keywords combination."
56 log_onexit cleanup
57
58 create_pool $TESTPOOL $DISKS
59 mntpnt=$(get_prop mountpoint $TESTPOOL)
60
61 typeset -i i=0
62 while ((i < 10)); do
63 log_must truncate -s $MINVDEVSIZE $mntpnt/vdev$i
64
65 eval vdev$i=$mntpnt/vdev$i
66 ((i += 1))
67 done
68
69 set -A redundancy0_create_args \
70 "$vdev0"
71
72 set -A redundancy1_create_args \
73 "mirror $vdev0 $vdev1" \
74 "raidz1 $vdev0 $vdev1"
75
76 set -A redundancy2_create_args \
77 "mirror $vdev0 $vdev1 $vdev2" \
78 "raidz2 $vdev0 $vdev1 $vdev2"
79
80 set -A redundancy3_create_args \
81 "mirror $vdev0 $vdev1 $vdev2 $vdev3" \
82 "raidz3 $vdev0 $vdev1 $vdev2 $vdev3"
83
84 set -A redundancy0_add_args \
85 "$vdev5" \
86 "$vdev5 $vdev6"
87
88 set -A redundancy1_add_args \
89 "mirror $vdev5 $vdev6" \
90 "raidz1 $vdev5 $vdev6" \
91 "raidz1 $vdev5 $vdev6 mirror $vdev7 $vdev8" \
92 "mirror $vdev5 $vdev6 raidz1 $vdev7 $vdev8"
93
94 set -A redundancy2_add_args \
95 "mirror $vdev5 $vdev6 $vdev7" \
96 "raidz2 $vdev5 $vdev6 $vdev7"
97
98 set -A redundancy3_add_args \
99 "mirror $vdev5 $vdev6 $vdev7 $vdev8" \
100 "raidz3 $vdev5 $vdev6 $vdev7 $vdev8"
101
102 typeset -i j=0
103
104 function zpool_create_add
105 {
106 typeset -n create_args=$1
107 typeset -n add_args=$2
108
109 i=0
110 while ((i < ${#create_args[@]})); do
111 j=0
112 while ((j < ${#add_args[@]})); do
113 log_must zpool create $TESTPOOL1 ${create_args[$i]}
114 log_must zpool add $TESTPOOL1 ${add_args[$j]}
115 log_must zpool destroy -f $TESTPOOL1
116
117 ((j += 1))
118 done
119 ((i += 1))
120 done
121 }
122
123 function zpool_create_forced_add
124 {
125 typeset -n create_args=$1
126 typeset -n add_args=$2
127
128 i=0
129 while ((i < ${#create_args[@]})); do
130 j=0
131 while ((j < ${#add_args[@]})); do
132 log_must zpool create $TESTPOOL1 ${create_args[$i]}
133 log_mustnot zpool add $TESTPOOL1 ${add_args[$j]}
134 log_must zpool add -f $TESTPOOL1 ${add_args[$j]}
135 log_must zpool destroy -f $TESTPOOL1
136
137 ((j += 1))
138 done
139 ((i += 1))
140 done
141 }
142
143 zpool_create_add redundancy0_create_args redundancy0_add_args
144 zpool_create_add redundancy1_create_args redundancy1_add_args
145 zpool_create_add redundancy2_create_args redundancy2_add_args
146 zpool_create_add redundancy3_create_args redundancy3_add_args
147
148 zpool_create_forced_add redundancy0_create_args redundancy1_add_args
149 zpool_create_forced_add redundancy0_create_args redundancy2_add_args
150 zpool_create_forced_add redundancy0_create_args redundancy3_add_args
151
152 zpool_create_forced_add redundancy1_create_args redundancy0_add_args
153 zpool_create_forced_add redundancy1_create_args redundancy2_add_args
154 zpool_create_forced_add redundancy1_create_args redundancy3_add_args
155
156 zpool_create_forced_add redundancy2_create_args redundancy0_add_args
157 zpool_create_forced_add redundancy2_create_args redundancy1_add_args
158 zpool_create_forced_add redundancy2_create_args redundancy3_add_args
159
160 zpool_create_forced_add redundancy3_create_args redundancy0_add_args
161 zpool_create_forced_add redundancy3_create_args redundancy1_add_args
162 zpool_create_forced_add redundancy3_create_args redundancy2_add_args
163
164 log_pass "'zpool add' succeed with keywords combination."