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 "@(#)zpool_add_001_pos.ksh 1.4 09/06/22 SMI" 30# 31. $STF_SUITE/include/libtest.kshlib 32. $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zpool_add_001_pos 39# 40# DESCRIPTION: 41# 'zpool add <pool> <vdev> ...' can successfully add the specified 42# devices to the given pool 43# 44# STRATEGY: 45# 1. Create a storage pool 46# 2. Add spare devices to the pool 47# 3. Verify the devices are added to the pool successfully 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING STATUS: COMPLETED (2005-09-27) 54# 55# __stc_assertion_end 56# 57############################################################################### 58 59verify_runnable "global" 60 61function cleanup 62{ 63 poolexists $TESTPOOL && \ 64 destroy_pool $TESTPOOL 65 66 partition_cleanup 67} 68 69log_assert "'zpool add <pool> <vdev> ...' can add devices to the pool." 70 71log_onexit cleanup 72 73set -A keywords "" "mirror" "raidz" "raidz1" "spare" 74 75typeset diskname=${disk#/dev/} 76typeset diskname0=${DISK0#/dev/} 77typeset diskname1=${DISK1#/dev/} 78 79case $DISK_ARRAY_NUM in 800|1) 81 pooldevs="${diskname}p1 \ 82 /dev/${diskname}p1 \ 83 \"${diskname}p1 ${diskname}p2\"" 84 mirrordevs="\"/dev/${diskname}p1 ${diskname}p2\"" 85 raidzdevs="\"/dev/${diskname}p1 ${diskname}p2\"" 86 87 ;; 882|*) 89 pooldevs="${diskname0}p1\ 90 \"/dev/${diskname0}p1 ${diskname1}p1\" \ 91 \"${diskname0}p1 ${diskname0}p2 ${diskname1}p2\"\ 92 \"${diskname0}p1 ${diskname1}p1 ${diskname0}p2\ 93 ${diskname1}p2\"" 94 mirrordevs="\"/dev/${diskname0}p1 ${diskname1}p1\"" 95 raidzdevs="\"/dev/${diskname0}p1 ${diskname1}p1\"" 96 97 ;; 98esac 99 100typeset -i i=0 101typeset vdev 102eval set -A poolarray $pooldevs 103eval set -A mirrorarray $mirrordevs 104eval set -A raidzarray $raidzdevs 105 106while (( $i < ${#keywords[*]} )); do 107 case ${keywords[i]} in 108 ""|spare) 109 for vdev in "${poolarray[@]}"; do 110 create_pool "$TESTPOOL" "${diskname}p6" 111 log_must poolexists "$TESTPOOL" 112 log_must $ZPOOL add -f "$TESTPOOL" ${keywords[i]} \ 113 $vdev 114 log_must iscontained "$TESTPOOL" "$vdev" 115 destroy_pool "$TESTPOOL" 116 done 117 118 ;; 119 mirror) 120 for vdev in "${mirrorarray[@]}"; do 121 create_pool "$TESTPOOL" "${keywords[i]}" \ 122 "${diskname}p4" "${diskname}p5" 123 log_must poolexists "$TESTPOOL" 124 log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} \ 125 $vdev 126 log_must iscontained "$TESTPOOL" "$vdev" 127 destroy_pool "$TESTPOOL" 128 done 129 130 ;; 131 raidz|raidz1) 132 for vdev in "${raidzarray[@]}"; do 133 create_pool "$TESTPOOL" "${keywords[i]}" \ 134 "${diskname}p4" "${diskname}p5" 135 log_must poolexists "$TESTPOOL" 136 log_must $ZPOOL add "$TESTPOOL" ${keywords[i]} \ 137 $vdev 138 log_must iscontained "$TESTPOOL" "$vdev" 139 destroy_pool "$TESTPOOL" 140 done 141 142 ;; 143 esac 144 145 (( i = i+1 )) 146done 147 148log_pass "'zpool add <pool> <vdev> ...' executes successfully" 149