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 2013 Spectra Logic. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)hotspare_replace_007_pos.ksh 1.0 12/08/10 SL" 28# 29. $STF_SUITE/tests/hotspare/hotspare.kshlib 30. $STF_SUITE/tests/zfsd/zfsd.kshlib 31. $STF_SUITE/include/libgnop.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: zfsd_autoreplace_001_neg 38# 39# DESCRIPTION: 40# In a pool without the autoreplace property set, a vdev will not be 41# replaced by physical path 42# 43# STRATEGY: 44# 1. Create 1 storage pool without hot spares 45# 2. Remove a vdev 46# 4. Create a new vdev with the same physical path as the first one 47# 9. Verify that it does not get added to the pool. 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING STATUS: COMPLETED (2013-02-4) 54# 55# __stc_assertion_end 56# 57############################################################################### 58 59log_assert "A pool without the autoreplace property set will not replace disks by physical path" 60 61function verify_assertion 62{ 63 # 9. Verify that it does not get added to the pool 64 for ((timeout=0; timeout<4; timeout=$timeout+1)); do 65 log_mustnot check_state $TESTPOOL $NEW_DISK "ONLINE" 66 $SLEEP 5 67 done 68} 69 70typeset PHYSPATH="some_physical_path" 71typeset REMOVAL_DISK=$DISK0 72typeset REMOVAL_NOP=${DISK0}.nop 73typeset NEW_DISK=$DISK4 74typeset NEW_NOP=${DISK4}.nop 75typeset OTHER_DISKS="${DISK1} ${DISK2} ${DISK3}" 76typeset ALLDISKS="${DISK0} ${DISK1} ${DISK2} ${DISK3}" 77typeset ALLNOPS=${ALLDISKS//~(E)([[:space:]]+|$)/.nop\1} 78set -A MY_KEYWORDS "mirror" "raidz1" "raidz2" 79ensure_zfsd_running 80log_must create_gnops $OTHER_DISKS 81for keyword in "${MY_KEYWORDS[@]}" ; do 82 log_must create_gnop $REMOVAL_DISK $PHYSPATH 83 log_must create_pool $TESTPOOL $keyword $ALLNOPS 84 log_must $ZPOOL set autoreplace=off $TESTPOOL 85 86 log_must destroy_gnop $REMOVAL_DISK 87 log_must wait_for_pool_removal 20 88 log_must create_gnop $NEW_DISK $PHYSPATH 89 verify_assertion 90 destroy_pool "$TESTPOOL" 91 log_must destroy_gnop $NEW_DISK 92done 93 94log_pass 95