f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER START
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# The contents of this file are subject to the terms of the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Common Development and Distribution License (the "License").
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You may not use this file except in compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# See the License for the specific language governing permissions
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER END
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy. $STF_SUITE/tests/functional/history/history_common.kshlib
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Create a scenario to verify the following zfs subcommands are logged.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# create, destroy, clone, rename, snapshot, rollback, set, inherit,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# receive, promote, hold and release.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# 1. Verify that all the zfs commands listed (barring send) produce an
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# entry in the pool history.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy for dataset in $fs $newfs $fsclone $vol $newvol $volclone; do
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy datasetexists $dataset && zfs destroy -Rf $dataset
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_assert "Verify zfs sub-commands which modify state are logged."
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyfs=$TESTPOOL/$TESTFS1; newfs=$TESTPOOL/newfs; fsclone=$TESTPOOL/clone
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyvol=$TESTPOOL/$TESTVOL ; newvol=$TESTPOOL/newvol; volclone=$TESTPOOL/volclone
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyvolsnap=$vol@volsnap; volsnap2=$vol@volsnap2
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedytmpfile=/tmp/tmpfile.$$ ; tmpfile2=/tmp/tmpfile2.$$
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# property value property value
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy readonly on readonly off
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy compression gzip compression gzip-$((RANDOM%9 + 1))
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Set all the property for filesystem
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy run_and_verify "zfs set ${props[$i]}=${props[((i+1))]} $fs"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy # quota, reservation, canmount can not be inherited.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy if [[ ${props[$i]} != "quota" && ${props[$i]} != "reservation" && \
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy run_and_verify "zfs inherit ${props[$i]} $fs"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Send isn't logged...
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs send -i $fssnap $fssnap2 > $tmpfile
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs send -i $volsnap $volsnap2 > $tmpfile2
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Verify that's true
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyzpool history $TESTPOOL | grep 'zfs send' >/dev/null 2>&1 && \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_fail "'zfs send' found in history of \"$TESTPOOL\""
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs receive $fs < $tmpfile"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs receive $vol < $tmpfile2"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs clone $fssnap $fsclone"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs clone $volsnap $volclone"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_pass "zfs sub-commands which modify state are logged passed."