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 https://opensource.org/licenses/CDDL-1.0.
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 (c) 2020 Lawrence Livermore National Security, LLC.
25
26. $STF_SUITE/include/libtest.shlib
27
28#
29# DESCRIPTION:
30# Create dRAID pool using the maximum number of vdevs (255).  Then verify
31# that creating a pool with 256 fails as expected.
32#
33# STRATEGY:
34# 1) Verify a pool with fewer than the required vdevs fails.
35# 2) Verify pools with a valid number of vdevs succeed.
36# 3) Verify a pool which exceeds the maximum number of vdevs fails.
37#
38
39verify_runnable "global"
40
41function cleanup
42{
43	poolexists $TESTPOOL && destroy_pool $TESTPOOL
44
45	rm -f $all_vdevs
46	rmdir $TESTDIR
47}
48
49log_assert "'zpool create <pool> draid <vdevs>'"
50
51log_onexit cleanup
52
53all_vdevs=$(echo $TESTDIR/file.{01..256})
54
55mkdir $TESTDIR
56log_must truncate -s $MINVDEVSIZE $all_vdevs
57
58# Below maximum dRAID vdev count for specified parity level.
59log_mustnot zpool create $TESTPOOL draid1 $(echo $TESTDIR/file.{01..01})
60log_mustnot zpool create $TESTPOOL draid2 $(echo $TESTDIR/file.{01..02})
61log_mustnot zpool create $TESTPOOL draid3 $(echo $TESTDIR/file.{01..03})
62
63# Verify pool sizes from 2-10.  Values in between are skipped to speed
64# up the test case but will be exercised by the random pool creation
65# done in zpool_create_draid_002_pos.ksh.
66for (( i=2; i<=10; i++ )); do
67	log_must zpool create $TESTPOOL draid:${i}c \
68	    $(echo $TESTDIR/file.{01..$i})
69	log_must destroy_pool $TESTPOOL
70done
71
72# Verify pool sizes from 254-255.
73for (( i=254; i<=255; i++ )); do
74	log_must zpool create $TESTPOOL draid:${i}c \
75	    $(echo $TESTDIR/file.{01..$i})
76	log_must destroy_pool $TESTPOOL
77done
78
79# Exceeds maximum dRAID vdev count (256).
80log_mustnot zpool create $TESTPOOL draid $(echo $TESTDIR/file.{01..256})
81
82log_pass "'zpool create <pool> draid <vdevs>'"
83