]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_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 # damaged or missing (d/m), 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 # Verify those are true.
49 # 1. Create test pool upon device files using the various combinations.
53 # 2. Create necessary filesystem and test files.
54 # 3. Export the test pool.
55 # 4. Remove one or more devices
56 # 5. Verify 'zpool import' will handle d/m device successfully.
57 # Using the various combinations.
59 # - Alternate Root Specified
60 # It should be succeed with single d/m device upon 'raidz' & 'mirror',
61 # but failed against 'regular' or more d/m devices.
62 # 6. If import succeed, verify following is true:
63 # - The pool shows up under 'zpool list'.
64 # - The pool's health should be DEGRADED.
65 # - It contains the correct test file
68 verify_runnable
"global"
70 set -A vdevs
"" "mirror" "raidz"
71 set -A options
"" "-R $ALTER_ROOT"
78 [[ -d $ALTER_ROOT ]] && \
79 log_must
rm -rf $ALTER_ROOT
82 function recreate_files
84 if poolexists
"$TESTPOOL1" ; then
85 cleanup_filesystem
$TESTPOOL1 $TESTFS
86 destroy_pool
$TESTPOOL1
89 log_must
rm -rf $DEVICE_DIR/*
91 while (( i
< $MAX_NUM )); do
92 log_must mkfile
$FILE_SIZE ${DEVICE_DIR}/${DEVICE_FILE}$i
99 log_assert
"Verify that import could handle damaged or missing device."
102 cd $DEVICE_DIR || log_fail
"Unable change directory to $DEVICE_DIR"
104 checksum1
=$
(sum $MYTESTFILE |
awk '{print $1}')
109 typeset basedir backup
111 while (( i
< ${#vdevs[*]} )); do
113 setup_filesystem
"$DEVICE_FILES" \
114 $TESTPOOL1 $TESTFS $TESTDIR1 \
119 guid
=$
(get_config
$TESTPOOL1 pool_guid
)
120 log_must
cp $MYTESTFILE $TESTDIR1/$TESTFILE0
122 log_must zfs umount
$TESTDIR1
125 while (( j
< ${#options[*]} )); do
131 # Restore all device files.
133 [[ -n $backup ]] && \
134 log_must
tar xf
$DEVICE_DIR/$DEVICE_ARCHIVE
136 for device
in $DEVICE_FILES ; do
137 log_must
rm -f $device
139 poolexists
$TESTPOOL1 && \
140 log_must zpool
export $TESTPOOL1
143 # Backup all device files while filesystem prepared.
145 if [[ -z $backup ]]; then
146 log_must
tar cf
$DEVICE_DIR/$DEVICE_ARCHIVE \
151 (( count
= count
+ 1 ))
153 case "${vdevs[i]}" in
154 'mirror') (( count
== $GROUP_NUM )) && \
157 'raidz') (( count
> 1 )) && \
160 '') action
=log_mustnot
164 typeset target
=$TESTPOOL1
165 if (( RANDOM
% 2 == 0 )) ; then
167 log_note
"Import by guid."
169 $action zpool import \
170 -d $DEVICE_DIR ${options[j]} $target
172 [[ $action == "log_mustnot" ]] && continue
174 log_must poolexists
$TESTPOOL1
176 health
=$
(zpool list
-H -o health
$TESTPOOL1)
178 [[ $health == "DEGRADED" ]] || \
179 log_fail
"$TESTPOOL1: Incorrect health($health)"
180 log_must ismounted
$TESTPOOL1/$TESTFS
183 [[ -n ${options[j]} ]] && \
184 basedir
=$ALTER_ROOT/$TESTDIR1
186 [[ ! -e $basedir/$TESTFILE0 ]] && \
187 log_fail
"$basedir/$TESTFILE0 missing after import."
189 checksum2
=$
(sum $basedir/$TESTFILE0 |
awk '{print $1}')
190 [[ "$checksum1" != "$checksum2" ]] && \
191 log_fail
"Checksums differ ($checksum1 != $checksum2)"
203 log_pass
"Import could handle damaged or missing device."