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. $STF_SUITE/tests/hotspare/hotspare.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: hotspare_export_001_neg 33# 34# DESCRIPTION: 35# If 2 storage pools have shared hotspares, if the shared hotspare was used by 36# one of the pool, the export of the pool that use hotspare will fail. 37# 38# STRATEGY: 39# 1. Create 2 storage pools with hot spares shared. 40# 2. Fail one vdev in one pool to make the hotspare in use. 41# 3. Export the pool that currently use the hotspare 42# 4. Verify the export will failed with warning message. 43# 5. Verify export -f will success. 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING STATUS: COMPLETED (2008-12-12) 50# 51# __stc_assertion_end 52# 53############################################################################### 54 55verify_runnable "global" 56 57function cleanup 58{ 59 60 if poolexists $TESTPOOL ; then 61 destroy_pool $TESTPOOL 62 else 63 $ZPOOL import -d $HOTSPARE_TMPDIR -f | $GREP \ 64 "pool: $TESTPOOL">/dev/null 2>&1 65 if (( $? == 0 )); then 66 log_must $ZPOOL import -d $HOTSPARE_TMPDIR -f $TESTPOOL 67 destroy_pool $TESTPOOL 68 fi 69 fi 70 71 poolexists $TESTPOOL1 && \ 72 destroy_pool $TESTPOOL1 73 74 partition_cleanup 75 76} 77 78 79log_onexit cleanup 80 81function verify_assertion # type, dev 82{ 83 typeset pool_type=$1 84 typeset hotspare=$2 85 86 typeset err_dev=${devarray[3]} 87 typeset pool_dev="${devarray[6]}" 88 typeset mntp=$(get_prop mountpoint $TESTPOOL) 89 90 create_pool $TESTPOOL1 $pool_dev spare $hotspare 91 92 zpool replace $TESTPOOL $err_dev $hotspare 93 log_must check_hotspare_state "$TESTPOOL" "$hotspare" "INUSE" 94 95 log_must $ZPOOL status $TESTPOOL 96 log_must $ZPOOL status $TESTPOOL1 97 98 log_mustnot $ZPOOL export $TESTPOOL 99 log_must $ZPOOL export -f $TESTPOOL 100 101 log_must $ZPOOL import -d $HOTSPARE_TMPDIR -f $TESTPOOL 102 destroy_pool $TESTPOOL 103 104 destroy_pool $TESTPOOL1 105} 106 107log_onexit cleanup 108 109log_assert "export pool that using shared hotspares will fail" 110 111set_devs 112 113typeset share_spare="${devarray[0]}" 114set -A my_keywords "mirror" "raidz1" "raidz2" 115 116for keyword in "${my_keywords[@]}" ; do 117 setup_hotspares $keyword $share_spare 118 verify_assertion $keyword $share_spare 119done 120 121log_pass "export pool that using shared hotspares will fail" 122 123