]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/history/history_007_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) 2013 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/history
/history_common.kshlib
37 # Verify command history moves with pool while pool being migrated
40 # 1. Import uniform platform and cross platform pools
41 # 2. Contract the command history of the imported pool
42 # 3. Compare imported history log with the previous log.
45 verify_runnable
"global"
49 poolexists
$migratedpoolname && \
50 log_must
$ZPOOL destroy
-f $migratedpoolname
52 [[ -d $import_dir ]] && $RM -rf $import_dir
55 log_assert
"Verify command history moves with migrated pool."
58 tst_dir
=$STF_SUITE/tests
/functional
/history
59 import_dir
=$TESTDIR/importdir.$$
60 migrated_cmds_f
=$import_dir/migrated_history.$$
61 migratedpoolname
=$MIGRATEDPOOLNAME
65 [[ ! -d $import_dir ]] && log_must
$MKDIR $import_dir
67 # We test the migrations on both uniform platform and cross platform
68 for arch
in "i386" "sparc"; do
69 log_must
$CP $tst_dir/${arch}.orig_history.txt
$import_dir
70 orig_cmds_f
=$import_dir/${arch}.orig_history.txt
72 orig_cmds_f1
=$import_dir/${arch}.orig_history_1.txt
73 $CAT $orig_cmds_f |
$GREP -v "^$" > $orig_cmds_f1
75 log_must
$CP $tst_dir/${arch}.migratedpool.DAT.Z
$import_dir
76 log_must
$UNCOMPRESS $import_dir/${arch}.migratedpool.DAT.Z
78 # destroy the pool with same name, so that import operation succeeds.
79 poolexists
$migratedpoolname && \
80 log_must
$ZPOOL destroy
-f $migratedpoolname
82 log_must
$ZPOOL import
-d $import_dir $migratedpoolname
83 TZ
=$TIMEZONE $ZPOOL history $migratedpoolname |
$GREP -v "^$" \
86 (( $RET != 0 )) && log_fail
"$ZPOOL histroy $migratedpoolname fails."
88 # The migrated history file should differ with original history file on
89 # two commands -- 'export' and 'import', which are included in migrated
90 # history file but not in original history file. so, check the two
91 # commands firstly in migrated history file and then delete them, and
92 # then compare this filtered file with the original history file. They
93 # should be identical at this time.
94 for subcmd
in "export" "import"; do
95 $GREP "$subcmd" $migrated_cmds_f >/dev
/null
2>&1
97 (( $RET != 0 )) && log_fail
"zpool $subcmd is not logged for" \
98 "the imported pool $migratedpoolname."
101 tmpfile
=$import_dir/cmds_tmp.$$
102 linenum
=`$CAT $migrated_cmds_f | $WC -l`
103 (( linenum
= linenum
- 2 ))
104 $HEAD -n $linenum $migrated_cmds_f > $tmpfile
105 log_must
$DIFF $tmpfile $orig_cmds_f1
107 # cleanup for next loop testing
108 log_must
$ZPOOL destroy
-f $migratedpoolname
109 log_must
$RM -f `$LS $import_dir`
112 log_pass
"Verify command history moves with migrated pool."