1#!/usr/local/bin/ksh93 -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2012,2013 Spectra Logic Corporation.  All rights reserved.
25# Use is subject to license terms.
26#
27
28. $STF_SUITE/include/libtest.kshlib
29. $STF_SUITE/tests/zfsd/zfsd.kshlib
30
31################################################################################
32#
33# __stc_assertion_start
34#
35# ID: zfsd_degrade_001_pos
36#
37# DESCRIPTION:
38#   If a vdev experiences checksum errors, it will become degraded.
39#
40#
41# STRATEGY:
42#   1. Create a storage pool.  Only use the file vdevs because it is easy to
43#      generate checksum errors on them.
44#   2. Mostly fill the pool with data.
45#   3. Corrupt it by DDing to the underlying vdev
46#   4. Verify that the vdev becomes DEGRADED.
47#   5. ONLINE it and verify that it resilvers and joins the pool.
48#
49# TESTABILITY: explicit
50#
51# TEST_AUTOMATION_LEVEL: automated
52#
53# CODING STATUS: COMPLETED (2012-08-09)
54#
55# __stc_assertion_end
56#
57###############################################################################
58
59verify_runnable "global"
60
61VDEV0=${TMPDIR}/file0.${TESTCASE_ID}
62VDEV1=${TMPDIR}/file1.${TESTCASE_ID}
63VDEVS="${VDEV0} ${VDEV1}"
64TESTFILE=/$TESTPOOL/testfile
65VDEV_SIZE=192m
66
67
68function cleanup
69{
70	destroy_pool $TESTPOOL
71	$RM -f $VDEVS
72}
73
74log_assert "ZFS will degrade a vdev that produces checksum errors"
75
76log_onexit cleanup
77
78log_must create_vdevs $VDEV0 $VDEV1
79ensure_zfsd_running
80for type in "raidz" "mirror"; do
81	log_note "Testing raid type $type"
82
83	create_pool $TESTPOOL $type ${VDEVS}
84	corrupt_pool_vdev $TESTPOOL $VDEV1 $TESTFILE
85	destroy_pool $TESTPOOL
86done
87
88cleanup
89log_pass
90