xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_006_pos.ksh (revision 2e1aefd1b4539a3d6cf03dbfa515eabf4de09f59)
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
28#
29# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
30#
31
32. $STF_SUITE/include/libtest.shlib
33
34#
35# DESCRIPTION:
36#	Verify zpool create succeed with multiple keywords combination.
37#
38# STRATEGY:
39#	1. Create base filesystem to hold virtual disk files.
40#	2. Create several files == $MINVDEVSIZE.
41#	3. Verify 'zpool create' succeed with valid keywords combination.
42#
43
44verify_runnable "global"
45
46function cleanup
47{
48	datasetexists $TESTPOOL1 && destroy_pool $TESTPOOL1
49	datasetexists $TESTPOOL && destroy_pool $TESTPOOL
50}
51
52
53log_assert "Verify 'zpool create' succeed with keywords combination."
54log_onexit cleanup
55
56create_pool $TESTPOOL $DISKS
57mntpnt=$(get_prop mountpoint $TESTPOOL)
58
59typeset -i i=0
60while ((i < 10)); do
61	log_must $MKFILE $MINVDEVSIZE $mntpnt/vdev$i
62
63	eval vdev$i=$mntpnt/vdev$i
64	((i += 1))
65done
66
67set -A valid_args \
68	"mirror $vdev0 $vdev1 $vdev2 mirror $vdev3 $vdev4 $vdev5" \
69	"mirror $vdev0 $vdev1 mirror $vdev2 $vdev3 mirror $vdev4 $vdev5" \
70	"mirror $vdev0 $vdev1 $vdev2 mirror $vdev3 $vdev4 $vdev5 \
71		spare $vdev6" \
72	"mirror $vdev0 $vdev1 mirror $vdev2 $vdev3 mirror $vdev4 $vdev5 \
73		spare $vdev6 $vdev7" \
74	"mirror $vdev0 $vdev1 spare $vdev2 mirror $vdev3 $vdev4" \
75	"raidz $vdev0 $vdev1 $vdev2 raidz1 $vdev3 $vdev4 $vdev5" \
76	"raidz $vdev0 $vdev1 raidz1 $vdev2 $vdev3 raidz $vdev4 $vdev5" \
77	"raidz $vdev0 $vdev1 $vdev2 raidz1 $vdev3 $vdev4 $vdev5 \
78		spare $vdev6" \
79	"raidz $vdev0 $vdev1 raidz1 $vdev2 $vdev3 raidz $vdev4 $vdev5 \
80		spare $vdev6 $vdev7" \
81	"raidz $vdev0 $vdev1 spare $vdev2 raidz $vdev3 $vdev4" \
82	"raidz2 $vdev0 $vdev1 $vdev2 raidz2 $vdev3 $vdev4 $vdev5" \
83	"raidz2 $vdev0 $vdev1 $vdev2 raidz2 $vdev3 $vdev4 $vdev5 \
84		raidz2 $vdev6 $vdev7 $vdev8" \
85	"raidz2 $vdev0 $vdev1 $vdev2 raidz2 $vdev3 $vdev4 $vdev5 \
86		spare $vdev6" \
87	"raidz2 $vdev0 $vdev1 $vdev2 raidz2 $vdev3 $vdev4 $vdev5 \
88		raidz2 $vdev6 $vdev7 $vdev8 spare $vdev9" \
89	"raidz2 $vdev0 $vdev1 $vdev2 spare $vdev3 raidz2 $vdev4 $vdev5 $vdev6"
90
91set -A forced_args \
92	"$vdev0 raidz $vdev1 $vdev2 raidz1 $vdev3 $vdev4 $vdev5" \
93	"$vdev0 raidz2 $vdev1 $vdev2 $vdev3 raidz2 $vdev4 $vdev5 $vdev6" \
94	"$vdev0 mirror $vdev1 $vdev2 mirror $vdev3 $vdev4" \
95	"$vdev0 mirror $vdev1 $vdev2 raidz $vdev3 $vdev4 \
96		raidz2 $vdev5 $vdev6 $vdev7 spare $vdev8" \
97	"$vdev0 mirror $vdev1 $vdev2 spare $vdev3 raidz $vdev4 $vdev5" \
98	"raidz $vdev0 $vdev1 raidz2 $vdev2 $vdev3 $vdev4" \
99	"raidz $vdev0 $vdev1 raidz2 $vdev2 $vdev3 $vdev4 spare $vdev5" \
100	"raidz $vdev0 $vdev1 spare $vdev2 raidz2 $vdev3 $vdev4 $vdev5" \
101	"mirror $vdev0 $vdev1 raidz $vdev2 $vdev3 raidz2 $vdev4 $vdev5 $vdev6" \
102	"mirror $vdev0 $vdev1 raidz $vdev2 $vdev3 \
103		raidz2 $vdev4 $vdev5 $vdev6 spare $vdev7" \
104	"mirror $vdev0 $vdev1 raidz $vdev2 $vdev3 \
105		spare $vdev4 raidz2 $vdev5 $vdev6 $vdev7" \
106	"spare $vdev0 $vdev1 $vdev2 mirror $vdev3 $vdev4 raidz $vdev5 $vdev6"
107
108i=0
109while ((i < ${#valid_args[@]})); do
110	log_must $ZPOOL create $TESTPOOL1 ${valid_args[$i]}
111	$SYNC; $SYNC
112	log_must $ZPOOL destroy -f $TESTPOOL1
113
114	((i += 1))
115done
116
117i=0
118while ((i < ${#forced_args[@]})); do
119	log_mustnot $ZPOOL create $TESTPOOL1 ${forced_args[$i]}
120	log_must $ZPOOL create -f $TESTPOOL1 ${forced_args[$i]}
121	$SYNC; $SYNC
122	log_must $ZPOOL destroy -f $TESTPOOL1
123
124	((i += 1))
125done
126
127log_pass "'zpool create' succeed with keywords combination."
128