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