]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_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 # Verify that an exported pool cannot be imported
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 # 4. Verify it shows up under 'zpool list'.
48 # 5. Verify it contains a file.
49 # 6. Attempt to import it for a second time. Verify this fails.
52 verify_runnable
"global"
54 set -A pools
"$TESTPOOL" "$TESTPOOL1"
55 set -A devs
"" "-d $DEVICE_DIR"
56 set -A options
"" "-R $ALTER_ROOT"
57 set -A mtpts
"$TESTDIR" "$TESTDIR1"
63 while (( i
< ${#pools[*]} )); do
64 poolexists
${pools[i]} && \
65 log_must zpool
export ${pools[i]}
67 datasetexists
"${pools[i]}/$TESTFS" || \
68 log_must zpool import
${devs[i]} ${pools[i]}
70 ismounted
"${pools[i]}/$TESTFS" || \
71 log_must zfs mount
${pools[i]}/$TESTFS
73 [[ -e ${mtpts[i]}/$TESTFILE0 ]] && \
74 log_must
rm -rf ${mtpts[i]}/$TESTFILE0
79 cleanup_filesystem
$TESTPOOL1 $TESTFS
81 destroy_pool
$TESTPOOL1
83 [[ -d $ALTER_ROOT ]] && \
84 log_must
rm -rf $ALTER_ROOT
89 log_assert
"Verify that an exported pool cannot be imported more than once."
91 setup_filesystem
"$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
93 checksum1
=$
(sum $MYTESTFILE |
awk '{print $1}')
99 while (( i
< ${#pools[*]} )); do
100 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."
116 log_must zpool import
${devs[i]} ${options[j]} $target
118 log_must poolexists
${pools[i]}
120 log_must ismounted
${pools[i]}/$TESTFS
123 [[ -n ${options[j]} ]] && \
124 basedir
=$ALTER_ROOT/${mtpts[i]}
126 [[ ! -e $basedir/$TESTFILE0 ]] && \
127 log_fail
"$basedir/$TESTFILE0 missing after import."
129 checksum2
=$
(sum $basedir/$TESTFILE0 |
awk '{print $1}')
130 [[ "$checksum1" != "$checksum2" ]] && \
131 log_fail
"Checksums differ ($checksum1 != $checksum2)"
133 log_mustnot zpool import
${devs[i]} $target
142 log_pass
"Unable to import the same pool twice as expected."