1#!/bin/ksh -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. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.kshlib 29 30# 31# DESCRIPTION: 32# 'zpool add <pool> <vdev> ...' can successfully add the specified 33# devices to the given pool 34# 35# STRATEGY: 36# 1. Create a storage pool 37# 2. Add spare devices to the pool 38# 3. Verify the devices are added to the pool successfully 39# 40 41verify_runnable "global" 42 43function cleanup 44{ 45 poolexists $TESTPOOL && \ 46 destroy_pool $TESTPOOL 47 48 partition_cleanup 49} 50 51log_assert "'zpool add <pool> <vdev> ...' can add devices to the pool." 52 53log_onexit cleanup 54 55set -A keywords "" "mirror" "raidz" "raidz1" "spare" 56 57case $DISK_ARRAY_NUM in 580|1) 59 pooldevs="${disk}s${SLICE0} \ 60 /dev/dsk/${disk}s${SLICE0} \ 61 \"${disk}s${SLICE0} ${disk}s${SLICE1}\"" 62 mirrordevs="\"/dev/dsk/${disk}s${SLICE0} ${disk}s${SLICE1}\"" 63 raidzdevs="\"/dev/dsk/${disk}s${SLICE0} ${disk}s${SLICE1}\"" 64 65 ;; 662|*) 67 pooldevs="${DISK0}s${SLICE0}\ 68 \"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\" \ 69 \"${DISK0}s${SLICE0} ${DISK0}s${SLICE1} ${DISK1}s${SLICE1}\"\ 70 \"${DISK0}s${SLICE0} ${DISK1}s${SLICE0} ${DISK0}s${SLICE1}\ 71 ${DISK1}s${SLICE1}\"" 72 mirrordevs="\"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\"" 73 raidzdevs="\"/dev/dsk/${DISK0}s${SLICE0} ${DISK1}s${SLICE0}\"" 74 75 ;; 76esac 77 78typeset -i i=0 79typeset vdev 80eval set -A poolarray $pooldevs 81eval set -A mirrorarray $mirrordevs 82eval set -A raidzarray $raidzdevs 83 84while (( $i < ${#keywords[*]} )); do 85 case ${keywords[i]} in 86 ""|spare) 87 for vdev in "${poolarray[@]}"; do 88 create_pool "$TESTPOOL" "${disk}s${SLICE6}" 89 log_must poolexists "$TESTPOOL" 90 log_must $ZPOOL add -f "$TESTPOOL" ${keywords[i]} $vdev 91 log_must iscontained "$TESTPOOL" "$vdev" 92 destroy_pool "$TESTPOOL" 93 done 94 95 ;; 96 mirror) 97 for vdev in "${mirrorarray[@]}"; do 98 create_pool "$TESTPOOL" "${keywords[i]}" \ 99 "${disk}s${SLICE4}" "${disk}s${SLICE5}" 100 log_must poolexists "$TESTPOOL" 101 log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} $vdev 102 log_must iscontained "$TESTPOOL" "$vdev" 103 destroy_pool "$TESTPOOL" 104 done 105 106 ;; 107 raidz|raidz1) 108 for vdev in "${raidzarray[@]}"; do 109 create_pool "$TESTPOOL" "${keywords[i]}" \ 110 "${disk}s${SLICE4}" "${disk}s${SLICE5}" 111 log_must poolexists "$TESTPOOL" 112 log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} $vdev 113 log_must iscontained "$TESTPOOL" "$vdev" 114 destroy_pool "$TESTPOOL" 115 done 116 117 ;; 118 esac 119 120 (( i = i+1 )) 121done 122 123log_pass "'zpool add <pool> <vdev> ...' executes successfully" 124