1f38cb554SJohn Wren Kennedy#!/bin/ksh -p 2f38cb554SJohn Wren Kennedy# 3f38cb554SJohn Wren Kennedy# CDDL HEADER START 4f38cb554SJohn Wren Kennedy# 5f38cb554SJohn Wren Kennedy# The contents of this file are subject to the terms of the 6f38cb554SJohn Wren Kennedy# Common Development and Distribution License (the "License"). 7f38cb554SJohn Wren Kennedy# You may not use this file except in compliance with the License. 8f38cb554SJohn Wren Kennedy# 9f38cb554SJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10f38cb554SJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing. 11f38cb554SJohn Wren Kennedy# See the License for the specific language governing permissions 12f38cb554SJohn Wren Kennedy# and limitations under the License. 13f38cb554SJohn Wren Kennedy# 14f38cb554SJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each 15f38cb554SJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16f38cb554SJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the 17f38cb554SJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying 18f38cb554SJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner] 19f38cb554SJohn Wren Kennedy# 20f38cb554SJohn Wren Kennedy# CDDL HEADER END 21f38cb554SJohn Wren Kennedy# 22f38cb554SJohn Wren Kennedy 23f38cb554SJohn Wren Kennedy# 24f38cb554SJohn Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25f38cb554SJohn Wren Kennedy# Use is subject to license terms. 26f38cb554SJohn Wren Kennedy 27f38cb554SJohn Wren Kennedy# 28*1d32ba66SJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 29f38cb554SJohn Wren Kennedy# 30f38cb554SJohn Wren Kennedy 31f38cb554SJohn Wren Kennedy. $STF_SUITE/tests/functional/history/history_common.kshlib 32f38cb554SJohn Wren Kennedy 33f38cb554SJohn Wren Kennedy# 34f38cb554SJohn Wren Kennedy# DESCRIPTION: 35f38cb554SJohn Wren Kennedy# Create a scenario to verify the following zfs subcommands are logged. 36f38cb554SJohn Wren Kennedy# create, destroy, clone, rename, snapshot, rollback, set, inherit, 37f38cb554SJohn Wren Kennedy# receive, promote, hold and release. 38f38cb554SJohn Wren Kennedy# 39f38cb554SJohn Wren Kennedy# STRATEGY: 40f38cb554SJohn Wren Kennedy# 1. Verify that all the zfs commands listed (barring send) produce an 41f38cb554SJohn Wren Kennedy# entry in the pool history. 42f38cb554SJohn Wren Kennedy# 43f38cb554SJohn Wren Kennedy 44f38cb554SJohn Wren Kennedyverify_runnable "global" 45f38cb554SJohn Wren Kennedy 46f38cb554SJohn Wren Kennedyfunction cleanup 47f38cb554SJohn Wren Kennedy{ 48f38cb554SJohn Wren Kennedy 49*1d32ba66SJohn Wren Kennedy [[ -f $tmpfile ]] && rm -f $tmpfile 50*1d32ba66SJohn Wren Kennedy [[ -f $tmpfile2 ]] && rm -f $tmpfile2 51f38cb554SJohn Wren Kennedy for dataset in $fs $newfs $fsclone $vol $newvol $volclone; do 52*1d32ba66SJohn Wren Kennedy datasetexists $dataset && zfs destroy -Rf $dataset 53f38cb554SJohn Wren Kennedy done 54*1d32ba66SJohn Wren Kennedy rm -rf /history.$$ 55f38cb554SJohn Wren Kennedy} 56f38cb554SJohn Wren Kennedy 57f38cb554SJohn Wren Kennedylog_assert "Verify zfs sub-commands which modify state are logged." 58f38cb554SJohn Wren Kennedylog_onexit cleanup 59f38cb554SJohn Wren Kennedy 60f38cb554SJohn Wren Kennedyfs=$TESTPOOL/$TESTFS1; newfs=$TESTPOOL/newfs; fsclone=$TESTPOOL/clone 61f38cb554SJohn Wren Kennedyvol=$TESTPOOL/$TESTVOL ; newvol=$TESTPOOL/newvol; volclone=$TESTPOOL/volclone 62f38cb554SJohn Wren Kennedyfssnap=$fs@fssnap; fssnap2=$fs@fssnap2 63f38cb554SJohn Wren Kennedyvolsnap=$vol@volsnap; volsnap2=$vol@volsnap2 64f38cb554SJohn Wren Kennedytmpfile=/tmp/tmpfile.$$ ; tmpfile2=/tmp/tmpfile2.$$ 65f38cb554SJohn Wren Kennedy 66f38cb554SJohn Wren Kennedy# property value property value 67f38cb554SJohn Wren Kennedy# 68f38cb554SJohn Wren Kennedyprops=( 69f38cb554SJohn Wren Kennedy quota 64M recordsize 512 70f38cb554SJohn Wren Kennedy reservation 32M reservation none 71f38cb554SJohn Wren Kennedy mountpoint /history.$$ mountpoint legacy 72f38cb554SJohn Wren Kennedy mountpoint none sharenfs on 73f38cb554SJohn Wren Kennedy sharenfs off 74f38cb554SJohn Wren Kennedy compression on compression off 75f38cb554SJohn Wren Kennedy compression lzjb aclmode discard 76f38cb554SJohn Wren Kennedy aclmode groupmask aclmode passthrough 77f38cb554SJohn Wren Kennedy atime on atime off 78f38cb554SJohn Wren Kennedy devices on devices off 79f38cb554SJohn Wren Kennedy exec on exec off 80f38cb554SJohn Wren Kennedy setuid on setuid off 81f38cb554SJohn Wren Kennedy readonly on readonly off 82f38cb554SJohn Wren Kennedy zoned on zoned off 83f38cb554SJohn Wren Kennedy snapdir hidden snapdir visible 84f38cb554SJohn Wren Kennedy aclinherit discard aclinherit noallow 85f38cb554SJohn Wren Kennedy aclinherit secure aclinherit passthrough 86f38cb554SJohn Wren Kennedy canmount off canmount on 87f38cb554SJohn Wren Kennedy xattr on xattr off 88f38cb554SJohn Wren Kennedy compression gzip compression gzip-$((RANDOM%9 + 1)) 89f38cb554SJohn Wren Kennedy copies $((RANDOM%3 + 1)) 90f38cb554SJohn Wren Kennedy) 91f38cb554SJohn Wren Kennedy 92*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs create $fs" 93f38cb554SJohn Wren Kennedy# Set all the property for filesystem 94f38cb554SJohn Wren Kennedytypeset -i i=0 95f38cb554SJohn Wren Kennedywhile ((i < ${#props[@]})) ; do 96*1d32ba66SJohn Wren Kennedy run_and_verify "zfs set ${props[$i]}=${props[((i+1))]} $fs" 97f38cb554SJohn Wren Kennedy 98f38cb554SJohn Wren Kennedy # quota, reservation, canmount can not be inherited. 99f38cb554SJohn Wren Kennedy # 100f38cb554SJohn Wren Kennedy if [[ ${props[$i]} != "quota" && ${props[$i]} != "reservation" && \ 101f38cb554SJohn Wren Kennedy ${props[$i]} != "canmount" ]]; 102f38cb554SJohn Wren Kennedy then 103*1d32ba66SJohn Wren Kennedy run_and_verify "zfs inherit ${props[$i]} $fs" 104f38cb554SJohn Wren Kennedy fi 105f38cb554SJohn Wren Kennedy 106f38cb554SJohn Wren Kennedy ((i += 2)) 107f38cb554SJohn Wren Kennedydone 108f38cb554SJohn Wren Kennedy 109*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs create -V 64M $vol" 110*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs set volsize=32M $vol" 111*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs snapshot $fssnap" 112*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs hold tag $fssnap" 113*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs release tag $fssnap" 114*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs snapshot $volsnap" 115*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs snapshot $fssnap2" 116*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs snapshot $volsnap2" 117f38cb554SJohn Wren Kennedy 118f38cb554SJohn Wren Kennedy# Send isn't logged... 119*1d32ba66SJohn Wren Kennedylog_must zfs send -i $fssnap $fssnap2 > $tmpfile 120*1d32ba66SJohn Wren Kennedylog_must zfs send -i $volsnap $volsnap2 > $tmpfile2 121f38cb554SJohn Wren Kennedy# Verify that's true 122*1d32ba66SJohn Wren Kennedyzpool history $TESTPOOL | grep 'zfs send' >/dev/null 2>&1 && \ 123f38cb554SJohn Wren Kennedy log_fail "'zfs send' found in history of \"$TESTPOOL\"" 124f38cb554SJohn Wren Kennedy 125*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs destroy $fssnap2" 126*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs destroy $volsnap2" 127*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs receive $fs < $tmpfile" 128*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs receive $vol < $tmpfile2" 129*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs rollback -r $fssnap" 130*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs rollback -r $volsnap" 131*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs clone $fssnap $fsclone" 132*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs clone $volsnap $volclone" 133*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs rename $fs $newfs" 134*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs rename $vol $newvol" 135*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs promote $fsclone" 136*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs promote $volclone" 137*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs destroy $newfs" 138*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs destroy $newvol" 139*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs destroy -rf $fsclone" 140*1d32ba66SJohn Wren Kennedyrun_and_verify "zfs destroy -rf $volclone" 141f38cb554SJohn Wren Kennedy 142f38cb554SJohn Wren Kennedylog_pass "zfs sub-commands which modify state are logged passed." 143