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 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/tests/functional/history/history_common.kshlib
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.
40 # 1. Verify that all the zfs commands listed (barring send) produce an
41 # entry in the pool history.
44 verify_runnable "global"
49 [[ -f $tmpfile ]] && rm -f $tmpfile
50 [[ -f $tmpfile2 ]] && rm -f $tmpfile2
51 for dataset in $fs $newfs $fsclone $vol $newvol $volclone; do
52 datasetexists $dataset && zfs destroy -Rf $dataset
57 log_assert "Verify zfs sub-commands which modify state are logged."
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
64 tmpfile=$TEST_BASE_DIR/tmpfile.$$ ; tmpfile2=$TEST_BASE_DIR/tmpfile2.$$
67 # property value property value
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 off
76 acltype posix acltype nfsv4
78 devices on devices off
81 readonly on readonly off
83 snapdir hidden snapdir visible
84 aclinherit discard aclinherit noallow
85 aclinherit secure aclinherit passthrough
86 canmount off canmount on
87 compression gzip compression gzip-$((RANDOM%9 + 1))
88 compression zstd compression zstd-$((RANDOM%9 + 1))
89 compression zstd-fast copies $((RANDOM%3 + 1))
90 compression zstd-fast-$((RANDOM%9 + 1)) xattr sa
94 # property value property value
97 quota 64M recordsize 512
98 reservation 32M reservation none
99 mountpoint /history.$$ mountpoint legacy
100 mountpoint none sharenfs on
102 compression on compression off
103 compression lzjb aclmode discard
104 aclmode groupmask aclmode passthrough
106 devices on devices off
109 readonly on readonly off
111 snapdir hidden snapdir visible
112 aclinherit discard aclinherit noallow
113 aclinherit secure aclinherit passthrough
114 canmount off canmount on
115 compression gzip compression gzip-$((RANDOM%9 + 1))
116 compression zstd compression zstd-$((RANDOM%9 + 1))
117 compression zstd-fast copies $((RANDOM%3 + 1))
118 compression zstd-fast-$((RANDOM%9 + 1)) acltype off
119 acltype posix acltype nfsv4
122 # property value property value
125 quota 64M recordsize 512
126 reservation 32M reservation none
127 mountpoint /history.$$ mountpoint legacy
128 mountpoint none sharenfs on
130 compression on compression off
131 compression lzjb aclmode discard
132 aclmode groupmask aclmode passthrough
134 devices on devices off
137 readonly on readonly off
139 snapdir hidden snapdir visible
140 aclinherit discard aclinherit noallow
141 aclinherit secure aclinherit passthrough
142 canmount off canmount on
144 compression gzip compression gzip-$((RANDOM%9 + 1))
145 copies $((RANDOM%3 + 1))
149 run_and_verify "zfs create $fs"
150 # Set all the property for filesystem
152 while ((i < ${#props[@]})) ; do
153 run_and_verify "zfs set ${props[$i]}=${props[((i+1))]} $fs"
155 # quota, reservation, canmount can not be inherited.
157 if [[ ${props[$i]} != "quota" && ${props[$i]} != "reservation" && \
158 ${props[$i]} != "canmount" ]];
160 run_and_verify "zfs inherit ${props[$i]} $fs"
166 run_and_verify "zfs create -V 64M $vol"
167 run_and_verify "zfs set volsize=32M $vol"
168 run_and_verify "zfs snapshot $fssnap"
169 run_and_verify "zfs hold tag $fssnap"
170 run_and_verify "zfs release tag $fssnap"
171 run_and_verify "zfs snapshot $volsnap"
172 run_and_verify "zfs snapshot $fssnap2"
173 run_and_verify "zfs snapshot $volsnap2"
175 # Send isn't logged...
176 log_must eval "zfs send -i $fssnap $fssnap2 > $tmpfile"
177 log_must eval "zfs send -i $volsnap $volsnap2 > $tmpfile2"
179 zpool history $TESTPOOL | grep 'zfs send' >/dev/null 2>&1 && \
180 log_fail "'zfs send' found in history of \"$TESTPOOL\""
182 run_and_verify "zfs destroy $fssnap2"
183 run_and_verify "zfs destroy $volsnap2"
184 run_and_verify "zfs receive $fs < $tmpfile"
185 run_and_verify "zfs receive $vol < $tmpfile2"
186 run_and_verify "zfs rollback -r $fssnap"
187 run_and_verify "zfs rollback -r $volsnap"
188 run_and_verify "zfs clone $fssnap $fsclone"
189 run_and_verify "zfs clone $volsnap $volclone"
190 run_and_verify "zfs rename $fs $newfs"
191 run_and_verify "zfs rename $vol $newvol"
192 run_and_verify "zfs promote $fsclone"
193 run_and_verify "zfs promote $volclone"
194 run_and_verify "zfs destroy $newfs"
195 run_and_verify "zfs destroy $newvol"
196 run_and_verify "zfs destroy -rf $fsclone"
197 run_and_verify "zfs destroy -rf $volclone"
199 log_pass "zfs sub-commands which modify state are logged passed."