]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh
MFC r353117-r353118, r353281-r353282, r353284-r353289, r353309-r353310, r353360-r3533...
[FreeBSD/FreeBSD.git] / tests / sys / cddl / zfs / tests / hotspare / hotspare_test.sh
1 # CDDL HEADER START
2 #
3 # The contents of this file are subject to the terms of the
4 # Common Development and Distribution License (the "License").
5 # You may not use this file except in compliance with the License.
6 #
7 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8 # or http://www.opensolaris.org/os/licensing.
9 # See the License for the specific language governing permissions
10 # and limitations under the License.
11 #
12 # When distributing Covered Code, include this CDDL HEADER in each
13 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14 # If applicable, add the following below this CDDL HEADER, with the
15 # fields enclosed by brackets "[]" replaced with your own identifying
16 # information: Portions Copyright [yyyy] [name of copyright owner]
17 #
18 # CDDL HEADER END
19 #
20
21 # $FreeBSD$
22
23 #
24 # Copyright 2012 Spectra Logic.  All rights reserved.
25 # Use is subject to license terms.
26 #
27
28
29 atf_test_case hotspare_add_001_pos cleanup
30 hotspare_add_001_pos_head()
31 {
32         atf_set "descr" "'zpool add <pool> spare <vdev> ...' can add devices to the pool."
33         atf_set "timeout" 3600
34 }
35 hotspare_add_001_pos_body()
36 {
37         . $(atf_get_srcdir)/../../include/default.cfg
38         . $(atf_get_srcdir)/hotspare.kshlib
39         . $(atf_get_srcdir)/hotspare.cfg
40
41         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
42         ksh93 $(atf_get_srcdir)/hotspare_add_001_pos.ksh || atf_fail "Testcase failed"
43 }
44 hotspare_add_001_pos_cleanup()
45 {
46         . $(atf_get_srcdir)/../../include/default.cfg
47         . $(atf_get_srcdir)/hotspare.kshlib
48         . $(atf_get_srcdir)/hotspare.cfg
49
50         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
51 }
52
53
54 atf_test_case hotspare_add_002_pos cleanup
55 hotspare_add_002_pos_head()
56 {
57         atf_set "descr" "'zpool add <pool> spare <vdev> ...' can add devices to the pool while it has spare-in device."
58         atf_set "require.progs"  zpool
59         atf_set "timeout" 3600
60 }
61 hotspare_add_002_pos_body()
62 {
63         . $(atf_get_srcdir)/../../include/default.cfg
64         . $(atf_get_srcdir)/hotspare.kshlib
65         . $(atf_get_srcdir)/hotspare.cfg
66
67         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
68         ksh93 $(atf_get_srcdir)/hotspare_add_002_pos.ksh || atf_fail "Testcase failed"
69 }
70 hotspare_add_002_pos_cleanup()
71 {
72         . $(atf_get_srcdir)/../../include/default.cfg
73         . $(atf_get_srcdir)/hotspare.kshlib
74         . $(atf_get_srcdir)/hotspare.cfg
75
76         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
77 }
78
79
80 atf_test_case hotspare_add_003_neg cleanup
81 hotspare_add_003_neg_head()
82 {
83         atf_set "descr" "'zpool add [-f]' with hot spares should fail with inapplicable scenarios."
84         atf_set "require.progs"  zpool
85         atf_set "timeout" 3600
86 }
87 hotspare_add_003_neg_body()
88 {
89         . $(atf_get_srcdir)/../../include/default.cfg
90         . $(atf_get_srcdir)/hotspare.kshlib
91         . $(atf_get_srcdir)/hotspare.cfg
92
93         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
94         ksh93 $(atf_get_srcdir)/hotspare_add_003_neg.ksh || atf_fail "Testcase failed"
95 }
96 hotspare_add_003_neg_cleanup()
97 {
98         . $(atf_get_srcdir)/../../include/default.cfg
99         . $(atf_get_srcdir)/hotspare.kshlib
100         . $(atf_get_srcdir)/hotspare.cfg
101
102         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
103 }
104
105
106 atf_test_case hotspare_add_004_neg cleanup
107 hotspare_add_004_neg_head()
108 {
109         atf_set "descr" "'zpool add [-f]' will not allow a swap device to be used as a hotspare'"
110         atf_set "require.progs"  zpool swapon swapoff swapctl
111 }
112 hotspare_add_004_neg_body()
113 {
114         . $(atf_get_srcdir)/../../include/default.cfg
115         . $(atf_get_srcdir)/hotspare.kshlib
116         . $(atf_get_srcdir)/hotspare.cfg
117
118         verify_disk_count "$DISKS" 2
119         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
120         ksh93 $(atf_get_srcdir)/hotspare_add_004_neg.ksh || atf_fail "Testcase failed"
121 }
122 hotspare_add_004_neg_cleanup()
123 {
124         . $(atf_get_srcdir)/../../include/default.cfg
125         . $(atf_get_srcdir)/hotspare.kshlib
126         . $(atf_get_srcdir)/hotspare.cfg
127
128         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
129 }
130
131
132 atf_test_case hotspare_clone_001_pos cleanup
133 hotspare_clone_001_pos_head()
134 {
135         atf_set "descr" "'zpool detach <pool> <vdev> ...' against hotspare should do no harm to clone."
136         atf_set "require.progs"  zfs zpool sum
137         atf_set "timeout" 3600
138 }
139 hotspare_clone_001_pos_body()
140 {
141         . $(atf_get_srcdir)/../../include/default.cfg
142         . $(atf_get_srcdir)/hotspare.kshlib
143         . $(atf_get_srcdir)/hotspare.cfg
144
145         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
146         ksh93 $(atf_get_srcdir)/hotspare_clone_001_pos.ksh || atf_fail "Testcase failed"
147 }
148 hotspare_clone_001_pos_cleanup()
149 {
150         . $(atf_get_srcdir)/../../include/default.cfg
151         . $(atf_get_srcdir)/hotspare.kshlib
152         . $(atf_get_srcdir)/hotspare.cfg
153
154         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
155 }
156
157
158 atf_test_case hotspare_clone_002_pos cleanup
159 hotspare_clone_002_pos_head()
160 {
161         atf_set "descr" "'zpool detach <pool> <vdev> ...' against basic vdev should do no harm to clone."
162         atf_set "require.progs"  zfs zpool sum
163         atf_set "timeout" 3600
164 }
165 hotspare_clone_002_pos_body()
166 {
167         . $(atf_get_srcdir)/../../include/default.cfg
168         . $(atf_get_srcdir)/hotspare.kshlib
169         . $(atf_get_srcdir)/hotspare.cfg
170
171         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
172         ksh93 $(atf_get_srcdir)/hotspare_clone_002_pos.ksh || atf_fail "Testcase failed"
173 }
174 hotspare_clone_002_pos_cleanup()
175 {
176         . $(atf_get_srcdir)/../../include/default.cfg
177         . $(atf_get_srcdir)/hotspare.kshlib
178         . $(atf_get_srcdir)/hotspare.cfg
179
180         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
181 }
182
183
184 atf_test_case hotspare_create_001_neg cleanup
185 hotspare_create_001_neg_head()
186 {
187         atf_set "descr" "'zpool create [-f]' with hot spares should be failedwith inapplicable scenarios."
188         atf_set "require.progs"  dumpadm zpool
189         atf_set "timeout" 3600
190 }
191 hotspare_create_001_neg_body()
192 {
193         . $(atf_get_srcdir)/../../include/default.cfg
194         . $(atf_get_srcdir)/hotspare.kshlib
195         . $(atf_get_srcdir)/hotspare.cfg
196
197         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
198         ksh93 $(atf_get_srcdir)/hotspare_create_001_neg.ksh || atf_fail "Testcase failed"
199 }
200 hotspare_create_001_neg_cleanup()
201 {
202         . $(atf_get_srcdir)/../../include/default.cfg
203         . $(atf_get_srcdir)/hotspare.kshlib
204         . $(atf_get_srcdir)/hotspare.cfg
205
206         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
207 }
208
209
210 atf_test_case hotspare_detach_001_pos cleanup
211 hotspare_detach_001_pos_head()
212 {
213         atf_set "descr" "'zpool detach <pool> <vdev> ...' should deactivate the spared-in hot spare device successfully."
214         atf_set "require.progs"  zpool
215         atf_set "timeout" 3600
216 }
217 hotspare_detach_001_pos_body()
218 {
219         . $(atf_get_srcdir)/../../include/default.cfg
220         . $(atf_get_srcdir)/hotspare.kshlib
221         . $(atf_get_srcdir)/hotspare.cfg
222
223         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
224         ksh93 $(atf_get_srcdir)/hotspare_detach_001_pos.ksh || atf_fail "Testcase failed"
225 }
226 hotspare_detach_001_pos_cleanup()
227 {
228         . $(atf_get_srcdir)/../../include/default.cfg
229         . $(atf_get_srcdir)/hotspare.kshlib
230         . $(atf_get_srcdir)/hotspare.cfg
231
232         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
233 }
234
235
236 atf_test_case hotspare_detach_002_pos cleanup
237 hotspare_detach_002_pos_head()
238 {
239         atf_set "descr" "'zpool detach <pool> <vdev> ...' against a functioning device that have spared should take the hot spare permanently swapping in successfully."
240         atf_set "require.progs"  zpool
241         atf_set "timeout" 3600
242 }
243 hotspare_detach_002_pos_body()
244 {
245         . $(atf_get_srcdir)/../../include/default.cfg
246         . $(atf_get_srcdir)/hotspare.kshlib
247         . $(atf_get_srcdir)/hotspare.cfg
248
249         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
250         ksh93 $(atf_get_srcdir)/hotspare_detach_002_pos.ksh || atf_fail "Testcase failed"
251 }
252 hotspare_detach_002_pos_cleanup()
253 {
254         . $(atf_get_srcdir)/../../include/default.cfg
255         . $(atf_get_srcdir)/hotspare.kshlib
256         . $(atf_get_srcdir)/hotspare.cfg
257
258         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
259 }
260
261
262 atf_test_case hotspare_detach_003_pos cleanup
263 hotspare_detach_003_pos_head()
264 {
265         atf_set "descr" "'zpool replace <pool> <vdev> <ndev>' against a functioning device that have spared should complete and the hot spare should return to available."
266         atf_set "require.progs"  zpool
267         atf_set "timeout" 3600
268 }
269 hotspare_detach_003_pos_body()
270 {
271         . $(atf_get_srcdir)/../../include/default.cfg
272         . $(atf_get_srcdir)/hotspare.kshlib
273         . $(atf_get_srcdir)/hotspare.cfg
274
275         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
276         ksh93 $(atf_get_srcdir)/hotspare_detach_003_pos.ksh || atf_fail "Testcase failed"
277 }
278 hotspare_detach_003_pos_cleanup()
279 {
280         . $(atf_get_srcdir)/../../include/default.cfg
281         . $(atf_get_srcdir)/hotspare.kshlib
282         . $(atf_get_srcdir)/hotspare.cfg
283
284         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
285 }
286
287
288 atf_test_case hotspare_detach_004_pos cleanup
289 hotspare_detach_004_pos_head()
290 {
291         atf_set "descr" "'zpool replace <pool> <vdev> <ndev>' against a hot spare device that have been activated should successful while the another dev is a available hot spare."
292         atf_set "require.progs"  zpool
293         atf_set "timeout" 3600
294 }
295 hotspare_detach_004_pos_body()
296 {
297         . $(atf_get_srcdir)/../../include/default.cfg
298         . $(atf_get_srcdir)/hotspare.kshlib
299         . $(atf_get_srcdir)/hotspare.cfg
300
301         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
302         ksh93 $(atf_get_srcdir)/hotspare_detach_004_pos.ksh || atf_fail "Testcase failed"
303 }
304 hotspare_detach_004_pos_cleanup()
305 {
306         . $(atf_get_srcdir)/../../include/default.cfg
307         . $(atf_get_srcdir)/hotspare.kshlib
308         . $(atf_get_srcdir)/hotspare.cfg
309
310         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
311 }
312
313
314 atf_test_case hotspare_detach_005_neg cleanup
315 hotspare_detach_005_neg_head()
316 {
317         atf_set "descr" "'zpool detach <pool> <vdev>' against a hot spare device that NOT activated should fail and issue an error message."
318         atf_set "require.progs"  zpool
319         atf_set "timeout" 3600
320 }
321 hotspare_detach_005_neg_body()
322 {
323         . $(atf_get_srcdir)/../../include/default.cfg
324         . $(atf_get_srcdir)/hotspare.kshlib
325         . $(atf_get_srcdir)/hotspare.cfg
326
327         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
328         ksh93 $(atf_get_srcdir)/hotspare_detach_005_neg.ksh || atf_fail "Testcase failed"
329 }
330 hotspare_detach_005_neg_cleanup()
331 {
332         . $(atf_get_srcdir)/../../include/default.cfg
333         . $(atf_get_srcdir)/hotspare.kshlib
334         . $(atf_get_srcdir)/hotspare.cfg
335
336         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
337 }
338
339
340 atf_test_case hotspare_export_001_neg cleanup
341 hotspare_export_001_neg_head()
342 {
343         atf_set "descr" "export pool that using shared hotspares will fail"
344         atf_set "require.progs"  zpool
345         atf_set "timeout" 3600
346 }
347 hotspare_export_001_neg_body()
348 {
349         . $(atf_get_srcdir)/../../include/default.cfg
350         . $(atf_get_srcdir)/hotspare.kshlib
351         . $(atf_get_srcdir)/hotspare.cfg
352
353         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
354         ksh93 $(atf_get_srcdir)/hotspare_export_001_neg.ksh || atf_fail "Testcase failed"
355 }
356 hotspare_export_001_neg_cleanup()
357 {
358         . $(atf_get_srcdir)/../../include/default.cfg
359         . $(atf_get_srcdir)/hotspare.kshlib
360         . $(atf_get_srcdir)/hotspare.cfg
361
362         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
363 }
364
365
366 atf_test_case hotspare_import_001_pos cleanup
367 hotspare_import_001_pos_head()
368 {
369         atf_set "descr" "'zpool export/import <pool>' should runs successfully regardless the hotspare is only in list, activated, or offline."
370         atf_set "require.progs"  zpool sum
371         atf_set "timeout" 3600
372 }
373 hotspare_import_001_pos_body()
374 {
375         . $(atf_get_srcdir)/../../include/default.cfg
376         . $(atf_get_srcdir)/hotspare.kshlib
377         . $(atf_get_srcdir)/hotspare.cfg
378
379         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
380         ksh93 $(atf_get_srcdir)/hotspare_import_001_pos.ksh || atf_fail "Testcase failed"
381 }
382 hotspare_import_001_pos_cleanup()
383 {
384         . $(atf_get_srcdir)/../../include/default.cfg
385         . $(atf_get_srcdir)/hotspare.kshlib
386         . $(atf_get_srcdir)/hotspare.cfg
387
388         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
389 }
390
391
392 atf_test_case hotspare_onoffline_003_neg cleanup
393 hotspare_onoffline_003_neg_head()
394 {
395         atf_set "descr" "'zpool offline/online <pool> <vdev>' should fail on inactive spares"
396         atf_set "require.progs"  zpool zdb
397         atf_set "timeout" 3600
398 }
399 hotspare_onoffline_003_neg_body()
400 {
401         . $(atf_get_srcdir)/../../include/default.cfg
402         . $(atf_get_srcdir)/hotspare.kshlib
403         . $(atf_get_srcdir)/hotspare.cfg
404
405         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
406         ksh93 $(atf_get_srcdir)/hotspare_onoffline_003_neg.ksh || atf_fail "Testcase failed"
407 }
408 hotspare_onoffline_003_neg_cleanup()
409 {
410         . $(atf_get_srcdir)/../../include/default.cfg
411         . $(atf_get_srcdir)/hotspare.kshlib
412         . $(atf_get_srcdir)/hotspare.cfg
413
414         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
415 }
416
417
418 atf_test_case hotspare_onoffline_004_neg cleanup
419 hotspare_onoffline_004_neg_head()
420 {
421         atf_set "descr" "'zpool offline/online <pool> <vdev>' against a spared basic vdev during I/O completes."
422         atf_set "require.progs"  zfs zpool zdb
423         atf_set "timeout" 3600
424 }
425 hotspare_onoffline_004_neg_body()
426 {
427         . $(atf_get_srcdir)/../../include/default.cfg
428         . $(atf_get_srcdir)/hotspare.kshlib
429         . $(atf_get_srcdir)/hotspare.cfg
430
431         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
432         ksh93 $(atf_get_srcdir)/hotspare_onoffline_004_neg.ksh || atf_fail "Testcase failed"
433 }
434 hotspare_onoffline_004_neg_cleanup()
435 {
436         . $(atf_get_srcdir)/../../include/default.cfg
437         . $(atf_get_srcdir)/hotspare.kshlib
438         . $(atf_get_srcdir)/hotspare.cfg
439
440         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
441 }
442
443
444 atf_test_case hotspare_remove_001_pos cleanup
445 hotspare_remove_001_pos_head()
446 {
447         atf_set "descr" "'zpool remove <pool> <vdev> ...' can remove spare device from the pool."
448         atf_set "require.progs"  zpool
449         atf_set "timeout" 3600
450 }
451 hotspare_remove_001_pos_body()
452 {
453         . $(atf_get_srcdir)/../../include/default.cfg
454         . $(atf_get_srcdir)/hotspare.kshlib
455         . $(atf_get_srcdir)/hotspare.cfg
456
457         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
458         ksh93 $(atf_get_srcdir)/hotspare_remove_001_pos.ksh || atf_fail "Testcase failed"
459 }
460 hotspare_remove_001_pos_cleanup()
461 {
462         . $(atf_get_srcdir)/../../include/default.cfg
463         . $(atf_get_srcdir)/hotspare.kshlib
464         . $(atf_get_srcdir)/hotspare.cfg
465
466         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
467 }
468
469
470 atf_test_case hotspare_remove_002_neg cleanup
471 hotspare_remove_002_neg_head()
472 {
473         atf_set "descr" "'zpool remove <pool> <vdev> ...' should fail with inapplicable scenarios."
474         atf_set "require.progs"  zpool
475         atf_set "timeout" 3600
476 }
477 hotspare_remove_002_neg_body()
478 {
479         . $(atf_get_srcdir)/../../include/default.cfg
480         . $(atf_get_srcdir)/hotspare.kshlib
481         . $(atf_get_srcdir)/hotspare.cfg
482
483         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
484         ksh93 $(atf_get_srcdir)/hotspare_remove_002_neg.ksh || atf_fail "Testcase failed"
485 }
486 hotspare_remove_002_neg_cleanup()
487 {
488         . $(atf_get_srcdir)/../../include/default.cfg
489         . $(atf_get_srcdir)/hotspare.kshlib
490         . $(atf_get_srcdir)/hotspare.cfg
491
492         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
493 }
494
495
496 atf_test_case hotspare_remove_003_neg cleanup
497 hotspare_remove_003_neg_head()
498 {
499         atf_set "descr" "Executing 'zpool remove' with bad options fails"
500         atf_set "require.progs"  zpool
501         atf_set "timeout" 3600
502 }
503 hotspare_remove_003_neg_body()
504 {
505         . $(atf_get_srcdir)/../../include/default.cfg
506         . $(atf_get_srcdir)/hotspare.kshlib
507         . $(atf_get_srcdir)/hotspare.cfg
508
509         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
510         ksh93 $(atf_get_srcdir)/hotspare_remove_003_neg.ksh || atf_fail "Testcase failed"
511 }
512 hotspare_remove_003_neg_cleanup()
513 {
514         . $(atf_get_srcdir)/../../include/default.cfg
515         . $(atf_get_srcdir)/hotspare.kshlib
516         . $(atf_get_srcdir)/hotspare.cfg
517
518         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
519 }
520
521
522 atf_test_case hotspare_remove_004_pos cleanup
523 hotspare_remove_004_pos_head()
524 {
525         atf_set "descr" "'zpool remove <pool> <vdev> ...' can remove spare device from the pool."
526         atf_set "require.progs"  zpool
527         atf_set "timeout" 3600
528 }
529 hotspare_remove_004_pos_body()
530 {
531         . $(atf_get_srcdir)/../../include/default.cfg
532         . $(atf_get_srcdir)/hotspare.kshlib
533         . $(atf_get_srcdir)/hotspare.cfg
534
535         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
536         ksh93 $(atf_get_srcdir)/hotspare_remove_004_pos.ksh || atf_fail "Testcase failed"
537 }
538 hotspare_remove_004_pos_cleanup()
539 {
540         . $(atf_get_srcdir)/../../include/default.cfg
541         . $(atf_get_srcdir)/hotspare.kshlib
542         . $(atf_get_srcdir)/hotspare.cfg
543
544         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
545 }
546
547
548 atf_test_case hotspare_replace_001_neg cleanup
549 hotspare_replace_001_neg_head()
550 {
551         atf_set "descr" "'zpool replace <pool> <odev> <ndev>' should fail with inapplicable scenarios."
552         atf_set "require.progs"  zpool
553         atf_set "timeout" 3600
554 }
555 hotspare_replace_001_neg_body()
556 {
557         . $(atf_get_srcdir)/../../include/default.cfg
558         . $(atf_get_srcdir)/hotspare.kshlib
559         . $(atf_get_srcdir)/hotspare.cfg
560
561         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
562         ksh93 $(atf_get_srcdir)/hotspare_replace_001_neg.ksh || atf_fail "Testcase failed"
563 }
564 hotspare_replace_001_neg_cleanup()
565 {
566         . $(atf_get_srcdir)/../../include/default.cfg
567         . $(atf_get_srcdir)/hotspare.kshlib
568         . $(atf_get_srcdir)/hotspare.cfg
569
570         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
571 }
572
573
574 atf_test_case hotspare_replace_002_neg cleanup
575 hotspare_replace_002_neg_head()
576 {
577         atf_set "descr" "'zpool replace <pool> <odev> <ndev>' should fail while the hot spares smaller than the basic vdev."
578         atf_set "require.progs"  zpool
579         atf_set "timeout" 3600
580 }
581 hotspare_replace_002_neg_body()
582 {
583         . $(atf_get_srcdir)/../../include/default.cfg
584         . $(atf_get_srcdir)/hotspare.kshlib
585         . $(atf_get_srcdir)/hotspare.cfg
586
587         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
588         ksh93 $(atf_get_srcdir)/hotspare_replace_002_neg.ksh || atf_fail "Testcase failed"
589 }
590 hotspare_replace_002_neg_cleanup()
591 {
592         . $(atf_get_srcdir)/../../include/default.cfg
593         . $(atf_get_srcdir)/hotspare.kshlib
594         . $(atf_get_srcdir)/hotspare.cfg
595
596         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
597 }
598
599
600 atf_test_case hotspare_scrub_001_pos cleanup
601 hotspare_scrub_001_pos_head()
602 {
603         atf_set "descr" "'zpool scrub <pool>' should runs successfully regardlessthe hotspare is only in list or activated."
604         atf_set "require.progs"  zpool
605         atf_set "timeout" 3600
606 }
607 hotspare_scrub_001_pos_body()
608 {
609         . $(atf_get_srcdir)/../../include/default.cfg
610         . $(atf_get_srcdir)/hotspare.kshlib
611         . $(atf_get_srcdir)/hotspare.cfg
612
613         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
614         ksh93 $(atf_get_srcdir)/hotspare_scrub_001_pos.ksh || atf_fail "Testcase failed"
615 }
616 hotspare_scrub_001_pos_cleanup()
617 {
618         . $(atf_get_srcdir)/../../include/default.cfg
619         . $(atf_get_srcdir)/hotspare.kshlib
620         . $(atf_get_srcdir)/hotspare.cfg
621
622         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
623 }
624
625
626 atf_test_case hotspare_scrub_002_pos cleanup
627 hotspare_scrub_002_pos_head()
628 {
629         atf_set "descr" "'zpool scrub' scans spare vdevs"
630         atf_set "require.progs"  zpool
631 }
632 hotspare_scrub_002_pos_body()
633 {
634         . $(atf_get_srcdir)/../../include/default.cfg
635         . $(atf_get_srcdir)/hotspare.kshlib
636         . $(atf_get_srcdir)/hotspare.cfg
637
638         atf_expect_fail "PR 241069 scrub does not detect all errors on active spares"
639         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
640         ksh93 $(atf_get_srcdir)/hotspare_scrub_002_pos.ksh || atf_fail "Testcase failed"
641 }
642 hotspare_scrub_002_pos_cleanup()
643 {
644         . $(atf_get_srcdir)/../../include/default.cfg
645         . $(atf_get_srcdir)/hotspare.kshlib
646         . $(atf_get_srcdir)/hotspare.cfg
647
648         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
649 }
650
651
652 atf_test_case hotspare_shared_001_pos cleanup
653 hotspare_shared_001_pos_head()
654 {
655         atf_set "descr" "'zpool add <pool> spare <vdev> ...' can add a disk as a shared spare to multiple pools."
656         atf_set "require.progs"  zpool
657         atf_set "timeout" 3600
658 }
659 hotspare_shared_001_pos_body()
660 {
661         . $(atf_get_srcdir)/../../include/default.cfg
662         . $(atf_get_srcdir)/hotspare.kshlib
663         . $(atf_get_srcdir)/hotspare.cfg
664
665         verify_disk_count "$DISKS" 5
666         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
667         ksh93 $(atf_get_srcdir)/hotspare_shared_001_pos.ksh || atf_fail "Testcase failed"
668 }
669 hotspare_shared_001_pos_cleanup()
670 {
671         . $(atf_get_srcdir)/../../include/default.cfg
672         . $(atf_get_srcdir)/hotspare.kshlib
673         . $(atf_get_srcdir)/hotspare.cfg
674
675         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
676 }
677
678
679 atf_test_case hotspare_snapshot_001_pos cleanup
680 hotspare_snapshot_001_pos_head()
681 {
682         atf_set "descr" "'zpool detach <pool> <vdev> ...' against hotspare should do no harm to snapshot."
683         atf_set "require.progs"  zfs zpool sum
684         atf_set "timeout" 3600
685 }
686 hotspare_snapshot_001_pos_body()
687 {
688         . $(atf_get_srcdir)/../../include/default.cfg
689         . $(atf_get_srcdir)/hotspare.kshlib
690         . $(atf_get_srcdir)/hotspare.cfg
691
692         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
693         ksh93 $(atf_get_srcdir)/hotspare_snapshot_001_pos.ksh || atf_fail "Testcase failed"
694 }
695 hotspare_snapshot_001_pos_cleanup()
696 {
697         . $(atf_get_srcdir)/../../include/default.cfg
698         . $(atf_get_srcdir)/hotspare.kshlib
699         . $(atf_get_srcdir)/hotspare.cfg
700
701         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
702 }
703
704
705 atf_test_case hotspare_snapshot_002_pos cleanup
706 hotspare_snapshot_002_pos_head()
707 {
708         atf_set "descr" "'zpool detach <pool> <vdev> ...' against basic vdev do no harm to snapshot."
709         atf_set "require.progs"  zfs zpool sum
710         atf_set "timeout" 3600
711 }
712 hotspare_snapshot_002_pos_body()
713 {
714         . $(atf_get_srcdir)/../../include/default.cfg
715         . $(atf_get_srcdir)/hotspare.kshlib
716         . $(atf_get_srcdir)/hotspare.cfg
717
718         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
719         ksh93 $(atf_get_srcdir)/hotspare_snapshot_002_pos.ksh || atf_fail "Testcase failed"
720 }
721 hotspare_snapshot_002_pos_cleanup()
722 {
723         . $(atf_get_srcdir)/../../include/default.cfg
724         . $(atf_get_srcdir)/hotspare.kshlib
725         . $(atf_get_srcdir)/hotspare.cfg
726
727         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
728 }
729
730
731 atf_init_test_cases()
732 {
733
734         atf_add_test_case hotspare_add_001_pos
735         atf_add_test_case hotspare_add_002_pos
736         atf_add_test_case hotspare_add_003_neg
737         atf_add_test_case hotspare_add_004_neg
738         atf_add_test_case hotspare_clone_001_pos
739         atf_add_test_case hotspare_clone_002_pos
740         atf_add_test_case hotspare_create_001_neg
741         atf_add_test_case hotspare_detach_001_pos
742         atf_add_test_case hotspare_detach_002_pos
743         atf_add_test_case hotspare_detach_003_pos
744         atf_add_test_case hotspare_detach_004_pos
745         atf_add_test_case hotspare_detach_005_neg
746         atf_add_test_case hotspare_export_001_neg
747         atf_add_test_case hotspare_import_001_pos
748         atf_add_test_case hotspare_onoffline_003_neg
749         atf_add_test_case hotspare_onoffline_004_neg
750         atf_add_test_case hotspare_remove_001_pos
751         atf_add_test_case hotspare_remove_002_neg
752         atf_add_test_case hotspare_remove_003_neg
753         atf_add_test_case hotspare_remove_004_pos
754         atf_add_test_case hotspare_replace_001_neg
755         atf_add_test_case hotspare_replace_002_neg
756         atf_add_test_case hotspare_scrub_001_pos
757         atf_add_test_case hotspare_scrub_002_pos
758         atf_add_test_case hotspare_shared_001_pos
759         atf_add_test_case hotspare_snapshot_001_pos
760         atf_add_test_case hotspare_snapshot_002_pos
761 }