1#!/usr/local/bin/ksh93
2#
3# Copyright (c) 2017 Spectra Logic Corporation
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions, and the following disclaimer,
11#    without modification.
12# 2. Redistributions in binary form must reproduce at minimum a disclaimer
13#    substantially similar to the "NO WARRANTY" disclaimer below
14#    ("Disclaimer") and any redistribution must be conditioned upon
15#    including a substantially similar Disclaimer requirement for further
16#    binary redistribution.
17#
18# NO WARRANTY
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGES.
30#
31
32. $STF_SUITE/include/libtest.kshlib
33set_disks
34
35# "zpool import" will not show destroyed pools, even if out-of-date
36# non-destroyed label is present
37#
38# This situation can happen any time the following things happen:
39# 1) A disk gets removed with its label intact
40# 2) The pool gets destroyed
41# 3) Somebody run "zpool import" to see importable pools
42
43log_must $ZPOOL create -f $TESTPOOL mirror ${DISK0} ${DISK1}
44
45# Offline a disk so it's label won't get updated by the upcoming destroy
46log_must $ZPOOL offline $TESTPOOL ${DISK0}
47
48# Destroy the pool, so DISK1's and DISK2's labels will be in the destroyed
49# state, leaving DISK0's label as the most recent non-destroyed label
50log_must $ZPOOL destroy $TESTPOOL
51
52# Now try to import the pool.  It should fail.
53if $ZPOOL import | $GREP -q $TESTPOOL; then
54	$ZPOOL import
55	log_fail "ERROR: Destroyed pool visible"
56else
57	log_pass
58fi
59