]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/zfs/zpool/create/option-f_inuse.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / zfs / zpool / create / option-f_inuse.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 dir=`dirname $0`
5 . ${dir}/../../misc.sh
6
7 echo "1..146"
8
9 disks_create 7
10 names_create 2
11
12 expect_ok ${ZPOOL} create ${name0} ${disk0}
13 expect_ok ${ZPOOL} export ${name0}
14 exp=`(
15   echo "invalid vdev specification"
16   echo "use '-f' to override the following errors:"
17   echo "${fdisk0} is part of exported pool '${name0}'"
18 )`
19 expect "${exp}" ${ZPOOL} create ${name1} ${disk0}
20 expect_fl ${ZPOOL} status -x ${name1}
21 expect_ok ${ZPOOL} create -f ${name1} ${disk0}
22 expect_ok ${ZPOOL} status -x ${name1}
23 expect_ok ${ZPOOL} destroy ${name1}
24
25 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
26 expect_ok ${ZPOOL} export ${name0}
27 exp=`(
28   echo "invalid vdev specification"
29   echo "use '-f' to override the following errors:"
30   echo "${fdisk0} is part of exported pool '${name0}'"
31 )`
32 expect "${exp}" ${ZPOOL} create ${name1} mirror ${disk0} ${disk1}
33 expect_fl ${ZPOOL} status -x ${name1}
34 expect_ok ${ZPOOL} create -f ${name1} mirror ${disk0} ${disk1}
35 expect_ok ${ZPOOL} status -x ${name1}
36 expect_ok ${ZPOOL} destroy ${name1}
37
38 expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
39 expect_ok ${ZPOOL} export ${name0}
40 exp=`(
41   echo "invalid vdev specification"
42   echo "use '-f' to override the following errors:"
43   echo "${fdisk0} is part of exported pool '${name0}'"
44 )`
45 expect "${exp}" ${ZPOOL} create ${name1} raidz1 ${disk0} ${disk1} ${disk2}
46 expect_fl ${ZPOOL} status -x ${name1}
47 expect_ok ${ZPOOL} create -f ${name1} raidz1 ${disk0} ${disk1} ${disk2}
48 expect_ok ${ZPOOL} status -x ${name1}
49 expect_ok ${ZPOOL} destroy ${name1}
50
51 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
52 expect_ok ${ZPOOL} export ${name0}
53 exp=`(
54   echo "invalid vdev specification"
55   echo "use '-f' to override the following errors:"
56   echo "${fdisk0} is part of exported pool '${name0}'"
57 )`
58 expect "${exp}" ${ZPOOL} create ${name1} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
59 expect_fl ${ZPOOL} status -x ${name1}
60 expect_ok ${ZPOOL} create -f ${name1} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
61 expect_ok ${ZPOOL} status -x ${name1}
62 expect_ok ${ZPOOL} destroy ${name1}
63
64 expect_ok ${ZPOOL} create ${name0} ${disk0} log ${disk1}
65 expect_ok ${ZPOOL} export ${name0}
66 exp=`(
67   echo "invalid vdev specification"
68   echo "use '-f' to override the following errors:"
69   echo "${fdisk0} is part of exported pool '${name0}'"
70 )`
71 expect "${exp}" ${ZPOOL} create ${name1} ${disk0} log ${disk1}
72 expect_fl ${ZPOOL} status -x ${name1}
73 expect_ok ${ZPOOL} create -f ${name1} ${disk0} log ${disk1}
74 expect_ok ${ZPOOL} status -x ${name1}
75 expect_ok ${ZPOOL} destroy ${name1}
76
77 expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
78 expect_ok ${ZPOOL} export ${name0}
79 exp=`(
80   echo "invalid vdev specification"
81   echo "use '-f' to override the following errors:"
82   echo "${fdisk0} is part of exported pool '${name0}'"
83 )`
84 expect "${exp}" ${ZPOOL} create ${name1} ${disk0} log mirror ${disk1} ${disk2}
85 expect_fl ${ZPOOL} status -x ${name1}
86 expect_ok ${ZPOOL} create -f ${name1} ${disk0} log mirror ${disk1} ${disk2}
87 expect_ok ${ZPOOL} status -x ${name1}
88 expect_ok ${ZPOOL} destroy ${name1}
89
90 expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
91 expect_ok ${ZPOOL} export ${name0}
92 exp=`(
93   echo "invalid vdev specification"
94   echo "use '-f' to override the following errors:"
95   echo "${fdisk0} is part of exported pool '${name0}'"
96 )`
97 expect "${exp}" ${ZPOOL} create ${name1} ${disk0} cache ${disk1}
98 expect_fl ${ZPOOL} status -x ${name1}
99 expect_ok ${ZPOOL} create -f ${name1} ${disk0} cache ${disk1}
100 expect_ok ${ZPOOL} status -x ${name1}
101 expect_ok ${ZPOOL} destroy ${name1}
102
103 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
104 expect_ok ${ZPOOL} offline ${name0} ${disk1}
105 expect_ok ${ZPOOL} export ${name0}
106 exp=`(
107   echo "invalid vdev specification"
108   echo "use '-f' to override the following errors:"
109   echo "${fdisk1} is part of potentially active pool '${name0}'"
110 )`
111 expect "${exp}" ${ZPOOL} create ${name1} mirror ${disk1} ${disk2}
112 expect_fl ${ZPOOL} status -x ${name1}
113 expect_ok ${ZPOOL} create -f ${name1} mirror ${disk1} ${disk2}
114 expect_ok ${ZPOOL} status -x ${name1}
115 expect_ok ${ZPOOL} destroy ${name1}
116 expect_ok ${ZPOOL} import ${name0}
117 expect_ok ${ZPOOL} destroy ${name0}
118
119 expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
120 expect_ok ${ZPOOL} offline ${name0} ${disk2}
121 expect_ok ${ZPOOL} export ${name0}
122 exp=`(
123   echo "invalid vdev specification"
124   echo "use '-f' to override the following errors:"
125   echo "${fdisk2} is part of potentially active pool '${name0}'"
126 )`
127 expect "${exp}" ${ZPOOL} create ${name1} raidz1 ${disk2} ${disk3} ${disk4}
128 expect_fl ${ZPOOL} status -x ${name1}
129 expect_ok ${ZPOOL} create -f ${name1} raidz1 ${disk2} ${disk3} ${disk4}
130 expect_ok ${ZPOOL} status -x ${name1}
131 expect_ok ${ZPOOL} destroy ${name1}
132 expect_ok ${ZPOOL} import ${name0}
133 expect_ok ${ZPOOL} destroy ${name0}
134
135 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
136 expect_ok ${ZPOOL} offline ${name0} ${disk3}
137 expect_ok ${ZPOOL} export ${name0}
138 exp=`(
139   echo "invalid vdev specification"
140   echo "use '-f' to override the following errors:"
141   echo "${fdisk3} is part of potentially active pool '${name0}'"
142 )`
143 expect "${exp}" ${ZPOOL} create ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
144 expect_fl ${ZPOOL} status -x ${name1}
145 expect_ok ${ZPOOL} create -f ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
146 expect_ok ${ZPOOL} status -x ${name1}
147 expect_ok ${ZPOOL} destroy ${name1}
148 expect_ok ${ZPOOL} import ${name0}
149 expect_ok ${ZPOOL} destroy ${name0}
150
151 expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
152 expect_ok ${ZPOOL} offline ${name0} ${disk2}
153 expect_ok ${ZPOOL} export ${name0}
154 exp=`(
155   echo "invalid vdev specification"
156   echo "use '-f' to override the following errors:"
157   echo "${fdisk2} is part of potentially active pool '${name0}'"
158 )`
159 expect "${exp}" ${ZPOOL} create ${name1} ${disk3} log mirror ${disk2} ${disk4}
160 expect_fl ${ZPOOL} status -x ${name1}
161 expect_ok ${ZPOOL} create -f ${name1} ${disk3} log mirror ${disk2} ${disk4}
162 expect_ok ${ZPOOL} status -x ${name1}
163 expect_ok ${ZPOOL} destroy ${name1}
164 expect_ok ${ZPOOL} import ${name0}
165 expect_ok ${ZPOOL} destroy ${name0}
166
167 expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
168 expect_ok ${ZPOOL} offline ${name0} ${disk1}
169 expect_ok ${ZPOOL} export ${name0}
170 exp=`(
171   echo "invalid vdev specification"
172   echo "use '-f' to override the following errors:"
173   echo "${fdisk1} is part of potentially active pool '${name0}'"
174 )`
175 add_msg="# TODO It shouldn't be possible to use offlined cache vdev."
176 expect "${exp}" ${ZPOOL} create ${name1} ${disk2} cache ${disk1}
177 expect_fl ${ZPOOL} status -x ${name1}
178 expect_ok ${ZPOOL} create -f ${name1} ${disk2} cache ${disk1}
179 add_msg=""
180 expect_ok ${ZPOOL} status -x ${name1}
181 expect_ok ${ZPOOL} destroy ${name1}
182 expect_ok ${ZPOOL} import ${name0}
183 expect_ok ${ZPOOL} destroy ${name0}
184
185 expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
186 expect_ok ${ZPOOL} offline ${name0} ${disk1}
187 exp=`(
188   echo "invalid vdev specification"
189   echo "use '-f' to override the following errors:"
190   echo "${fdisk1} is part of active pool '${name0}'"
191 )`
192 expect "${exp}" ${ZPOOL} create ${name1} mirror ${disk1} ${disk2}
193 expect_fl ${ZPOOL} status -x ${name1}
194 exp=`(
195   echo "invalid vdev specification"
196   echo "the following errors must be manually repaired:"
197   echo "${fdisk1} is part of active pool '${name0}'"
198 )`
199 expect "${exp}" ${ZPOOL} create -f ${name1} mirror ${disk1} ${disk2}
200 expect_fl ${ZPOOL} status -x ${name1}
201 expect_ok ${ZPOOL} online ${name0} ${disk1}
202 expect_ok ${ZPOOL} destroy ${name0}
203
204 expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
205 expect_ok ${ZPOOL} offline ${name0} ${disk2}
206 exp=`(
207   echo "invalid vdev specification"
208   echo "use '-f' to override the following errors:"
209   echo "${fdisk2} is part of active pool '${name0}'"
210 )`
211 expect "${exp}" ${ZPOOL} create ${name1} raidz1 ${disk2} ${disk3} ${disk4}
212 expect_fl ${ZPOOL} status -x ${name1}
213 exp=`(
214   echo "invalid vdev specification"
215   echo "the following errors must be manually repaired:"
216   echo "${fdisk2} is part of active pool '${name0}'"
217 )`
218 expect "${exp}" ${ZPOOL} create -f ${name1} raidz1 ${disk2} ${disk3} ${disk4}
219 expect_fl ${ZPOOL} status -x ${name1}
220 expect_ok ${ZPOOL} online ${name0} ${disk2}
221 expect_ok ${ZPOOL} destroy ${name0}
222
223 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
224 expect_ok ${ZPOOL} offline ${name0} ${disk3}
225 exp=`(
226   echo "invalid vdev specification"
227   echo "use '-f' to override the following errors:"
228   echo "${fdisk3} is part of active pool '${name0}'"
229 )`
230 expect "${exp}" ${ZPOOL} create ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
231 expect_fl ${ZPOOL} status -x ${name1}
232 exp=`(
233   echo "invalid vdev specification"
234   echo "the following errors must be manually repaired:"
235   echo "${fdisk3} is part of active pool '${name0}'"
236 )`
237 expect "${exp}" ${ZPOOL} create -f ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
238 expect_fl ${ZPOOL} status -x ${name1}
239 expect_ok ${ZPOOL} online ${name0} ${disk3}
240 expect_ok ${ZPOOL} destroy ${name0}
241
242 expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
243 expect_ok ${ZPOOL} offline ${name0} ${disk2}
244 exp=`(
245   echo "invalid vdev specification"
246   echo "use '-f' to override the following errors:"
247   echo "${fdisk2} is part of active pool '${name0}'"
248 )`
249 expect "${exp}" ${ZPOOL} create ${name1} ${disk3} log mirror ${disk2} ${disk4}
250 expect_fl ${ZPOOL} status -x ${name1}
251 exp=`(
252   echo "invalid vdev specification"
253   echo "the following errors must be manually repaired:"
254   echo "${fdisk2} is part of active pool '${name0}'"
255 )`
256 expect "${exp}" ${ZPOOL} create -f ${name1} ${disk3} log mirror ${disk2} ${disk4}
257 expect_fl ${ZPOOL} status -x ${name1}
258 expect_ok ${ZPOOL} online ${name0} ${disk2}
259 expect_ok ${ZPOOL} destroy ${name0}
260
261 expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
262 expect_ok ${ZPOOL} offline ${name0} ${disk1}
263 exp=`(
264   echo "invalid vdev specification"
265   echo "use '-f' to override the following errors:"
266   echo "${fdisk1} is part of active pool '${name0}'"
267 )`
268 add_msg="# TODO It reports that ${fdisk1} is part of unknown pool."
269 expect "${exp}" ${ZPOOL} create ${name1} ${disk2} cache ${disk1}
270 add_msg=""
271 expect_fl ${ZPOOL} status -x ${name1}
272 exp=`(
273   echo "invalid vdev specification"
274   echo "the following errors must be manually repaired:"
275   echo "${fdisk1} is part of active pool '${name0}'"
276 )`
277 add_msg="# TODO It reports that ${fdisk1} is used twice."
278 expect "${exp}" ${ZPOOL} create -f ${name1} ${disk2} cache ${disk1}
279 add_msg=""
280 expect_fl ${ZPOOL} status -x ${name1}
281 expect_ok ${ZPOOL} online ${name0} ${disk1}
282 expect_ok ${ZPOOL} destroy ${name0}
283
284 expect_ok ${ZPOOL} create ${name0} ${disk0}
285 expect_ok ${ZPOOL} export ${name0}
286 exp=`(
287   echo "invalid vdev specification"
288   echo "use '-f' to override the following errors:"
289   echo "${fdisk0} is part of exported pool '${name0}'"
290 )`
291 expect "${exp}" ${ZPOOL} create ${name0} ${disk0}
292 expect_fl ${ZPOOL} status -x ${name0}
293 expect_ok ${ZPOOL} create -f ${name0} ${disk0}
294 expect_ok ${ZPOOL} status -x ${name0}
295 expect_ok ${ZPOOL} destroy ${name0}
296
297 disks_destroy