1*094e47e9SGeorge Wilson#!/bin/ksh -p
2*094e47e9SGeorge Wilson#
3*094e47e9SGeorge Wilson# CDDL HEADER START
4*094e47e9SGeorge Wilson#
5*094e47e9SGeorge Wilson# The contents of this file are subject to the terms of the
6*094e47e9SGeorge Wilson# Common Development and Distribution License (the "License").
7*094e47e9SGeorge Wilson# You may not use this file except in compliance with the License.
8*094e47e9SGeorge Wilson#
9*094e47e9SGeorge Wilson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*094e47e9SGeorge Wilson# or http://www.opensolaris.org/os/licensing.
11*094e47e9SGeorge Wilson# See the License for the specific language governing permissions
12*094e47e9SGeorge Wilson# and limitations under the License.
13*094e47e9SGeorge Wilson#
14*094e47e9SGeorge Wilson# When distributing Covered Code, include this CDDL HEADER in each
15*094e47e9SGeorge Wilson# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*094e47e9SGeorge Wilson# If applicable, add the following below this CDDL HEADER, with the
17*094e47e9SGeorge Wilson# fields enclosed by brackets "[]" replaced with your own identifying
18*094e47e9SGeorge Wilson# information: Portions Copyright [yyyy] [name of copyright owner]
19*094e47e9SGeorge Wilson#
20*094e47e9SGeorge Wilson# CDDL HEADER END
21*094e47e9SGeorge Wilson#
22*094e47e9SGeorge Wilson
23*094e47e9SGeorge Wilson#
24*094e47e9SGeorge Wilson# Copyright (c) 2016 by Delphix. All rights reserved.
25*094e47e9SGeorge Wilson#
26*094e47e9SGeorge Wilson. $STF_SUITE/include/libtest.shlib
27*094e47e9SGeorge Wilson. $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib
28*094e47e9SGeorge Wilson
29*094e47e9SGeorge Wilson#
30*094e47e9SGeorge Wilson# DESCRIPTION:
31*094e47e9SGeorge Wilson# Attempting to initialize unsupported vdevs should fail.
32*094e47e9SGeorge Wilson#
33*094e47e9SGeorge Wilson# STRATEGY:
34*094e47e9SGeorge Wilson# 1. Create a pool with the following configuration:
35*094e47e9SGeorge Wilson#    root
36*094e47e9SGeorge Wilson#      mirror
37*094e47e9SGeorge Wilson#        vdev0
38*094e47e9SGeorge Wilson#        vdev1 (offline)
39*094e47e9SGeorge Wilson#      cache
40*094e47e9SGeorge Wilson#        vdev2
41*094e47e9SGeorge Wilson#      spare
42*094e47e9SGeorge Wilson#        vdev3
43*094e47e9SGeorge Wilson# 2. Try to initialize vdev1, vdev2, and vdev3. Ensure that all 3 fail.
44*094e47e9SGeorge Wilson#
45*094e47e9SGeorge Wilsonfunction cleanup
46*094e47e9SGeorge Wilson{
47*094e47e9SGeorge Wilson        if datasetexists $TESTPOOL; then
48*094e47e9SGeorge Wilson                log_must zpool destroy -f $TESTPOOL
49*094e47e9SGeorge Wilson        fi
50*094e47e9SGeorge Wilson        if [[ -d $TESTDIR ]]; then
51*094e47e9SGeorge Wilson                log_must rm -rf $TESTDIR
52*094e47e9SGeorge Wilson        fi
53*094e47e9SGeorge Wilson}
54*094e47e9SGeorge Wilsonlog_onexit cleanup
55*094e47e9SGeorge Wilson
56*094e47e9SGeorge Wilsonlog_must mkdir $TESTDIR
57*094e47e9SGeorge Wilsonset -A FDISKS
58*094e47e9SGeorge Wilsonfor n in {0..2}; do
59*094e47e9SGeorge Wilson        log_must mkfile $MINVDEVSIZE $TESTDIR/vdev$n
60*094e47e9SGeorge Wilson        FDISKS+=("$TESTDIR/vdev$n")
61*094e47e9SGeorge Wilsondone
62*094e47e9SGeorge WilsonFDISKS+=("${DISKS%% *}")
63*094e47e9SGeorge Wilson
64*094e47e9SGeorge Wilsonlog_must zpool create $TESTPOOL mirror ${FDISKS[0]} ${FDISKS[1]} \
65*094e47e9SGeorge Wilson        spare ${FDISKS[2]} cache ${FDISKS[3]}
66*094e47e9SGeorge Wilson
67*094e47e9SGeorge Wilsonlog_must zpool offline $TESTPOOL ${FDISKS[1]}
68*094e47e9SGeorge Wilson
69*094e47e9SGeorge Wilsonlog_mustnot zpool initialize $TESTPOOL mirror-0
70*094e47e9SGeorge Wilsonfor n in {1..3}; do
71*094e47e9SGeorge Wilson        log_mustnot zpool initialize $TESTPOOL ${FDISKS[$n]}
72*094e47e9SGeorge Wilsondone
73*094e47e9SGeorge Wilson
74*094e47e9SGeorge Wilsonlog_pass "Attempting to initialize failed on unsupported devices"
75