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]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_create
/zpool_create.shlib
37 # 'zpool create' will fail in the following cases:
38 # existent pool; device is part of an active pool; nested virtual devices;
39 # differently sized devices without -f option; device being currently
40 # mounted; devices in /etc/vfstab; specified as the dedicated dump device.
43 # 1. Create case scenarios
44 # 2. For each scenario, try to create a new pool with the virtual devices
45 # 3. Verify the creation is failed.
48 verify_runnable
"global"
52 for pool
in $TESTPOOL $TESTPOOL1
57 rm -rf $disk1 $disk2 $disk3 $disk4
59 if [[ -n $saved_dump_dev ]]; then
60 log_must dumpadm
-u -d $saved_dump_dev
64 log_assert
"'zpool create' should be failed with inapplicable scenarios."
67 disk1
=$
(create_blockfile
$FILESIZE)
68 disk2
=$
(create_blockfile
$FILESIZE)
69 disk3
=$
(create_blockfile
$FILESIZE)
70 disk4
=$
(create_blockfile
$FILESIZE1)
71 mirror1
="$DISK0 $DISK1"
72 mirror2
="$disk1 $disk2"
75 draid1
="$DISK0 $DISK1 $DISK2"
76 draid2
="$disk1 $disk2 $disk3"
77 diff_size_dev
="$disk2 $disk4"
78 draid_diff_size_dev
="$disk1 $disk2 $disk4"
79 vfstab_dev
=$
(find_vfstab_dev
)
82 specified_dump_dev
=${DISK0}s0
83 saved_dump_dev
=$
(save_dump_dev
)
85 cyl
=$
(get_endslice
$DISK0 6)
86 log_must set_partition
7 "$cyl" $SIZE1 $DISK0
88 create_pool
$TESTPOOL $DISK0
91 # Set up the testing scenarios parameters
95 "$TESTPOOL1 mirror mirror $mirror1 mirror $mirror2" \
96 "$TESTPOOL1 raidz raidz $raidz1 raidz $raidz2" \
97 "$TESTPOOL1 raidz1 raidz1 $raidz1 raidz1 $raidz2" \
98 "$TESTPOOL1 draid draid $draid draid $draid2" \
99 "$TESTPOOL1 mirror raidz $raidz1 raidz $raidz2" \
100 "$TESTPOOL1 mirror raidz1 $raidz1 raidz1 $raidz2" \
101 "$TESTPOOL1 mirror draid $draid1 draid $draid2" \
102 "$TESTPOOL1 raidz mirror $mirror1 mirror $mirror2" \
103 "$TESTPOOL1 raidz1 mirror $mirror1 mirror $mirror2" \
104 "$TESTPOOL1 draid1 mirror $mirror1 mirror $mirror2" \
105 "$TESTPOOL1 mirror $diff_size_dev" \
106 "$TESTPOOL1 raidz $diff_size_dev" \
107 "$TESTPOOL1 raidz1 $diff_size_dev" \
108 "$TESTPOOL1 draid1 $draid_diff_size_dev" \
109 "$TESTPOOL1 mirror $mirror1 spare $mirror2 spare $diff_size_dev" \
110 "$TESTPOOL1 $vfstab_dev" \
111 "$TESTPOOL1 ${DISK0}s10" \
112 "$TESTPOOL1 spare $pooldev2"
116 while (( i
< ${#arg[*]} )); do
117 log_mustnot zpool create
${arg[i]}
121 # now destroy the pool to be polite
122 log_must zpool destroy
-f $TESTPOOL
125 # create/destroy a pool as a simple way to set the partitioning
126 # back to something normal so we can use this $disk as a dump device
127 log_must zpool create
-f $TESTPOOL3 $DISK1
128 log_must zpool destroy
-f $TESTPOOL3
130 log_must dumpadm
-d ${DEV_DSKDIR}/$specified_dump_dev
131 log_mustnot zpool create
-f $TESTPOOL1 "$specified_dump_dev"
133 # Also check to see that in-use checking prevents us from creating
134 # a zpool from just the first slice on the disk.
135 log_mustnot zpool create \
136 -f $TESTPOOL1 ${specified_dump_dev}s0
139 log_pass
"'zpool create' is failed as expected with inapplicable scenarios."