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# ident "@(#)hotspare_scrub_001_pos.ksh 1.3 09/06/22 SMI" 28# 29. $STF_SUITE/tests/hotspare/hotspare.kshlib 30 31################################################################################ 32# 33# __stc_assertion_start 34# 35# ID: hotspare_scrub_001_pos 36# 37# DESCRIPTION: 38# If a storage pool has hot spare, 39# regardless it has been activated or NOT, 40# invoke "zpool scrub" with this storage pool should successful. 41# 42# STRATEGY: 43# 1. Create a storage pool with hot spares 44# 2. Make the storage pool dirty. 45# 3. Do 'zpool scrub' with following scernarios 46# - the hotspare is only in available list 47# - the hotspare is activated 48# 4. Verify the scrub runs successfully. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING STATUS: COMPLETED (2006-06-07) 55# 56# __stc_assertion_end 57# 58############################################################################### 59 60verify_runnable "global" 61 62function cleanup 63{ 64 # Record status so we can see the current state on failure. 65 $ZPOOL status 66 poolexists $TESTPOOL && \ 67 destroy_pool $TESTPOOL 68 69 partition_cleanup 70} 71 72function verify_assertion # dev 73{ 74 typeset dev=$1 75 typeset odev=${pooldevs[0]} 76 77 log_must $MKFILE 100m $mtpt/$TESTFILE0 78 log_must $ZPOOL scrub $TESTPOOL 79 while is_pool_scrubbing $TESTPOOL ; do 80 $SLEEP 2 81 done 82 83 log_must $MKFILE 100m $mtpt/$TESTFILE1 84 log_must $ZPOOL replace $TESTPOOL $odev $dev 85 86 while ! is_pool_resilvered $TESTPOOL ; do 87 $SLEEP 2 88 done 89 90 log_must $ZPOOL scrub $TESTPOOL 91 92 while is_pool_scrubbing $TESTPOOL ; do 93 $SLEEP 2 94 done 95 96 log_must $ZPOOL detach $TESTPOOL $dev 97 log_must $RM -f $mtpt/$TESTFILE0 \ 98 $mtpt/$TESTFILE1 99} 100 101log_assert "'zpool scrub <pool>' should runs successfully regardless " \ 102 "the hotspare is only in list or activated." 103 104log_onexit cleanup 105 106typeset mtpt="" 107 108set_devs 109 110for keyword in "${keywords[@]}" ; do 111 setup_hotspares "$keyword" 112 mtpt=$(get_prop mountpoint $TESTPOOL) 113 iterate_over_hotspares verify_assertion "${vdev%% *}" 114 destroy_pool "$TESTPOOL" 115done 116 117log_pass "'zpool scrub <pool>' runs successfully regardless " \ 118 "the hotspare is only in list or activated." 119