4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2016 by Delphix. All rights reserved.
18 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_import
/zpool_import.kshlib
22 # A pool should be importable using an outdated cachefile that misses a
23 # mirror that was attached.
26 # 1. Create a pool with some devices and an alternate cachefile.
27 # 2. Backup the cachefile.
28 # 3. Attach a mirror to one of the devices in the pool.
30 # 5. Verify that we can import the pool using the backed-up cachefile.
33 verify_runnable
"global"
37 function test_attach_vdev
39 typeset poolcreate
="$1"
41 typeset attachvdev
="$3"
42 typeset poolcheck
="$4"
44 log_note
"$0: pool '$poolcreate', attach $attachvdev to $attachto."
46 log_must zpool create
-o cachefile
=$CPATH $TESTPOOL1 $poolcreate
48 log_must
cp $CPATH $CPATHBKP
50 log_must zpool attach
$TESTPOOL1 $attachto $attachvdev
52 log_must zpool
export $TESTPOOL1
54 log_must zpool import
-c $CPATHBKP $TESTPOOL1
55 log_must check_pool_config
$TESTPOOL1 "$poolcheck"
58 log_must zpool destroy
$TESTPOOL1
59 log_must
rm -f $CPATH $CPATHBKP
64 test_attach_vdev
"$VDEV0" "$VDEV0" "$VDEV4" "mirror $VDEV0 $VDEV4"
65 test_attach_vdev
"$VDEV0 $VDEV1" "$VDEV1" "$VDEV4" \
66 "$VDEV0 mirror $VDEV1 $VDEV4"
67 test_attach_vdev
"mirror $VDEV0 $VDEV1" "$VDEV0" "$VDEV4" \
68 "mirror $VDEV0 $VDEV1 $VDEV4"
69 test_attach_vdev
"$VDEV0 log $VDEV1" "$VDEV1" "$VDEV4" \
70 "$VDEV0 log mirror $VDEV1 $VDEV4"
72 log_pass
"zpool import -c cachefile_unaware_of_attach passed."