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 2009 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
36 # Verify zpool export succeed or fail with spare.
39 # 1. Create two mirror pools with same spare.
40 # 2. Verify zpool export one pool succeed.
42 # 4. Replace one device with the spare and detach it in one pool.
43 # 5. Verify zpool export the pool succeed.
45 # 7. Replace one device with the spare in one pool.
46 # 8. Verify zpool export the pool fail.
47 # 9. Verify zpool export the pool with "-f" succeed.
48 # 10. Import the pool.
51 verify_runnable
"global"
55 mntpnt
=$
(get_prop mountpoint
$TESTPOOL)
56 datasetexists
$TESTPOOL1 || log_must zpool import
-d $mntpnt $TESTPOOL1
57 datasetexists
$TESTPOOL1 && destroy_pool
$TESTPOOL1
58 datasetexists
$TESTPOOL2 && destroy_pool
$TESTPOOL2
61 if [[ -e $mntpnt/vdev
$i ]]; then
62 log_must
rm -f $mntpnt/vdev
$i
69 log_assert
"Verify zpool export succeed or fail with spare."
72 mntpnt
=$
(get_prop mountpoint
$TESTPOOL)
76 log_must mkfile
$MINVDEVSIZE $mntpnt/vdev
$i
77 eval vdev
$i=$mntpnt/vdev
$i
81 log_must zpool create
$TESTPOOL1 mirror
$vdev0 $vdev1 spare
$vdev4
82 log_must zpool create
$TESTPOOL2 mirror
$vdev2 $vdev3 spare
$vdev4
84 log_must zpool
export $TESTPOOL1
85 log_must zpool import
-d $mntpnt $TESTPOOL1
87 log_must zpool replace
$TESTPOOL1 $vdev0 $vdev4
88 log_must zpool detach
$TESTPOOL1 $vdev4
89 log_must zpool
export $TESTPOOL1
90 log_must zpool import
-d $mntpnt $TESTPOOL1
92 log_must zpool replace
$TESTPOOL1 $vdev0 $vdev4
93 log_mustnot zpool
export $TESTPOOL1
95 log_must zpool
export -f $TESTPOOL1
96 log_must zpool import
-d $mntpnt $TESTPOOL1
98 log_pass
"Verify zpool export succeed or fail with spare."