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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27############################################################################### 28# 29# __stc_assertion_start 30# 31# ID: zinject_004_pos 32# 33# DESCRIPTION: 34# 35# Inject an error into the device of a pool. 36# Verify fmdump will get the expect ereport, 37# and the fault class of "fault.fs.zfs.vdev.io" be generated. 38# 39# STRATEGY: 40# 1) Populate ZFS file system 41# 2) Inject an error into the device of the pool. 42# 3) Verify fmdump get the ereport as expected. 43# <Errno> <Expect ereport> 44# nxio ereport.fs.zfs.probe_failure 45# io ereport.fs.zfs.probe_failure 46# 4) Verify the fault class of "fault.fs.zfs.vdev.io" be generated. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2007-05-31) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58. $STF_SUITE/tests/zinject/zinject.kshlib 59 60verify_runnable "global" 61 62log_assert "Verify fault inject handle device error successfully." 63log_onexit cleanup_env 64 65set -A types "mirror" "raidz" "raidz2" 66 67typeset -i maxnumber=1 68 69function test_zinject 70{ 71 typeset basedir=$1 72 typeset -i i=0 73 typeset etype="device" 74 typeset fclass="fault.fs.zfs.vdev.io" 75 76 set -A errset \ 77 "nxio" "ereport.fs.zfs.probe_failure" \ 78 "io" "ereport.fs.zfs.probe_failure" 79 80 set -A alldevarray $alldevs 81 82 for device in $(random_string alldevarray 1); do 83 i=0 84 while ((i < ${#errset[*]} )); do 85 now=`date '+%m/%d/%y %H:%M:%S'` 86 inject_device $device $TESTPOOL ${errset[i]} 87 88 trigger_inject $etype $basedir/testfile.$maxnumber "file" 89 log_must check_ereport "$now" ${errset[((i+1))]} 90 log_must check_fault "$now" $fclass 91 92 inject_clear 93 94 now=`date '+%m/%d/%y %H:%M:%S'` 95 inject_device $device $TESTPOOL ${errset[i]} 96 97 trigger_inject $etype $basedir/testdir.$maxnumber "dir" 98 log_must check_ereport "$now" ${errset[((i+1))]} 99 log_must check_fault "$now" $fclass 100 101 inject_clear 102 103 (( i = i + 2 )) 104 done 105 done 106} 107 108inject_clear 109for type in "${types[@]}"; do 110 create_pool $TESTPOOL $type $pooldevs spare $sparedevs 111 112 log_must $ZPOOL add -f $TESTPOOL log $logdevs 113 log_must $ZPOOL add -f $TESTPOOL cache $cachedevs 114 115 log_must $ZPOOL replace $TESTPOOL $VDEV0 $sparedevs 116 log_must $ZFS create $TESTPOOL/$TESTFS 117 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 118 119 populate_test_env $TESTDIR $maxnumber 120 test_zinject $TESTDIR 121 122 cleanup_env 123done 124 125log_pass "Fault inject handle device error successfully." 126