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.
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.
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]
24 # Copyright 2012,2013 Spectra Logic. All rights reserved.
25 # Use is subject to license terms.
29 atf_test_case zfsd_fault_001_pos cleanup
30 zfsd_fault_001_pos_head()
32 atf_set "descr" "ZFS will fault a vdev that produces IO errors"
33 atf_set "require.progs" zfs zpool zfsd
36 zfsd_fault_001_pos_body()
38 . $(atf_get_srcdir)/../../include/default.cfg
39 . $(atf_get_srcdir)/zfsd.cfg
41 verify_disk_count "$DISKS" 2
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
47 atf_fail "Testcase failed"
50 zfsd_fault_001_pos_cleanup()
52 . $(atf_get_srcdir)/../../include/default.cfg
53 . $(atf_get_srcdir)/zfsd.cfg
55 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
59 atf_test_case zfsd_degrade_001_pos cleanup
60 zfsd_degrade_001_pos_head()
62 atf_set "descr" "ZFS will degrade a vdev that produces checksum errors"
63 atf_set "require.progs" zpool zfsd
66 zfsd_degrade_001_pos_body()
68 . $(atf_get_srcdir)/../../include/default.cfg
69 . $(atf_get_srcdir)/zfsd.cfg
71 verify_disk_count "$DISKS" 2
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
77 atf_fail "Testcase failed"
80 zfsd_degrade_001_pos_cleanup()
82 . $(atf_get_srcdir)/../../include/default.cfg
83 . $(atf_get_srcdir)/zfsd.cfg
85 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
88 atf_test_case zfsd_degrade_002_pos cleanup
89 zfsd_degrade_002_pos_head()
91 atf_set "descr" "ZFS will degrade a spare that produces checksum errors"
92 atf_set "require.progs" zpool zfsd
95 zfsd_degrade_002_pos_body()
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
101 verify_disk_count "$DISKS" 5
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
107 atf_fail "Testcase failed"
110 zfsd_degrade_002_pos_cleanup()
112 . $(atf_get_srcdir)/../../include/default.cfg
113 . $(atf_get_srcdir)/zfsd.cfg
115 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
119 atf_test_case zfsd_hotspare_001_pos cleanup
120 zfsd_hotspare_001_pos_head()
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
126 zfsd_hotspare_001_pos_body()
128 . $(atf_get_srcdir)/../../include/default.cfg
129 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
130 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
137 atf_fail "Testcase failed"
140 zfsd_hotspare_001_pos_cleanup()
142 . $(atf_get_srcdir)/../../include/default.cfg
143 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
144 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
146 ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
149 atf_test_case zfsd_hotspare_002_pos cleanup
150 zfsd_hotspare_002_pos_head()
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
156 zfsd_hotspare_002_pos_body()
158 . $(atf_get_srcdir)/../../include/default.cfg
159 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
160 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
167 atf_fail "Testcase failed"
170 zfsd_hotspare_002_pos_cleanup()
172 . $(atf_get_srcdir)/../../include/default.cfg
173 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
174 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
176 ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
180 atf_test_case zfsd_hotspare_003_pos cleanup
181 zfsd_hotspare_003_pos_head()
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
187 zfsd_hotspare_003_pos_body()
189 . $(atf_get_srcdir)/../../include/default.cfg
190 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
191 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
193 verify_disk_count "$DISKS" 5
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
199 atf_fail "Testcase failed"
202 zfsd_hotspare_003_pos_cleanup()
204 . $(atf_get_srcdir)/../../include/default.cfg
205 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
206 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
208 ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
211 atf_test_case zfsd_hotspare_004_pos cleanup
212 zfsd_hotspare_004_pos_head()
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
218 zfsd_hotspare_004_pos_body()
220 . $(atf_get_srcdir)/../../include/default.cfg
221 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
222 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
224 verify_disk_count "$DISKS" 5
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
230 atf_fail "Testcase failed"
233 zfsd_hotspare_004_pos_cleanup()
235 . $(atf_get_srcdir)/../../include/default.cfg
236 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
237 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
239 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
242 atf_test_case zfsd_hotspare_005_pos cleanup
243 zfsd_hotspare_005_pos_head()
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
249 zfsd_hotspare_005_pos_body()
251 . $(atf_get_srcdir)/../../include/default.cfg
252 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
253 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
260 atf_fail "Testcase failed"
263 zfsd_hotspare_005_pos_cleanup()
265 . $(atf_get_srcdir)/../../include/default.cfg
266 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
267 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
269 ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
272 atf_test_case zfsd_hotspare_006_pos cleanup
273 zfsd_hotspare_006_pos_head()
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
279 zfsd_hotspare_006_pos_body()
281 . $(atf_get_srcdir)/../../include/default.cfg
282 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
283 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
290 atf_fail "Testcase failed"
293 zfsd_hotspare_006_pos_cleanup()
295 . $(atf_get_srcdir)/../../include/default.cfg
296 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
297 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
299 ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
302 atf_test_case zfsd_hotspare_007_pos cleanup
303 zfsd_hotspare_007_pos_head()
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
309 zfsd_hotspare_007_pos_body()
311 . $(atf_get_srcdir)/../../include/default.cfg
312 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
313 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
315 verify_disk_count "$DISKS" 5
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
321 atf_fail "Testcase failed"
324 zfsd_hotspare_007_pos_cleanup()
326 . $(atf_get_srcdir)/../../include/default.cfg
327 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
328 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
330 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
333 atf_test_case zfsd_hotspare_008_neg cleanup
334 zfsd_hotspare_008_neg_head()
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
340 zfsd_hotspare_008_neg_body()
342 . $(atf_get_srcdir)/../../include/default.cfg
343 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
344 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
351 atf_fail "Testcase failed"
354 zfsd_hotspare_008_neg_cleanup()
356 . $(atf_get_srcdir)/../../include/default.cfg
357 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
358 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
360 ksh93 $(atf_get_srcdir)/hotspare_cleanup.ksh || atf_fail "Cleanup failed"
363 atf_test_case zfsd_autoreplace_001_neg cleanup
364 zfsd_autoreplace_001_neg_head()
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
370 zfsd_autoreplace_001_neg_body()
372 . $(atf_get_srcdir)/../../include/default.cfg
373 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
374 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
381 atf_fail "Testcase failed"
384 zfsd_autoreplace_001_neg_cleanup()
386 . $(atf_get_srcdir)/../../include/default.cfg
387 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
388 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
390 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
393 atf_test_case zfsd_autoreplace_002_pos cleanup
394 zfsd_autoreplace_002_pos_head()
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
400 zfsd_autoreplace_002_pos_body()
402 . $(atf_get_srcdir)/../../include/default.cfg
403 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
404 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
406 verify_disk_count "$DISKS" 5
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
412 atf_fail "Testcase failed"
415 zfsd_autoreplace_002_pos_cleanup()
417 . $(atf_get_srcdir)/../../include/default.cfg
418 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
419 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
421 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
424 atf_test_case zfsd_autoreplace_003_pos cleanup
425 zfsd_autoreplace_003_pos_head()
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
431 zfsd_autoreplace_003_pos_body()
433 . $(atf_get_srcdir)/../../include/default.cfg
434 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
435 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
437 verify_disk_count "$DISKS" 5
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
443 atf_fail "Testcase failed"
446 zfsd_autoreplace_003_pos_cleanup()
448 . $(atf_get_srcdir)/../../include/default.cfg
449 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
450 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
452 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
455 atf_test_case zfsd_replace_001_pos cleanup
456 zfsd_replace_001_pos_head()
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
461 zfsd_replace_001_pos_body()
463 . $(atf_get_srcdir)/../../include/default.cfg
464 . $(atf_get_srcdir)/zfsd.cfg
466 verify_disk_count "$DISKS" 3
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
472 atf_fail "Testcase failed"
475 zfsd_replace_001_pos_cleanup()
477 . $(atf_get_srcdir)/../../include/default.cfg
478 . $(atf_get_srcdir)/zfsd.cfg
480 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
484 atf_test_case zfsd_replace_002_pos cleanup
485 zfsd_replace_002_pos_head()
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
490 zfsd_replace_002_pos_body()
492 atf_expect_fail "Not yet implemented in zfsd"
493 . $(atf_get_srcdir)/../../include/default.cfg
494 . $(atf_get_srcdir)/zfsd.cfg
496 verify_disk_count "$DISKS" 3
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
502 atf_fail "Testcase failed"
505 zfsd_replace_002_pos_cleanup()
507 . $(atf_get_srcdir)/../../include/default.cfg
508 . $(atf_get_srcdir)/zfsd.cfg
510 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
513 atf_test_case zfsd_replace_003_pos cleanup
514 zfsd_replace_003_pos_head()
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
519 zfsd_replace_003_pos_body()
521 . $(atf_get_srcdir)/../../include/default.cfg
522 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
523 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
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
530 atf_fail "Testcase failed"
533 zfsd_replace_003_pos_cleanup()
535 . $(atf_get_srcdir)/../../include/default.cfg
536 . $(atf_get_srcdir)/zfsd.cfg
538 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
541 atf_test_case zfsd_import_001_pos cleanup
542 zfsd_import_001_pos_head()
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
548 zfsd_import_001_pos_body()
550 . $(atf_get_srcdir)/../../include/default.cfg
551 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
552 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
554 verify_disk_count "$DISKS" 5
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
560 atf_fail "Testcase failed"
563 zfsd_import_001_pos_cleanup()
565 . $(atf_get_srcdir)/../../include/default.cfg
566 . $(atf_get_srcdir)/../hotspare/hotspare.kshlib
567 . $(atf_get_srcdir)/../hotspare/hotspare.cfg
569 ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
575 atf_init_test_cases()
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
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
609 verify_zfsd_running()
611 service zfsd onestatus || \
612 atf_skip "zfsd(8) must be enabled and running for this test"