]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/import_paths_changed.ksh
Distributed Spare (dRAID) Feature
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_import / import_paths_changed.ksh
1 #!/bin/ksh -p
2
3 #
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
7 # 1.0 of the CDDL.
8 #
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.
12 #
13
14 #
15 # Copyright (c) 2016 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib
19
20 #
21 # DESCRIPTION:
22 # A pool should be importable even if device paths have changed.
23 #
24 # STRATEGY:
25 # 1. Create a pool.
26 # 2. Export the pool.
27 # 3. Change the paths of some of the devices.
28 # 4. Verify that we can import the pool in a healthy state.
29 #
30
31 verify_runnable "global"
32
33 log_onexit cleanup
34
35 function test_new_paths
36 {
37 typeset poolcreate="$1"
38 typeset pathstochange="$2"
39
40 log_note "$0: pool '$poolcreate', changing paths of $pathstochange."
41
42 log_must zpool create $TESTPOOL1 $poolcreate
43
44 log_must zpool export $TESTPOOL1
45
46 for dev in $pathstochange; do
47 log_must mv $dev "${dev}_new"
48 done
49
50 log_must zpool import -d $DEVICE_DIR $TESTPOOL1
51 log_must check_pool_healthy $TESTPOOL1
52
53 # Cleanup
54 log_must zpool destroy $TESTPOOL1
55 for dev in $pathstochange; do
56 log_must mv "${dev}_new" $dev
57 done
58
59 log_note ""
60 }
61
62 function test_swap_paths
63 {
64 typeset poolcreate="$1"
65 typeset pathtoswap1="$2"
66 typeset pathtoswap2="$3"
67
68 log_note "$0: pool '$poolcreate', swapping paths of $pathtoswap1" \
69 "and $pathtoswap2."
70
71 log_must zpool create $TESTPOOL1 $poolcreate
72
73 log_must zpool export $TESTPOOL1
74
75 log_must mv $pathtoswap2 "$pathtoswap2.tmp"
76 log_must mv $pathtoswap1 "$pathtoswap2"
77 log_must mv "$pathtoswap2.tmp" $pathtoswap1
78
79 log_must zpool import -d $DEVICE_DIR $TESTPOOL1
80 log_must check_pool_healthy $TESTPOOL1
81
82 # Cleanup
83 log_must zpool destroy $TESTPOOL1
84
85 log_note ""
86 }
87
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"
93
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" \
98 "$VDEV0" "$VDEV2"
99
100 log_pass "zpool import succeeded after changing device paths."