xref: /freebsd/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
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#
22# Copyright 2012 Spectra Logic.  All rights reserved.
23# Use is subject to license terms.
24#
25
26
27atf_test_case hotspare_add_001_pos cleanup
28hotspare_add_001_pos_head()
29{
30	atf_set "descr" "'zpool add <pool> spare <vdev> ...' can add devices to the pool."
31	atf_set "timeout" 3600
32}
33hotspare_add_001_pos_body()
34{
35	. $(atf_get_srcdir)/../../include/default.cfg
36	. $(atf_get_srcdir)/hotspare.kshlib
37	. $(atf_get_srcdir)/hotspare.cfg
38
39	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
40	ksh93 $(atf_get_srcdir)/hotspare_add_001_pos.ksh || atf_fail "Testcase failed"
41}
42hotspare_add_001_pos_cleanup()
43{
44	. $(atf_get_srcdir)/../../include/default.cfg
45	. $(atf_get_srcdir)/hotspare.kshlib
46	. $(atf_get_srcdir)/hotspare.cfg
47
48	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
49}
50
51
52atf_test_case hotspare_add_002_pos cleanup
53hotspare_add_002_pos_head()
54{
55	atf_set "descr" "'zpool add <pool> spare <vdev> ...' can add devices to the pool while it has spare-in device."
56	atf_set "require.progs" "ksh93 zpool"
57	atf_set "timeout" 3600
58}
59hotspare_add_002_pos_body()
60{
61	. $(atf_get_srcdir)/../../include/default.cfg
62	. $(atf_get_srcdir)/hotspare.kshlib
63	. $(atf_get_srcdir)/hotspare.cfg
64
65	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
66	ksh93 $(atf_get_srcdir)/hotspare_add_002_pos.ksh || atf_fail "Testcase failed"
67}
68hotspare_add_002_pos_cleanup()
69{
70	. $(atf_get_srcdir)/../../include/default.cfg
71	. $(atf_get_srcdir)/hotspare.kshlib
72	. $(atf_get_srcdir)/hotspare.cfg
73
74	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
75}
76
77
78atf_test_case hotspare_add_003_neg cleanup
79hotspare_add_003_neg_head()
80{
81	atf_set "descr" "'zpool add [-f]' with hot spares should fail with inapplicable scenarios."
82	atf_set "require.progs" "ksh93 zpool"
83	atf_set "timeout" 3600
84}
85hotspare_add_003_neg_body()
86{
87	. $(atf_get_srcdir)/../../include/default.cfg
88	. $(atf_get_srcdir)/hotspare.kshlib
89	. $(atf_get_srcdir)/hotspare.cfg
90
91	verify_disk_count "$DISKS" 3
92	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
93	ksh93 $(atf_get_srcdir)/hotspare_add_003_neg.ksh || atf_fail "Testcase failed"
94}
95hotspare_add_003_neg_cleanup()
96{
97	. $(atf_get_srcdir)/../../include/default.cfg
98	. $(atf_get_srcdir)/hotspare.kshlib
99	. $(atf_get_srcdir)/hotspare.cfg
100
101	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
102}
103
104
105atf_test_case hotspare_add_004_neg cleanup
106hotspare_add_004_neg_head()
107{
108	atf_set "descr" "'zpool add [-f]' will not allow a swap device to be used as a hotspare'"
109	atf_set "require.progs" "ksh93 zpool swapon swapoff swapctl"
110}
111hotspare_add_004_neg_body()
112{
113	. $(atf_get_srcdir)/../../include/default.cfg
114	. $(atf_get_srcdir)/hotspare.kshlib
115	. $(atf_get_srcdir)/hotspare.cfg
116
117	verify_disk_count "$DISKS" 2
118	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
119	ksh93 $(atf_get_srcdir)/hotspare_add_004_neg.ksh || atf_fail "Testcase failed"
120}
121hotspare_add_004_neg_cleanup()
122{
123	. $(atf_get_srcdir)/../../include/default.cfg
124	. $(atf_get_srcdir)/hotspare.kshlib
125	. $(atf_get_srcdir)/hotspare.cfg
126
127	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
128}
129
130
131atf_test_case hotspare_clone_001_pos cleanup
132hotspare_clone_001_pos_head()
133{
134	atf_set "descr" "'zpool detach <pool> <vdev> ...' against hotspare should do no harm to clone."
135	atf_set "require.progs" "ksh93 zfs zpool sum"
136	atf_set "timeout" 3600
137}
138hotspare_clone_001_pos_body()
139{
140	. $(atf_get_srcdir)/../../include/default.cfg
141	. $(atf_get_srcdir)/hotspare.kshlib
142	. $(atf_get_srcdir)/hotspare.cfg
143
144	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
145	ksh93 $(atf_get_srcdir)/hotspare_clone_001_pos.ksh || atf_fail "Testcase failed"
146}
147hotspare_clone_001_pos_cleanup()
148{
149	. $(atf_get_srcdir)/../../include/default.cfg
150	. $(atf_get_srcdir)/hotspare.kshlib
151	. $(atf_get_srcdir)/hotspare.cfg
152
153	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
154}
155
156
157atf_test_case hotspare_clone_002_pos cleanup
158hotspare_clone_002_pos_head()
159{
160	atf_set "descr" "'zpool detach <pool> <vdev> ...' against basic vdev should do no harm to clone."
161	atf_set "require.progs" "ksh93 zfs zpool sum"
162	atf_set "timeout" 3600
163}
164hotspare_clone_002_pos_body()
165{
166	. $(atf_get_srcdir)/../../include/default.cfg
167	. $(atf_get_srcdir)/hotspare.kshlib
168	. $(atf_get_srcdir)/hotspare.cfg
169
170	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
171	ksh93 $(atf_get_srcdir)/hotspare_clone_002_pos.ksh || atf_fail "Testcase failed"
172}
173hotspare_clone_002_pos_cleanup()
174{
175	. $(atf_get_srcdir)/../../include/default.cfg
176	. $(atf_get_srcdir)/hotspare.kshlib
177	. $(atf_get_srcdir)/hotspare.cfg
178
179	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
180}
181
182
183atf_test_case hotspare_create_001_neg cleanup
184hotspare_create_001_neg_head()
185{
186	atf_set "descr" "'zpool create [-f]' with hot spares should be failedwith inapplicable scenarios."
187	atf_set "require.progs" "ksh93 zpool"
188	atf_set "timeout" 3600
189}
190hotspare_create_001_neg_body()
191{
192	. $(atf_get_srcdir)/../../include/default.cfg
193	. $(atf_get_srcdir)/hotspare.kshlib
194	. $(atf_get_srcdir)/hotspare.cfg
195
196	verify_disk_count "$DISKS" 3
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}
200hotspare_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
210atf_test_case hotspare_detach_001_pos cleanup
211hotspare_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" "ksh93 zpool"
215	atf_set "timeout" 3600
216}
217hotspare_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}
226hotspare_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
236atf_test_case hotspare_detach_002_pos cleanup
237hotspare_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" "ksh93 zpool"
241	atf_set "timeout" 3600
242}
243hotspare_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}
252hotspare_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
262atf_test_case hotspare_detach_003_pos cleanup
263hotspare_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" "ksh93 zpool"
267	atf_set "timeout" 3600
268}
269hotspare_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}
278hotspare_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
288atf_test_case hotspare_detach_004_pos cleanup
289hotspare_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" "ksh93 zpool"
293	atf_set "timeout" 3600
294}
295hotspare_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}
304hotspare_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
314atf_test_case hotspare_detach_005_neg cleanup
315hotspare_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" "ksh93 zpool"
319	atf_set "timeout" 3600
320}
321hotspare_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}
330hotspare_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
340atf_test_case hotspare_export_001_neg cleanup
341hotspare_export_001_neg_head()
342{
343	atf_set "descr" "export pool that using shared hotspares will fail"
344	atf_set "require.progs" "ksh93 zpool"
345	atf_set "timeout" 3600
346}
347hotspare_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}
356hotspare_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
366atf_test_case hotspare_import_001_pos cleanup
367hotspare_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" "ksh93 zpool sum"
371	atf_set "timeout" 3600
372}
373hotspare_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}
382hotspare_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
392atf_test_case hotspare_onoffline_003_neg cleanup
393hotspare_onoffline_003_neg_head()
394{
395	atf_set "descr" "'zpool offline/online <pool> <vdev>' should fail on inactive spares"
396	atf_set "require.progs" "ksh93 zpool zdb"
397	atf_set "timeout" 3600
398}
399hotspare_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}
408hotspare_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
418atf_test_case hotspare_onoffline_004_neg cleanup
419hotspare_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" "ksh93 zfs zpool zdb"
423	atf_set "timeout" 3600
424}
425hotspare_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}
434hotspare_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
444atf_test_case hotspare_remove_001_pos cleanup
445hotspare_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" "ksh93 zpool"
449	atf_set "timeout" 3600
450}
451hotspare_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}
460hotspare_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
470atf_test_case hotspare_remove_002_neg cleanup
471hotspare_remove_002_neg_head()
472{
473	atf_set "descr" "'zpool remove <pool> <vdev> ...' should fail with inapplicable scenarios."
474	atf_set "require.progs" "ksh93 zpool"
475	atf_set "timeout" 3600
476}
477hotspare_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}
486hotspare_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
496atf_test_case hotspare_remove_003_neg cleanup
497hotspare_remove_003_neg_head()
498{
499	atf_set "descr" "Executing 'zpool remove' with bad options fails"
500	atf_set "require.progs" "ksh93 zpool"
501	atf_set "timeout" 3600
502}
503hotspare_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}
512hotspare_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
522atf_test_case hotspare_remove_004_pos cleanup
523hotspare_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" "ksh93 zpool"
527	atf_set "timeout" 3600
528}
529hotspare_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}
538hotspare_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
548atf_test_case hotspare_replace_001_neg cleanup
549hotspare_replace_001_neg_head()
550{
551	atf_set "descr" "'zpool replace <pool> <odev> <ndev>' should fail with inapplicable scenarios."
552	atf_set "require.progs" "ksh93 zpool"
553	atf_set "timeout" 3600
554}
555hotspare_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}
564hotspare_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
574atf_test_case hotspare_replace_002_neg cleanup
575hotspare_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" "ksh93 zpool"
579	atf_set "timeout" 3600
580}
581hotspare_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}
590hotspare_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
600atf_test_case hotspare_scrub_001_pos cleanup
601hotspare_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" "ksh93 zpool"
605	atf_set "timeout" 3600
606}
607hotspare_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}
616hotspare_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
626atf_test_case hotspare_scrub_002_pos cleanup
627hotspare_scrub_002_pos_head()
628{
629	atf_set "descr" "'zpool scrub' scans spare vdevs"
630	atf_set "require.progs" "ksh93 zpool"
631}
632hotspare_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}
642hotspare_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
652atf_test_case hotspare_shared_001_pos cleanup
653hotspare_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" "ksh93 zpool"
657	atf_set "timeout" 3600
658}
659hotspare_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}
669hotspare_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
679atf_test_case hotspare_snapshot_001_pos cleanup
680hotspare_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" "ksh93 zfs zpool sum"
684	atf_set "timeout" 3600
685}
686hotspare_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}
695hotspare_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
705atf_test_case hotspare_snapshot_002_pos cleanup
706hotspare_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" "ksh93 zfs zpool sum"
710	atf_set "timeout" 3600
711}
712hotspare_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}
721hotspare_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
731atf_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}
762