]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_remove/zpool_remove_001_neg.ksh
Add the ZFS Test Suite
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_remove / zpool_remove_001_neg.ksh
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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zpool_remove/zpool_remove.cfg
34
35 #
36 # DESCRIPTION:
37 # Verify that 'zpool can not remove device except inactive hot spares from pool'
38 #
39 # STRATEGY:
40 # 1. Create all kinds of pool (strip, mirror, raidz, hotspare)
41 # 2. Try to remove device from the pool
42 # 3. Verify that the remove failed.
43 #
44
45 typeset disk=${DISK}
46 typeset vdev_devs="${disk}${SLICE_PREFIX}${SLICE0}"
47 typeset mirror_devs="${disk}${SLICE_PREFIX}${SLICE0} ${disk}${SLICE_PREFIX}${SLICE1}"
48 typeset raidz_devs=${mirror_devs}
49 typeset raidz1_devs=${mirror_devs}
50 typeset raidz2_devs="${mirror_devs} ${disk}${SLICE_PREFIX}${SLICE3}"
51 typeset spare_devs1="${disk}${SLICE_PREFIX}${SLICE0}"
52 typeset spare_devs2="${disk}${SLICE_PREFIX}${SLICE1}"
53
54 function check_remove
55 {
56 typeset pool=$1
57 typeset devs="$2"
58 typeset dev
59
60 for dev in $devs; do
61 log_mustnot $ZPOOL remove $dev
62 done
63
64 destroy_pool $pool
65
66 }
67
68 function cleanup
69 {
70 if poolexists $TESTPOOL; then
71 destroy_pool $TESTPOOL
72 fi
73 }
74
75 set -A create_args "$vdev_devs" "mirror $mirror_devs" \
76 "raidz $raidz_devs" "raidz $raidz1_devs" \
77 "raidz2 $raidz2_devs" \
78 "$spare_devs1 spare $spare_devs2"
79
80 set -A verify_disks "$vdev_devs" "$mirror_devs" "$raidz_devs" \
81 "$raidz1_devs" "$raidz2_devs" "$spare_devs1"
82
83
84 log_assert "Check zpool remove <pool> <device> can not remove " \
85 "active device from pool"
86
87 log_onexit cleanup
88
89 typeset -i i=0
90 while [[ $i -lt ${#create_args[*]} ]]; do
91 log_must $ZPOOL create $TESTPOOL ${create_args[i]}
92 check_remove $TESTPOOL "${verify_disks[i]}"
93 (( i = i + 1))
94 done
95
96 log_pass "'zpool remove <pool> <device> fail as expected .'"