]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh
60ccc0dd6006a346377a5b5a1a9dc43249225bcb
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 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 # An exported pool can be imported under a different name. Hence
39 # we test that a previously exported pool can be renamed.
42 # 1. Copy a file into the default test directory.
43 # 2. Umount the default directory.
45 # 4. Import the pool using the name ${TESTPOOL}-new,
46 # and using the various combinations.
48 # - Alternate Root Specified
49 # 5. Verify it exists in the 'zpool list' output.
50 # 6. Verify the default file system is mounted and that the file
51 # from step (1) is present.
54 verify_runnable
"global"
56 set -A pools
"$TESTPOOL" "$TESTPOOL1"
57 set -A devs
"" "-d $DEVICE_DIR"
58 set -A options
"" "-R $ALTER_ROOT"
59 set -A mtpts
"$TESTDIR" "$TESTDIR1"
65 while (( i
< ${#pools[*]} )); do
66 if poolexists
"${pools[i]}-new" ; then
67 log_must
$ZPOOL export "${pools[i]}-new"
69 [[ -d /${pools[i]}-new ]] && \
70 log_must
$RM -rf /${pools[i]}-new
72 log_must
$ZPOOL import
${devs[i]} \
73 "${pools[i]}-new" ${pools[i]}
76 datasetexists
"${pools[i]}" || \
77 log_must
$ZPOOL import
${devs[i]} ${pools[i]}
79 ismounted
"${pools[i]}/$TESTFS" || \
80 log_must
$ZFS mount
${pools[i]}/$TESTFS
82 [[ -e ${mtpts[i]}/$TESTFILE0 ]] && \
83 log_must
$RM -rf ${mtpts[i]}/$TESTFILE0
89 cleanup_filesystem
$TESTPOOL1 $TESTFS $TESTDIR1
91 destroy_pool
$TESTPOOL1
93 [[ -d $ALTER_ROOT ]] && \
94 log_must
$RM -rf $ALTER_ROOT
99 log_assert
"Verify that an imported pool can be renamed."
101 setup_filesystem
"$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
102 checksum1
=$
($SUM $MYTESTFILE |
$AWK '{print $1}')
108 while (( i
< ${#pools[*]} )); do
109 guid
=$
(get_config
${pools[i]} pool_guid
)
110 log_must
$CP $MYTESTFILE ${mtpts[i]}/$TESTFILE0
112 log_must
$ZFS umount
${mtpts[i]}
115 while (( j
< ${#options[*]} )); do
116 log_must
$ZPOOL export ${pools[i]}
118 [[ -d /${pools[i]} ]] && \
119 log_must
$RM -rf /${pools[i]}
121 typeset target
=${pools[i]}
122 if (( RANDOM
% 2 == 0 )) ; then
124 log_note
"Import by guid."
127 log_must
$ZPOOL import
${devs[i]} ${options[j]} \
128 $target ${pools[i]}-new
130 log_must poolexists
"${pools[i]}-new"
132 log_must ismounted
${pools[i]}-new/$TESTFS
135 [[ -n ${options[j]} ]] && \
136 basedir
=$ALTER_ROOT/${mtpts[i]}
138 [[ ! -e $basedir/$TESTFILE0 ]] && \
139 log_fail
"$basedir/$TESTFILE0 missing after import."
141 checksum2
=$
($SUM $basedir/$TESTFILE0 |
$AWK '{print $1}')
142 [[ "$checksum1" != "$checksum2" ]] && \
143 log_fail
"Checksums differ ($checksum1 != $checksum2)"
145 log_must
$ZPOOL export "${pools[i]}-new"
147 [[ -d /${pools[i]}-new ]] && \
148 log_must
$RM -rf /${pools[i]}-new
150 target
=${pools[i]}-new
151 if (( RANDOM
% 2 == 0 )) ; then
154 log_must
$ZPOOL import
${devs[i]} $target ${pools[i]}
162 log_pass
"Successfully imported and renamed a ZPOOL"