]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_002_pos.ksh
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.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_mount
/zfs_mount.kshlib
34 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_import
/zpool_import.cfg
38 # Once a pool has been exported, and one or more devices are
39 # move to other place, import should handle this kind of situation
41 # - Regular, report error while any number of devices failing.
42 # - Mirror could withstand (N-1) devices failing
43 # before data integrity is compromised
44 # - Raidz could withstand one devices failing
45 # before data integrity is compromised
46 # - dRAID could withstand one devices failing
47 # before data integrity is compromised
48 # Verify that is true.
51 # 1. Create test pool upon device files using the various combinations.
56 # 2. Create necessary filesystem and test files.
57 # 3. Export the test pool.
58 # 4. Move one or more device files to other directory
59 # 5. Verify 'zpool import -d' with the new directory
60 # will handle moved files successfully.
61 # Using the various combinations.
63 # - Alternate Root Specified
66 verify_runnable
"global"
68 # Randomly test a subset of combinations to speed up the test.
70 if [[ $rc == 0 ]] ; then
71 set -A vdevs
"" "mirror" "raidz"
72 elif [[ $rc == 1 ]] ; then
73 set -A vdevs
"" "mirror" "draid"
75 set -A vdevs
"" "raidz" "draid"
78 set -A options
"" "-R $ALTER_ROOT"
82 cd $DEVICE_DIR || log_fail
"Unable change directory to $DEVICE_DIR"
83 [[ -e $DEVICE_DIR/$DEVICE_ARCHIVE ]] && \
84 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
86 poolexists
$TESTPOOL1 || \
87 log_must zpool import
-d $DEVICE_DIR $TESTPOOL1
89 cleanup_filesystem
$TESTPOOL1 $TESTFS
91 destroy_pool
$TESTPOOL1
100 while (( i
< $MAX_NUM )); do
101 typeset dev_file
=${DEVICE_DIR}/${DEVICE_FILE}$i
102 if [[ ! -e ${dev_file} ]]; then
103 log_must
rm -f ${dev_file}
104 log_must truncate
-s $FILE_SIZE ${dev_file}
109 log_must
rm -f $DEVICE_DIR/$DEVICE_ARCHIVE
110 cd $CWD || log_fail
"Unable change directory to $CWD"
112 [[ -d $ALTER_ROOT ]] && \
113 log_must
rm -rf $ALTER_ROOT
115 [[ -d $BACKUP_DEVICE_DIR ]] && \
116 log_must
rm -rf $BACKUP_DEVICE_DIR
119 log_onexit cleanup_all
121 log_assert
"Verify that import could handle moving device."
125 [[ ! -d $BACKUP_DEVICE_DIR ]] &&
126 log_must mkdir
-p $BACKUP_DEVICE_DIR
128 cd $DEVICE_DIR || log_fail
"Unable change directory to $DEVICE_DIR"
133 typeset basedir backup
136 while (( i
< ${#vdevs[*]} )); do
139 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
141 setup_filesystem
"$DEVICE_FILES" \
142 $TESTPOOL1 $TESTFS $TESTDIR1 \
145 guid
=$
(get_config
$TESTPOOL1 pool_guid
)
148 log_must
cp $MYTESTFILE $TESTDIR1/$TESTFILE0
150 log_must zfs umount
$TESTDIR1
153 while (( j
< ${#options[*]} )); do
158 # Restore all device files.
160 [[ -n $backup ]] && \
161 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
163 log_must
rm -f $BACKUP_DEVICE_DIR/*
165 for device
in $DEVICE_FILES ; do
167 poolexists
$TESTPOOL1 && \
168 log_must zpool
export $TESTPOOL1
171 # Backup all device files while filesystem prepared.
173 if [[ -z $backup ]] ; then
174 log_must
tar cf
$DEVICE_DIR/$DEVICE_ARCHIVE \
175 ${DEVICE_FILE}0 ${DEVICE_FILE}1 ${DEVICE_FILE}2
179 log_must
mv $device $BACKUP_DEVICE_DIR
181 (( count
= count
+ 1 ))
184 case "${vdevs[i]}" in
185 'mirror') (( count
< $GROUP_NUM )) && \
188 'raidz') (( count
== 1 )) && \
191 'draid') (( count
== 1 )) && \
196 typeset target
=$TESTPOOL1
197 if (( RANDOM
% 2 == 0 )) ; then
199 log_note
"Import by guid."
201 $action zpool import \
202 -d $DEVICE_DIR ${options[j]} $target
214 log_pass
"Import could handle moving device."