]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
1 | #!/bin/ksh -p |
2 | # | |
3 | # CDDL HEADER START | |
4 | # | |
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. | |
8 | # | |
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. | |
13 | # | |
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] | |
19 | # | |
20 | # CDDL HEADER END | |
21 | # | |
22 | ||
23 | # | |
24 | # Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | # | |
27 | ||
28 | # | |
d7958b4c | 29 | # Copyright (c) 2013, 2015 by Delphix. All rights reserved. |
6bb24f4d BB |
30 | # |
31 | ||
32 | . $STF_SUITE/include/libtest.shlib | |
33 | ||
34 | # | |
35 | # DESCRIPTION: | |
36 | # zpool history will truncate on small pools, leaving pool creation intact | |
37 | # | |
38 | # STRATEGY: | |
d7958b4c MA |
39 | # 1. Create a test pool on a file. |
40 | # 2. Loop 300 times to set and remove compression to test dataset. | |
41 | # 3. Make sure 'zpool history' output is truncated | |
42 | # 4. Verify that the initial pool creation is preserved. | |
6bb24f4d BB |
43 | # |
44 | ||
45 | verify_runnable "global" | |
46 | ||
47 | function cleanup | |
48 | { | |
49 | datasetexists $spool && log_must $ZPOOL destroy $spool | |
50 | [[ -f $VDEV0 ]] && log_must $RM -f $VDEV0 | |
6bb24f4d BB |
51 | [[ -f $TMPFILE ]] && log_must $RM -f $TMPFILE |
52 | } | |
53 | ||
54 | log_assert "zpool history limitation test." | |
55 | log_onexit cleanup | |
56 | ||
57 | mntpnt=$(get_prop mountpoint $TESTPOOL) | |
58 | (( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL" | |
59 | ||
d7958b4c MA |
60 | VDEV0=$mntpnt/vdev0 |
61 | log_must $MKFILE $MINVDEVSIZE $VDEV0 | |
6bb24f4d BB |
62 | |
63 | spool=smallpool.$$; sfs=smallfs.$$ | |
d7958b4c | 64 | log_must $ZPOOL create $spool $VDEV0 |
6bb24f4d BB |
65 | log_must $ZFS create $spool/$sfs |
66 | ||
67 | typeset -i orig_count=$($ZPOOL history $spool | $WC -l) | |
68 | typeset orig_md5=$($ZPOOL history $spool | $HEAD -2 | $MD5SUM | \ | |
69 | $AWK '{print $1}') | |
70 | ||
71 | typeset -i i=0 | |
d7958b4c | 72 | while ((i < 300)); do |
6bb24f4d BB |
73 | $ZFS set compression=off $spool/$sfs |
74 | $ZFS set compression=on $spool/$sfs | |
75 | $ZFS set compression=off $spool/$sfs | |
76 | $ZFS set compression=on $spool/$sfs | |
77 | $ZFS set compression=off $spool/$sfs | |
78 | ||
79 | ((i += 1)) | |
80 | done | |
81 | ||
82 | TMPFILE=/tmp/spool.$$ | |
83 | $ZPOOL history $spool >$TMPFILE | |
84 | typeset -i entry_count=$($WC -l $TMPFILE | $AWK '{print $1}') | |
85 | typeset final_md5=$($HEAD -2 $TMPFILE | $MD5SUM | $AWK '{print $1}') | |
86 | ||
87 | $GREP 'zpool create' $TMPFILE >/dev/null 2>&1 || | |
88 | log_fail "'zpool create' was not found in pool history" | |
89 | ||
90 | $GREP 'zfs create' $TMPFILE >/dev/null 2>&1 && | |
91 | log_fail "'zfs create' was found in pool history" | |
92 | ||
93 | $GREP 'zfs set compress' $TMPFILE >/dev/null 2>&1 || | |
94 | log_fail "'zfs set compress' was found in pool history" | |
95 | ||
96 | # Verify that the creation of the pool was preserved in the history. | |
97 | if [[ $orig_md5 != $final_md5 ]]; then | |
98 | log_fail "zpool creation history was not preserved." | |
99 | fi | |
100 | ||
101 | log_pass "zpool history limitation test passed." |