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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/cli_root/zpool_export/zpool_export.kshlib 33 34# 35# DESCRIPTION: 36# Verify zpool export succeed or fail with spare. 37# 38# STRATEGY: 39# 1. Create two mirror pools with same spare. 40# 2. Verify zpool export one pool succeed. 41# 3. Import the pool. 42# 4. Replace one device with the spare and detach it in one pool. 43# 5. Verify zpool export the pool succeed. 44# 6. Import the pool. 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. 49# 50 51verify_runnable "global" 52 53log_assert "Verify zpool export succeed or fail with spare." 54log_onexit zpool_export_cleanup 55 56mntpnt=$TESTDIR0 57log_must mkdir -p $mntpnt 58 59# mntpnt=$(get_prop mountpoint $TESTPOOL) 60 61typeset -i i=0 62while ((i < 5)); do 63 log_must truncate -s $MINVDEVSIZE $mntpnt/vdev$i 64 eval vdev$i=$mntpnt/vdev$i 65 ((i += 1)) 66done 67 68log_must zpool create $TESTPOOL1 mirror $vdev0 $vdev1 spare $vdev4 69log_must zpool create $TESTPOOL2 mirror $vdev2 $vdev3 spare $vdev4 70 71log_must zpool export $TESTPOOL1 72log_must zpool import -d $mntpnt $TESTPOOL1 73 74log_must zpool replace $TESTPOOL1 $vdev0 $vdev4 75log_must zpool detach $TESTPOOL1 $vdev4 76log_must zpool export $TESTPOOL1 77log_must zpool import -d $mntpnt $TESTPOOL1 78 79log_must zpool replace $TESTPOOL1 $vdev0 $vdev4 80log_mustnot zpool export $TESTPOOL1 81 82log_must zpool export -f $TESTPOOL1 83log_must zpool import -d $mntpnt $TESTPOOL1 84 85log_pass "Verify zpool export succeed or fail with spare." 86 87