]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_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, it should be recreated after a
39 # successful import. Verify that is true.
42 # 1. Populate the default test directory and unmount it.
43 # 2. Export the default test pool.
44 # 3. Import it using the various combinations.
46 # - Alternate Root Specified
47 # Try to import it by name or guid randomly.
48 # 4. Verify it shows up under 'zpool list'.
49 # 5. Verify it can be mounted again and contains a file.
52 verify_runnable
"global"
54 set -A pools
"$TESTPOOL" "$TESTPOOL1"
55 set -A devs
" -s" "-d $DEVICE_DIR"
56 set -A options
"" "-R $ALTER_ROOT"
57 set -A mtpts
"$TESTDIR" "$TESTDIR1"
64 while (( i
< ${#pools[*]} )); do
65 poolexists
${pools[i]} && \
66 log_must zpool
export ${pools[i]}
68 datasetexists
"${pools[i]}/$TESTFS" || \
69 log_must zpool import
${devs[i]} ${pools[i]}
71 ismounted
"${pools[i]}/$TESTFS" || \
72 log_must zfs mount
${pools[i]}/$TESTFS
74 [[ -e ${mtpts[i]}/$TESTFILE0 ]] && \
75 log_must
rm -rf ${mtpts[i]}/$TESTFILE0
80 cleanup_filesystem
$TESTPOOL1 $TESTFS
82 destroy_pool
$TESTPOOL1
84 [[ -d $ALTER_ROOT ]] && \
85 log_must
rm -rf $ALTER_ROOT
90 log_assert
"Verify that an exported pool can be imported."
92 setup_filesystem
"$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
94 checksum1
=$
(sum $MYTESTFILE |
awk '{print $1}')
100 while (( i
< ${#pools[*]} )); do
101 guid
=$
(get_config
${pools[i]} pool_guid
)
102 log_must
cp $MYTESTFILE ${mtpts[i]}/$TESTFILE0
104 log_must zfs umount
${mtpts[i]}
107 while (( j
< ${#options[*]} )); do
108 log_must zpool
export ${pools[i]}
110 typeset target
=${pools[i]}
111 if (( RANDOM
% 2 == 0 )) ; then
113 log_note
"Import by guid."
115 log_must zpool import
${devs[i]} ${options[j]} $target
117 log_must poolexists
${pools[i]}
119 log_must ismounted
${pools[i]}/$TESTFS
122 [[ -n ${options[j]} ]] && \
123 basedir
=$ALTER_ROOT/${mtpts[i]}
125 [[ ! -e $basedir/$TESTFILE0 ]] && \
126 log_fail
"$basedir/$TESTFILE0 missing after import."
128 checksum2
=$
(sum $basedir/$TESTFILE0 |
awk '{print $1}')
129 [[ "$checksum1" != "$checksum2" ]] && \
130 log_fail
"Checksums differ ($checksum1 != $checksum2)"
138 log_pass
"Successfully imported a ZPOOL"