]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/history/history_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.
28 # Copyright (c) 2013, 2015 by Delphix. All rights reserved.
31 .
$STF_SUITE/tests
/functional
/history
/history_common.kshlib
35 # Create a scenario to verify the following zpool subcommands are logged.
36 # create, destroy, add, remove, offline, online, attach, detach, replace,
37 # scrub, export, import, clear, upgrade.
40 # 1. Create three virtual disk files and create a mirror.
41 # 2. Run and verify pool commands, with special casing for destroy/export.
42 # 3. Import a pool and upgrade it, verifying 'upgrade' was logged.
45 verify_runnable
"global"
50 destroy_pool
$upgrade_pool
52 [[ -d $import_dir ]] && $RM -rf $import_dir
53 for file in $VDEV1 $VDEV2 $VDEV3 $VDEV4; do
54 [[ -f $file ]] && $RM -f $file
58 log_assert
"Verify zpool sub-commands which modify state are logged."
61 mntpnt
=$
(get_prop mountpoint
$TESTPOOL)
62 (( $?
!= 0)) && log_fail
"get_prop($TESTPOOL mountpoint)"
63 VDEV1
=$mntpnt/vdev1
; VDEV2
=$mntpnt/vdev2
;
64 VDEV3
=$mntpnt/vdev3
; VDEV4
=$mntpnt/vdev4
;
66 log_must
$MKFILE $MINVDEVSIZE $VDEV1 $VDEV2 $VDEV3
67 log_must
$MKFILE $
(($MINVDEVSIZE * 2)) $VDEV4
69 run_and_verify
-p "$MPOOL" "$ZPOOL create $MPOOL mirror $VDEV1 $VDEV2"
70 run_and_verify
-p "$MPOOL" "$ZPOOL add -f $MPOOL spare $VDEV3"
71 run_and_verify
-p "$MPOOL" "$ZPOOL remove $MPOOL $VDEV3"
72 run_and_verify
-p "$MPOOL" "$ZPOOL offline $MPOOL $VDEV1"
73 run_and_verify
-p "$MPOOL" "$ZPOOL online $MPOOL $VDEV1"
74 run_and_verify
-p "$MPOOL" "$ZPOOL attach $MPOOL $VDEV1 $VDEV4"
75 run_and_verify
-p "$MPOOL" "$ZPOOL detach $MPOOL $VDEV4"
76 run_and_verify
-p "$MPOOL" "$ZPOOL replace -f $MPOOL $VDEV1 $VDEV4"
77 run_and_verify
-p "$MPOOL" "$ZPOOL scrub $MPOOL"
78 run_and_verify
-p "$MPOOL" "$ZPOOL clear $MPOOL"
80 # For export and destroy, mimic the behavior of run_and_verify using two
81 # commands since the history will be unavailable until the pool is imported
83 commands
=("$ZPOOL export $MPOOL" "$ZPOOL import -d $mntpnt $MPOOL"
84 "$ZPOOL destroy $MPOOL" "$ZPOOL import -D -f -d $mntpnt $MPOOL")
86 cmd1
="${commands[$i]}"
87 cmd2
="${commands[(($i + 1 ))]}"
89 $ZPOOL history $MPOOL > $OLD_HISTORY 2>/dev
/null
92 $ZPOOL history $MPOOL > $TMP_HISTORY 2>/dev
/null
93 $DIFF $OLD_HISTORY $TMP_HISTORY |
$GREP "^> " |
$SED 's/^> //g' > \
96 $GREP "$($ECHO "$cmd1" | $SED 's/^.*\/\(zpool .*\).*$/\1/')" \
97 $NEW_HISTORY >/dev
/null
2>&1 || \
98 log_fail
"Didn't find \"$cmd1\" in pool history"
99 $GREP "$($ECHO "$cmd2" | $SED 's/^.*\/\(zpool .*\).*$/\1/')" \
100 $NEW_HISTORY >/dev
/null
2>&1 || \
101 log_fail
"Didn't find \"$cmd2\" in pool history"
103 $GREP "$($ECHO "$cmd1" | $SED 's/\/usr\/sbin\///g')" \
104 $NEW_HISTORY >/dev
/null
2>&1 || \
105 log_fail
"Didn't find \"$cmd1\" in pool history"
106 $GREP "$($ECHO "$cmd2" | $SED 's/\/usr\/sbin\///g')" \
107 $NEW_HISTORY >/dev
/null
2>&1 || \
108 log_fail
"Didn't find \"$cmd2\" in pool history"
112 run_and_verify
-p "$MPOOL" "$ZPOOL split $MPOOL ${MPOOL}_split"
114 import_dir
=/var
/tmp
/import_dir.$$
115 log_must
$MKDIR $import_dir
116 log_must
$CP $STF_SUITE/tests
/functional
/history
/zfs-pool-v4.dat.Z
$import_dir
117 log_must
$UNCOMPRESS $import_dir/zfs-pool-v4.dat.Z
118 upgrade_pool
=$
($ZPOOL import
-d $import_dir |
$GREP "pool:" |
$AWK '{print $2}')
119 log_must
$ZPOOL import
-d $import_dir $upgrade_pool
120 run_and_verify
-p "$upgrade_pool" "$ZPOOL upgrade $upgrade_pool"
122 log_pass
"zpool sub-commands which modify state are logged passed. "