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 even if device paths have changed.
27 # 3. Change the paths of some of the devices.
28 # 4. Verify that we can import the pool in a healthy state.
31 verify_runnable
"global"
35 function test_new_paths
37 typeset poolcreate
="$1"
38 typeset pathstochange
="$2"
40 log_note
"$0: pool '$poolcreate', changing paths of $pathstochange."
42 log_must zpool create
$TESTPOOL1 $poolcreate
44 log_must zpool
export $TESTPOOL1
46 for dev
in $pathstochange; do
47 log_must
mv $dev "${dev}_new"
50 log_must zpool import
-d $DEVICE_DIR $TESTPOOL1
51 log_must check_pool_healthy
$TESTPOOL1
54 log_must zpool destroy
$TESTPOOL1
55 for dev
in $pathstochange; do
56 log_must
mv "${dev}_new" $dev
62 function test_swap_paths
64 typeset poolcreate
="$1"
65 typeset pathtoswap1
="$2"
66 typeset pathtoswap2
="$3"
68 log_note
"$0: pool '$poolcreate', swapping paths of $pathtoswap1" \
71 log_must zpool create
$TESTPOOL1 $poolcreate
73 log_must zpool
export $TESTPOOL1
75 log_must
mv $pathtoswap2 "$pathtoswap2.tmp"
76 log_must
mv $pathtoswap1 "$pathtoswap2"
77 log_must
mv "$pathtoswap2.tmp" $pathtoswap1
79 log_must zpool import
-d $DEVICE_DIR $TESTPOOL1
80 log_must check_pool_healthy
$TESTPOOL1
83 log_must zpool destroy
$TESTPOOL1
88 test_new_paths
"$VDEV0 $VDEV1" "$VDEV0 $VDEV1"
89 test_new_paths
"mirror $VDEV0 $VDEV1" "$VDEV0 $VDEV1"
90 test_new_paths
"$VDEV0 log $VDEV1" "$VDEV1"
91 test_new_paths
"raidz $VDEV0 $VDEV1 $VDEV2" "$VDEV1"
92 test_new_paths
"draid $VDEV0 $VDEV1 $VDEV2" "$VDEV1"
94 test_swap_paths
"$VDEV0 $VDEV1" "$VDEV0" "$VDEV1"
95 test_swap_paths
"raidz $VDEV0 $VDEV1 $VDEV2" "$VDEV0" "$VDEV1"
96 test_swap_paths
"draid $VDEV0 $VDEV1 $VDEV2" "$VDEV0" "$VDEV1"
97 test_swap_paths
"mirror $VDEV0 $VDEV1 mirror $VDEV2 $VDEV3" \
100 log_pass
"zpool import succeeded after changing device paths."