9102 zfs should be able to initialize storage devices
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zpool_initialize / zpool_initialize_unsupported_vdevs.ksh
blobbd4ca069c49b27cfd7c42ef4e2f27e0ad18e7d8f
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright (c) 2016 by Delphix. All rights reserved.
26 . $STF_SUITE/include/libtest.shlib
27 . $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib
30 # DESCRIPTION:
31 # Attempting to initialize unsupported vdevs should fail.
33 # STRATEGY:
34 # 1. Create a pool with the following configuration:
35 # root
36 # mirror
37 # vdev0
38 # vdev1 (offline)
39 # cache
40 # vdev2
41 # spare
42 # vdev3
43 # 2. Try to initialize vdev1, vdev2, and vdev3. Ensure that all 3 fail.
45 function cleanup
47 if datasetexists $TESTPOOL; then
48 log_must zpool destroy -f $TESTPOOL
50 if [[ -d $TESTDIR ]]; then
51 log_must rm -rf $TESTDIR
54 log_onexit cleanup
56 log_must mkdir $TESTDIR
57 set -A FDISKS
58 for n in {0..2}; do
59 log_must mkfile $MINVDEVSIZE $TESTDIR/vdev$n
60 FDISKS+=("$TESTDIR/vdev$n")
61 done
62 FDISKS+=("${DISKS%% *}")
64 log_must zpool create $TESTPOOL mirror ${FDISKS[0]} ${FDISKS[1]} \
65 spare ${FDISKS[2]} cache ${FDISKS[3]}
67 log_must zpool offline $TESTPOOL ${FDISKS[1]}
69 log_mustnot zpool initialize $TESTPOOL mirror-0
70 for n in {1..3}; do
71 log_mustnot zpool initialize $TESTPOOL ${FDISKS[$n]}
72 done
74 log_pass "Attempting to initialize failed on unsupported devices"