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# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)hotspare_detach_001_pos.ksh 1.3 09/06/22 SMI" 30# 31. $STF_SUITE/tests/hotspare/hotspare.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: hotspare_detach_001_pos 38# 39# DESCRIPTION: 40# If a hot spare have been activated, 41# and invoke "zpool detach" with this hot spare, 42# it will be returned to the set of available spares, 43# the original drive will remain in its current position. 44# 45# STRATEGY: 46# 1. Create a storage pool with hot spares 47# 2. Activate a spare device to the pool 48# 3. Do 'zpool detach' with the spare in device 49# 4. Verify the spare device returned to the set of available spares, 50# and the original drive will remain in its current position. 51# 52# TESTABILITY: explicit 53# 54# TEST_AUTOMATION_LEVEL: automated 55# 56# CODING STATUS: COMPLETED (2006-06-07) 57# 58# __stc_assertion_end 59# 60############################################################################### 61 62verify_runnable "global" 63 64function cleanup 65{ 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 /$TESTPOOL/$TESTFILE1 78 log_must $SYNC 79 log_must $ZPOOL replace $TESTPOOL $odev $dev 80 81 log_must resilver_happened $TESTPOOL 82 log_must check_hotspare_state "$TESTPOOL" "$dev" "INUSE" 83 84 log_must $ZPOOL detach $TESTPOOL $dev 85 log_must check_hotspare_state "$TESTPOOL" "$dev" "AVAIL" 86 log_must $RM -f /$TESTPOOL/$TESTFILE1 87 log_must $SYNC 88} 89 90log_assert "'zpool detach <pool> <vdev> ...' should deactivate the spared-in hot spare device successfully." 91 92log_onexit cleanup 93 94set_devs 95 96for keyword in "${keywords[@]}" ; do 97 setup_hotspares "$keyword" 98 99 iterate_over_hotspares verify_assertion 100 101 destroy_pool "$TESTPOOL" 102done 103 104log_pass "'zpool detach <pool> <vdev> ...' deactivate the spared-in hot spare device successfully." 105