]>
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 2009 Sun Microsystems, Inc. All rights reserved. | |
25 | # Use is subject to license terms. | |
26 | ||
27 | # | |
c1d9abf9 | 28 | # Copyright (c) 2013, 2016 by Delphix. All rights reserved. |
6bb24f4d BB |
29 | # |
30 | ||
31 | . $STF_SUITE/tests/functional/history/history_common.kshlib | |
32 | ||
33 | # | |
34 | # DESCRIPTION: | |
35 | # Create a scenario to verify the following zfs subcommands are logged. | |
36 | # create, destroy, clone, rename, snapshot, rollback, set, inherit, | |
37 | # receive, promote, hold and release. | |
38 | # | |
39 | # STRATEGY: | |
40 | # 1. Verify that all the zfs commands listed (barring send) produce an | |
41 | # entry in the pool history. | |
42 | # | |
43 | ||
44 | verify_runnable "global" | |
45 | ||
46 | function cleanup | |
47 | { | |
48 | ||
c1d9abf9 JWK |
49 | [[ -f $tmpfile ]] && rm -f $tmpfile |
50 | [[ -f $tmpfile2 ]] && rm -f $tmpfile2 | |
6bb24f4d | 51 | for dataset in $fs $newfs $fsclone $vol $newvol $volclone; do |
c1d9abf9 | 52 | datasetexists $dataset && zfs destroy -Rf $dataset |
6bb24f4d | 53 | done |
c1d9abf9 | 54 | rm -rf /history.$$ |
6bb24f4d BB |
55 | } |
56 | ||
57 | log_assert "Verify zfs sub-commands which modify state are logged." | |
58 | log_onexit cleanup | |
59 | ||
60 | fs=$TESTPOOL/$TESTFS1; newfs=$TESTPOOL/newfs; fsclone=$TESTPOOL/clone | |
61 | vol=$TESTPOOL/$TESTVOL ; newvol=$TESTPOOL/newvol; volclone=$TESTPOOL/volclone | |
62 | fssnap=$fs@fssnap; fssnap2=$fs@fssnap2 | |
63 | volsnap=$vol@volsnap; volsnap2=$vol@volsnap2 | |
0fe7c953 | 64 | tmpfile=$TEST_BASE_DIR/tmpfile.$$ ; tmpfile2=$TEST_BASE_DIR/tmpfile2.$$ |
6bb24f4d BB |
65 | |
66 | if is_linux; then | |
67 | # property value property value | |
68 | # | |
69 | props=( | |
70 | quota 64M recordsize 512 | |
71 | reservation 32M reservation none | |
72 | mountpoint /history.$$ mountpoint legacy | |
73 | mountpoint none compression lz4 | |
74 | compression on compression off | |
75 | compression lzjb acltype noacl | |
76 | acltype posixacl xattr sa | |
77 | atime on atime off | |
78 | devices on devices off | |
79 | exec on exec off | |
80 | setuid on setuid off | |
81 | readonly on readonly off | |
82 | zoned on zoned off | |
83 | snapdir hidden snapdir visible | |
84 | aclinherit discard aclinherit noallow | |
85 | aclinherit secure aclinherit passthrough | |
86 | canmount off canmount on | |
87 | xattr on xattr off | |
88 | compression gzip compression gzip-$((RANDOM%9 + 1)) | |
89 | copies $((RANDOM%3 + 1)) | |
90 | ) | |
7839c4b5 MM |
91 | elif is_freebsd; then |
92 | # property value property value | |
93 | # | |
94 | props=( | |
95 | quota 64M recordsize 512 | |
96 | reservation 32M reservation none | |
97 | mountpoint /history.$$ mountpoint legacy | |
98 | mountpoint none sharenfs on | |
99 | sharenfs off | |
100 | compression on compression off | |
101 | compression lzjb aclmode discard | |
102 | aclmode groupmask aclmode passthrough | |
103 | atime on atime off | |
104 | devices on devices off | |
105 | exec on exec off | |
106 | setuid on setuid off | |
107 | readonly on readonly off | |
108 | zoned on zoned off | |
109 | snapdir hidden snapdir visible | |
110 | aclinherit discard aclinherit noallow | |
111 | aclinherit secure aclinherit passthrough | |
112 | canmount off canmount on | |
113 | compression gzip compression gzip-$((RANDOM%9 + 1)) | |
114 | copies $((RANDOM%3 + 1)) | |
115 | ) | |
6bb24f4d BB |
116 | else |
117 | # property value property value | |
118 | # | |
119 | props=( | |
120 | quota 64M recordsize 512 | |
121 | reservation 32M reservation none | |
122 | mountpoint /history.$$ mountpoint legacy | |
123 | mountpoint none sharenfs on | |
124 | sharenfs off | |
125 | compression on compression off | |
126 | compression lzjb aclmode discard | |
127 | aclmode groupmask aclmode passthrough | |
128 | atime on atime off | |
129 | devices on devices off | |
130 | exec on exec off | |
131 | setuid on setuid off | |
132 | readonly on readonly off | |
133 | zoned on zoned off | |
134 | snapdir hidden snapdir visible | |
135 | aclinherit discard aclinherit noallow | |
136 | aclinherit secure aclinherit passthrough | |
137 | canmount off canmount on | |
138 | xattr on xattr off | |
139 | compression gzip compression gzip-$((RANDOM%9 + 1)) | |
140 | copies $((RANDOM%3 + 1)) | |
141 | ) | |
142 | fi | |
143 | ||
c1d9abf9 | 144 | run_and_verify "zfs create $fs" |
6bb24f4d BB |
145 | # Set all the property for filesystem |
146 | typeset -i i=0 | |
147 | while ((i < ${#props[@]})) ; do | |
c1d9abf9 | 148 | run_and_verify "zfs set ${props[$i]}=${props[((i+1))]} $fs" |
6bb24f4d BB |
149 | |
150 | # quota, reservation, canmount can not be inherited. | |
151 | # | |
152 | if [[ ${props[$i]} != "quota" && ${props[$i]} != "reservation" && \ | |
153 | ${props[$i]} != "canmount" ]]; | |
154 | then | |
c1d9abf9 | 155 | run_and_verify "zfs inherit ${props[$i]} $fs" |
6bb24f4d BB |
156 | fi |
157 | ||
158 | ((i += 2)) | |
159 | done | |
160 | ||
c1d9abf9 JWK |
161 | run_and_verify "zfs create -V 64M $vol" |
162 | run_and_verify "zfs set volsize=32M $vol" | |
163 | run_and_verify "zfs snapshot $fssnap" | |
164 | run_and_verify "zfs hold tag $fssnap" | |
165 | run_and_verify "zfs release tag $fssnap" | |
166 | run_and_verify "zfs snapshot $volsnap" | |
167 | run_and_verify "zfs snapshot $fssnap2" | |
168 | run_and_verify "zfs snapshot $volsnap2" | |
6bb24f4d BB |
169 | |
170 | # Send isn't logged... | |
88eaf610 TC |
171 | log_must eval "zfs send -i $fssnap $fssnap2 > $tmpfile" |
172 | log_must eval "zfs send -i $volsnap $volsnap2 > $tmpfile2" | |
6bb24f4d | 173 | # Verify that's true |
c1d9abf9 | 174 | zpool history $TESTPOOL | grep 'zfs send' >/dev/null 2>&1 && \ |
6bb24f4d BB |
175 | log_fail "'zfs send' found in history of \"$TESTPOOL\"" |
176 | ||
c1d9abf9 JWK |
177 | run_and_verify "zfs destroy $fssnap2" |
178 | run_and_verify "zfs destroy $volsnap2" | |
179 | run_and_verify "zfs receive $fs < $tmpfile" | |
180 | run_and_verify "zfs receive $vol < $tmpfile2" | |
181 | run_and_verify "zfs rollback -r $fssnap" | |
182 | run_and_verify "zfs rollback -r $volsnap" | |
183 | run_and_verify "zfs clone $fssnap $fsclone" | |
184 | run_and_verify "zfs clone $volsnap $volclone" | |
185 | run_and_verify "zfs rename $fs $newfs" | |
186 | run_and_verify "zfs rename $vol $newvol" | |
187 | run_and_verify "zfs promote $fsclone" | |
188 | run_and_verify "zfs promote $volclone" | |
189 | run_and_verify "zfs destroy $newfs" | |
190 | run_and_verify "zfs destroy $newvol" | |
191 | run_and_verify "zfs destroy -rf $fsclone" | |
192 | run_and_verify "zfs destroy -rf $volclone" | |
6bb24f4d BB |
193 | |
194 | log_pass "zfs sub-commands which modify state are logged passed." |