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 2012 Spectra Logic. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)hotspare_replace_005_pos.ksh 1.0 12/08/09 SL" 28# 29. $STF_SUITE/tests/hotspare/hotspare.kshlib 30 31################################################################################ 32# 33# __stc_assertion_start 34# 35# ID: zfs_hotspare_003_pos 36# 37# DESCRIPTION: 38# If a vdev becomes faulted in a pool with a spare, the spare will be 39# activated. 40# 41# 42# STRATEGY: 43# 1. Create 1 storage pools with hot spares. 44# 2. Artificially fault one vdev in the pool to make 1 hotspare in use. 45# 3. Verify that the spare is in use. 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING STATUS: COMPLETED (2012-08-06) 52# 53# __stc_assertion_end 54# 55############################################################################### 56 57verify_runnable "global" 58 59function cleanup 60{ 61 poolexists $TESTPOOL && \ 62 destroy_pool $TESTPOOL 63 64 partition_cleanup 65} 66 67function verify_assertion # spare_dev 68{ 69 typeset err_dev=${devarray[3]} 70 typeset sdev=$1 71 72 log_must $ZINJECT -d $err_dev -A degrade $TESTPOOL 73 log_must check_state $TESTPOOL $err_dev "DEGRADED" 74 75 # ZFSD can take up to 60 seconds to degrade an array in response to 76 # errors (though it's usually faster). 77 for ((timeout=0; $timeout<10; timeout=$timeout+1)); do 78 check_state $TESTPOOL "$sdev" "INUSE" 79 spare_inuse=$? 80 if [[ $spare_inuse == 0 ]]; then 81 break 82 fi 83 $SLEEP 6 84 done 85 log_must $ZPOOL status $TESTPOOL 86 log_must check_state $TESTPOOL "$sdev" "INUSE" 87 88 # do cleanup 89 destroy_pool $TESTPOOL 90} 91 92 93log_assert "A faulted vdev will be replaced by an available spare" 94 95log_onexit cleanup 96 97ensure_zfsd_running 98set_devs 99typeset sdev="${devarray[0]}" 100 101set -A my_keywords "mirror" "raidz1" "raidz2" 102for keyword in "${my_keywords[@]}" ; do 103 setup_hotspares "$keyword" 104 verify_assertion $sdev 105done 106 107log_pass "A faulted vdev will be replaced by an available spare" 108