]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
MFC r353117-r353118, r353281-r353282, r353284-r353289, r353309-r353310, r353360-r3533...
[FreeBSD/FreeBSD.git] / tests / sys / cddl / zfs / tests / zfsd / zfsd_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,2013 Spectra Logic.  All rights reserved.
25 # Use is subject to license terms.
26 #
27
28
29 atf_test_case zfsd_fault_001_pos cleanup
30 zfsd_fault_001_pos_head()
31 {
32         atf_set "descr" "ZFS will fault a vdev that produces IO errors"
33         atf_set "require.progs"  zfs zpool zfsd
34         atf_set "timeout" 300
35 }
36 zfsd_fault_001_pos_body()
37 {
38         . $(atf_get_srcdir)/../../include/default.cfg
39         . $(atf_get_srcdir)/zfsd.cfg
40
41         verify_disk_count "$DISKS" 2
42         verify_zfsd_running
43         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
44         ksh93 $(atf_get_srcdir)/zfsd_fault_001_pos.ksh
45         if [[ $? != 0 ]]; then
46                 save_artifacts
47                 atf_fail "Testcase failed"
48         fi
49 }
50 zfsd_fault_001_pos_cleanup()
51 {
52         . $(atf_get_srcdir)/../../include/default.cfg
53         . $(atf_get_srcdir)/zfsd.cfg
54
55         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
56 }
57
58
59 atf_test_case zfsd_degrade_001_pos cleanup
60 zfsd_degrade_001_pos_head()
61 {
62         atf_set "descr" "ZFS will degrade a vdev that produces checksum errors"
63         atf_set "require.progs"  zpool zfsd
64         atf_set "timeout" 600
65 }
66 zfsd_degrade_001_pos_body()
67 {
68         . $(atf_get_srcdir)/../../include/default.cfg
69         . $(atf_get_srcdir)/zfsd.cfg
70
71         verify_disk_count "$DISKS" 2
72         verify_zfsd_running
73         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
74         ksh93 $(atf_get_srcdir)/zfsd_degrade_001_pos.ksh
75         if [[ $? != 0 ]]; then
76                 save_artifacts
77                 atf_fail "Testcase failed"
78         fi
79 }
80 zfsd_degrade_001_pos_cleanup()
81 {
82         . $(atf_get_srcdir)/../../include/default.cfg
83         . $(atf_get_srcdir)/zfsd.cfg
84
85         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
86 }
87
88 atf_test_case zfsd_degrade_002_pos cleanup
89 zfsd_degrade_002_pos_head()
90 {
91         atf_set "descr" "ZFS will degrade a spare that produces checksum errors"
92         atf_set "require.progs"  zpool zfsd
93         atf_set "timeout" 600
94 }
95 zfsd_degrade_002_pos_body()
96 {
97         atf_expect_fail "https://www.illumos.org/issues/8614 Checksum errors on a mirrored child of a raidz are incorrectly accounted"
98         . $(atf_get_srcdir)/../../include/default.cfg
99         . $(atf_get_srcdir)/zfsd.cfg
100
101         verify_disk_count "$DISKS" 5
102         verify_zfsd_running
103         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
104         ksh93 $(atf_get_srcdir)/zfsd_degrade_002_pos.ksh
105         if [[ $? != 0 ]]; then
106                 save_artifacts
107                 atf_fail "Testcase failed"
108         fi
109 }
110 zfsd_degrade_002_pos_cleanup()
111 {
112         . $(atf_get_srcdir)/../../include/default.cfg
113         . $(atf_get_srcdir)/zfsd.cfg
114
115         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
116 }
117
118
119 atf_test_case zfsd_hotspare_001_pos cleanup
120 zfsd_hotspare_001_pos_head()
121 {
122         atf_set "descr" "An active, damaged spare will be replaced by an available spare"
123         atf_set "require.progs"  zpool zfsd
124         atf_set "timeout" 3600
125 }
126 zfsd_hotspare_001_pos_body()
127 {
128         . $(atf_get_srcdir)/../../include/default.cfg
129         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
130         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
131
132         verify_zfsd_running
133         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
134         ksh93 $(atf_get_srcdir)/zfsd_hotspare_001_pos.ksh
135         if [[ $? != 0 ]]; then
136                 save_artifacts
137                 atf_fail "Testcase failed"
138         fi
139 }
140 zfsd_hotspare_001_pos_cleanup()
141 {
142         . $(atf_get_srcdir)/../../include/default.cfg
143         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
144         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
145
146         ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
147 }
148
149 atf_test_case zfsd_hotspare_002_pos cleanup
150 zfsd_hotspare_002_pos_head()
151 {
152         atf_set "descr" "If a vdev becomes degraded, the spare will be activated."
153         atf_set "require.progs"  zpool zfsd zinject
154         atf_set "timeout" 3600
155 }
156 zfsd_hotspare_002_pos_body()
157 {
158         . $(atf_get_srcdir)/../../include/default.cfg
159         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
160         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
161
162         verify_zfsd_running
163         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
164         ksh93 $(atf_get_srcdir)/zfsd_hotspare_002_pos.ksh
165         if [[ $? != 0 ]]; then
166                 save_artifacts
167                 atf_fail "Testcase failed"
168         fi
169 }
170 zfsd_hotspare_002_pos_cleanup()
171 {
172         . $(atf_get_srcdir)/../../include/default.cfg
173         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
174         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
175
176         ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
177 }
178
179
180 atf_test_case zfsd_hotspare_003_pos cleanup
181 zfsd_hotspare_003_pos_head()
182 {
183         atf_set "descr" "A faulted vdev will be replaced by an available spare"
184         atf_set "require.progs"  zpool zfsd zinject
185         atf_set "timeout" 3600
186 }
187 zfsd_hotspare_003_pos_body()
188 {
189         . $(atf_get_srcdir)/../../include/default.cfg
190         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
191         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
192
193         verify_disk_count "$DISKS" 5
194         verify_zfsd_running
195         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
196         ksh93 $(atf_get_srcdir)/zfsd_hotspare_003_pos.ksh
197         if [[ $? != 0 ]]; then
198                 save_artifacts
199                 atf_fail "Testcase failed"
200         fi
201 }
202 zfsd_hotspare_003_pos_cleanup()
203 {
204         . $(atf_get_srcdir)/../../include/default.cfg
205         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
206         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
207
208         ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
209 }
210
211 atf_test_case zfsd_hotspare_004_pos cleanup
212 zfsd_hotspare_004_pos_head()
213 {
214         atf_set "descr" "Removing a disk from a pool results in the spare activating"
215         atf_set "require.progs"  gnop zpool camcontrol zfsd
216         atf_set "timeout" 3600
217 }
218 zfsd_hotspare_004_pos_body()
219 {
220         . $(atf_get_srcdir)/../../include/default.cfg
221         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
222         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
223
224         verify_disk_count "$DISKS" 5
225         verify_zfsd_running
226         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
227         ksh93 $(atf_get_srcdir)/zfsd_hotspare_004_pos.ksh
228         if [[ $? != 0 ]]; then
229                 save_artifacts
230                 atf_fail "Testcase failed"
231         fi
232 }
233 zfsd_hotspare_004_pos_cleanup()
234 {
235         . $(atf_get_srcdir)/../../include/default.cfg
236         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
237         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
238
239         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
240 }
241
242 atf_test_case zfsd_hotspare_005_pos cleanup
243 zfsd_hotspare_005_pos_head()
244 {
245         atf_set "descr" "A spare that is added to a degraded pool will be activated"
246         atf_set "require.progs"  zpool zfsd zinject
247         atf_set "timeout" 3600
248 }
249 zfsd_hotspare_005_pos_body()
250 {
251         . $(atf_get_srcdir)/../../include/default.cfg
252         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
253         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
254
255         verify_zfsd_running
256         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
257         ksh93 $(atf_get_srcdir)/zfsd_hotspare_005_pos.ksh
258         if [[ $? != 0 ]]; then
259                 save_artifacts
260                 atf_fail "Testcase failed"
261         fi
262 }
263 zfsd_hotspare_005_pos_cleanup()
264 {
265         . $(atf_get_srcdir)/../../include/default.cfg
266         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
267         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
268
269         ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
270 }
271
272 atf_test_case zfsd_hotspare_006_pos cleanup
273 zfsd_hotspare_006_pos_head()
274 {
275         atf_set "descr" "zfsd will replace two vdevs that fail simultaneously"
276         atf_set "require.progs"  zpool zfsd zinject
277         atf_set "timeout" 3600
278 }
279 zfsd_hotspare_006_pos_body()
280 {
281         . $(atf_get_srcdir)/../../include/default.cfg
282         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
283         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
284
285         verify_zfsd_running
286         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
287         ksh93 $(atf_get_srcdir)/zfsd_hotspare_006_pos.ksh
288         if [[ $? != 0 ]]; then
289                 save_artifacts
290                 atf_fail "Testcase failed"
291         fi
292 }
293 zfsd_hotspare_006_pos_cleanup()
294 {
295         . $(atf_get_srcdir)/../../include/default.cfg
296         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
297         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
298
299         ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
300 }
301
302 atf_test_case zfsd_hotspare_007_pos cleanup
303 zfsd_hotspare_007_pos_head()
304 {
305         atf_set "descr" "zfsd will swap failed drives at startup"
306         atf_set "require.progs"  gnop zpool camcontrol zfsd
307         atf_set "timeout" 3600
308 }
309 zfsd_hotspare_007_pos_body()
310 {
311         . $(atf_get_srcdir)/../../include/default.cfg
312         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
313         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
314
315         verify_disk_count "$DISKS" 5
316         verify_zfsd_running
317         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
318         ksh93 $(atf_get_srcdir)/zfsd_hotspare_007_pos.ksh
319         if [[ $? != 0 ]]; then
320                 save_artifacts
321                 atf_fail "Testcase failed"
322         fi
323 }
324 zfsd_hotspare_007_pos_cleanup()
325 {
326         . $(atf_get_srcdir)/../../include/default.cfg
327         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
328         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
329
330         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
331 }
332
333 atf_test_case zfsd_hotspare_008_neg cleanup
334 zfsd_hotspare_008_neg_head()
335 {
336         atf_set "descr" "zfsd will not use newly added spares on replacing vdevs"
337         atf_set "require.progs"  zpool zfsd
338         atf_set "timeout" 3600
339 }
340 zfsd_hotspare_008_neg_body()
341 {
342         . $(atf_get_srcdir)/../../include/default.cfg
343         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
344         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
345
346         verify_disk_count "$DISKS" 4
347         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
348         ksh93 $(atf_get_srcdir)/zfsd_hotspare_008_neg.ksh
349         if [[ $? != 0 ]]; then
350                 save_artifacts
351                 atf_fail "Testcase failed"
352         fi
353 }
354 zfsd_hotspare_008_neg_cleanup()
355 {
356         . $(atf_get_srcdir)/../../include/default.cfg
357         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
358         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
359
360         ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
361 }
362
363 atf_test_case zfsd_autoreplace_001_neg cleanup
364 zfsd_autoreplace_001_neg_head()
365 {
366         atf_set "descr" "A pool without autoreplace set will not replace by physical path"
367         atf_set "require.progs"  zpool camcontrol zfsd gnop
368         atf_set "timeout" 3600
369 }
370 zfsd_autoreplace_001_neg_body()
371 {
372         . $(atf_get_srcdir)/../../include/default.cfg
373         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
374         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
375
376         verify_disk_count "$DISKS" 5
377         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
378         ksh93 $(atf_get_srcdir)/zfsd_autoreplace_001_neg.ksh
379         if [[ $? != 0 ]]; then
380                 save_artifacts
381                 atf_fail "Testcase failed"
382         fi
383 }
384 zfsd_autoreplace_001_neg_cleanup()
385 {
386         . $(atf_get_srcdir)/../../include/default.cfg
387         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
388         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
389
390         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
391 }
392
393 atf_test_case zfsd_autoreplace_002_pos cleanup
394 zfsd_autoreplace_002_pos_head()
395 {
396         atf_set "descr" "A pool with autoreplace set will replace by physical path"
397         atf_set "require.progs"  gnop zpool zfsd
398         atf_set "timeout" 3600
399 }
400 zfsd_autoreplace_002_pos_body()
401 {
402         . $(atf_get_srcdir)/../../include/default.cfg
403         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
404         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
405
406         verify_disk_count "$DISKS" 5
407         verify_zfsd_running
408         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
409         ksh93 $(atf_get_srcdir)/zfsd_autoreplace_002_pos.ksh
410         if [[ $? != 0 ]]; then
411                 save_artifacts
412                 atf_fail "Testcase failed"
413         fi
414 }
415 zfsd_autoreplace_002_pos_cleanup()
416 {
417         . $(atf_get_srcdir)/../../include/default.cfg
418         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
419         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
420
421         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
422 }
423
424 atf_test_case zfsd_autoreplace_003_pos cleanup
425 zfsd_autoreplace_003_pos_head()
426 {
427         atf_set "descr" "A pool with autoreplace set will replace by physical path even if a spare is active"
428         atf_set "require.progs"  zpool camcontrol zfsd gnop
429         atf_set "timeout" 3600
430 }
431 zfsd_autoreplace_003_pos_body()
432 {
433         . $(atf_get_srcdir)/../../include/default.cfg
434         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
435         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
436
437         verify_disk_count "$DISKS" 5
438         verify_zfsd_running
439         ksh93 $(atf_get_srcdir)/hotspare_setup.ksh || atf_fail "Setup failed"
440         ksh93 $(atf_get_srcdir)/zfsd_autoreplace_003_pos.ksh
441         if [[ $? != 0 ]]; then
442                 save_artifacts
443                 atf_fail "Testcase failed"
444         fi
445 }
446 zfsd_autoreplace_003_pos_cleanup()
447 {
448         . $(atf_get_srcdir)/../../include/default.cfg
449         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
450         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
451
452         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
453 }
454
455 atf_test_case zfsd_replace_001_pos cleanup
456 zfsd_replace_001_pos_head()
457 {
458         atf_set "descr" "ZFSD will automatically replace a SAS disk that disappears and reappears in the same location, with the same devname"
459         atf_set "require.progs"  zpool camcontrol zfsd zfs gnop
460 }
461 zfsd_replace_001_pos_body()
462 {
463         . $(atf_get_srcdir)/../../include/default.cfg
464         . $(atf_get_srcdir)/zfsd.cfg
465
466         verify_disk_count "$DISKS" 3
467         verify_zfsd_running
468         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
469         ksh93 $(atf_get_srcdir)/zfsd_replace_001_pos.ksh
470         if [[ $? != 0 ]]; then
471                 save_artifacts
472                 atf_fail "Testcase failed"
473         fi
474 }
475 zfsd_replace_001_pos_cleanup()
476 {
477         . $(atf_get_srcdir)/../../include/default.cfg
478         . $(atf_get_srcdir)/zfsd.cfg
479
480         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
481 }
482
483
484 atf_test_case zfsd_replace_002_pos cleanup
485 zfsd_replace_002_pos_head()
486 {
487         atf_set "descr" "zfsd will reactivate a pool after all disks are failed and reappeared"
488         atf_set "require.progs"  zpool camcontrol zfsd zfs
489 }
490 zfsd_replace_002_pos_body()
491 {
492         atf_expect_fail "Not yet implemented in zfsd"
493         . $(atf_get_srcdir)/../../include/default.cfg
494         . $(atf_get_srcdir)/zfsd.cfg
495
496         verify_disk_count "$DISKS" 3
497         verify_zfsd_running
498         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
499         ksh93 $(atf_get_srcdir)/zfsd_replace_002_pos.ksh
500         if [[ $? != 0 ]]; then
501                 save_artifacts
502                 atf_fail "Testcase failed"
503         fi
504 }
505 zfsd_replace_002_pos_cleanup()
506 {
507         . $(atf_get_srcdir)/../../include/default.cfg
508         . $(atf_get_srcdir)/zfsd.cfg
509
510         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
511 }
512
513 atf_test_case zfsd_replace_003_pos cleanup
514 zfsd_replace_003_pos_head()
515 {
516         atf_set "descr" "ZFSD will correctly replace disks that dissapear and reappear with different devnames"
517         atf_set "require.progs"  zpool camcontrol zfsd zfs gnop
518 }
519 zfsd_replace_003_pos_body()
520 {
521         . $(atf_get_srcdir)/../../include/default.cfg
522         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
523         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
524
525         verify_zfsd_running
526         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
527         ksh93 $(atf_get_srcdir)/zfsd_replace_003_pos.ksh
528         if [[ $? != 0 ]]; then
529                 save_artifacts
530                 atf_fail "Testcase failed"
531         fi
532 }
533 zfsd_replace_003_pos_cleanup()
534 {
535         . $(atf_get_srcdir)/../../include/default.cfg
536         . $(atf_get_srcdir)/zfsd.cfg
537
538         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
539 }
540
541 atf_test_case zfsd_import_001_pos cleanup
542 zfsd_import_001_pos_head()
543 {
544         atf_set "descr" "If a removed drive gets reinserted while the pool is exported, it will detach its spare when imported."
545         atf_set "require.progs"  gnop zfsd zpool
546         atf_set "timeout" 3600
547 }
548 zfsd_import_001_pos_body()
549 {
550         . $(atf_get_srcdir)/../../include/default.cfg
551         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
552         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
553
554         verify_disk_count "$DISKS" 5
555         verify_zfsd_running
556         ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
557         ksh93 $(atf_get_srcdir)/zfsd_import_001_pos.ksh || atf_fail "Testcase failed"
558         if [[ $? != 0 ]]; then
559                 save_artifacts
560                 atf_fail "Testcase failed"
561         fi
562 }
563 zfsd_import_001_pos_cleanup()
564 {
565         . $(atf_get_srcdir)/../../include/default.cfg
566         . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
567         . $(atf_get_srcdir)/../hotspare/hotspare.cfg
568
569         ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
570 }
571
572
573
574
575 atf_init_test_cases()
576 {
577         atf_add_test_case zfsd_fault_001_pos
578         atf_add_test_case zfsd_degrade_001_pos
579         atf_add_test_case zfsd_degrade_002_pos
580         atf_add_test_case zfsd_hotspare_001_pos
581         atf_add_test_case zfsd_hotspare_002_pos
582         atf_add_test_case zfsd_hotspare_003_pos
583         atf_add_test_case zfsd_hotspare_004_pos
584         atf_add_test_case zfsd_hotspare_005_pos
585         atf_add_test_case zfsd_hotspare_006_pos
586         atf_add_test_case zfsd_hotspare_007_pos
587         atf_add_test_case zfsd_hotspare_008_neg
588         atf_add_test_case zfsd_autoreplace_001_neg
589         atf_add_test_case zfsd_autoreplace_002_pos
590         atf_add_test_case zfsd_autoreplace_003_pos
591         atf_add_test_case zfsd_replace_001_pos
592         atf_add_test_case zfsd_replace_002_pos
593         atf_add_test_case zfsd_replace_003_pos
594         atf_add_test_case zfsd_import_001_pos
595 }
596
597 save_artifacts()
598 {
599         # If ARTIFACTS_DIR is defined, save test artifacts for
600         # post-mortem analysis
601         if [[ -n $ARTIFACTS_DIR ]]; then
602                 TC_ARTIFACTS_DIR=${ARTIFACTS_DIR}/sys/cddl/zfs/tests/zfsd/$(atf_get ident)
603                 mkdir -p $TC_ARTIFACTS_DIR
604                 cp -a /var/log/zfsd.log* $TC_ARTIFACTS_DIR
605                 bzip2 $TC_ARTIFACTS_DIR/zfsd.log
606         fi
607 }
608
609 verify_zfsd_running()
610 {
611         service zfsd onestatus || \
612                 atf_skip "zfsd(8) must be enabled and running for this test"
613 }