1#!/usr/local/bin/ksh93 -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. $STF_SUITE/tests/history/history_common.kshlib 28. $STF_SUITE/tests/cli_root/zfs_rollback/zfs_rollback_common.kshlib 29 30################################################################################# 31# 32# __stc_assertion_start 33# 34# ID: history_002_pos 35# 36# DESCRIPTION: 37# Create a scenario to verify the following zfs subcommands are logged. 38# create, destroy, clone, rename, snapshot, rollback, 39# set, inherit, receive, promote. 40# 41# STRATEGY: 42# 1. Format zpool history to file $EXPECT_HISTORY. 43# 2. Invoke every sub-commands to this mirror. 44# 3. Compare 'zpool history' log with expected log. 45# 46# TESTABILITY: explicit 47# 48# TEST_AUTOMATION_LEVEL: automated 49# 50# CODING_STATUS: COMPLETED (2006-07-05) 51# 52# __stc_assertion_end 53# 54################################################################################ 55 56verify_runnable "global" 57 58function cleanup 59{ 60 for FileToRm in $EXPECT_HISTORY $REAL_HISTORY $tmpfile $tmpfile2; do 61 [[ -f $FileToRm ]] && log_must $RM -f $FileToRm 62 done 63 for dataset in $fs $newfs $fsclone $vol $newvol $volclone; do 64 datasetexists $dataset && $ZFS destroy -Rf $dataset 65 done 66 log_must $RM -rf /history.${TESTCASE_ID} 67} 68 69log_assert "Verify zfs sub-commands which modify state are logged." 70log_onexit cleanup 71 72format_history $TESTPOOL $EXPECT_HISTORY 73 74fs=$TESTPOOL/$TESTFS1; newfs=$TESTPOOL/newfs; fsclone=$TESTPOOL/clone 75vol=$TESTPOOL/$TESTVOL ; newvol=$TESTPOOL/newvol; volclone=$TESTPOOL/volclone 76fssnap=$fs@fssnap; fssnap2=$fs@fssnap2 77volsnap=$vol@volsnap; volsnap2=$vol@volsnap2 78 79# property value property value 80# 81set -A props \ 82 quota 64M recordsize 512 \ 83 reservation 32M reservation none \ 84 mountpoint /history.${TESTCASE_ID} mountpoint legacy \ 85 mountpoint none sharenfs on \ 86 sharenfs off \ 87 compression on compression off \ 88 compression lzjb aclmode discard \ 89 aclmode groupmask aclmode passthrough \ 90 atime on atime off \ 91 exec on exec off \ 92 setuid on setuid off \ 93 readonly on readonly off \ 94 snapdir hidden snapdir visible \ 95 aclinherit discard aclinherit noallow \ 96 aclinherit secure aclinherit passthrough \ 97 canmount off canmount on \ 98 compression gzip compression gzip-$((RANDOM%9 + 1)) \ 99 copies $((RANDOM%3 +1)) 100 101# Add a few extra properties not supported on FreeBSD, if applicable. The 102# currently unsupported list is in the source in libzfs_dataset.c. 103if [[ $os_name != "FreeBSD" ]]; then 104 set +A props \ 105 devices on devices off \ 106 zoned on zoned off \ 107 shareiscsi on shareiscsi off \ 108 xattr on xattr off 109fi 110 111tmpfile=$TMPDIR/tmpfile.${TESTCASE_ID} ; tmpfile2=$TMPDIR/tmpfile2.${TESTCASE_ID} 112 113exec_record $ZFS create $fs 114 115typeset enc="" 116enc=$(get_prop encryption $fs) 117if [[ $? -ne 0 ]] || [[ -z "$enc" ]] || [[ "$enc" == "off" ]]; then 118 typeset -i n=${#props[@]} 119 120 props[$n]=checksum ; props[((n+1))]="on" 121 props[((n+2))]=checksum ; props[((n+3))]="off" 122 props[((n+4))]=checksum ; props[((n+5))]="fletcher2" 123 props[((n+6))]=checksum ; props[((n+7))]="fletcher4" 124 props[((n+8))]=checksum ; props[((n+9))]="sha256" 125fi 126 127# Set all the property for filesystem 128typeset -i i=0 129while ((i < ${#props[@]})) ; do 130 exec_record $ZFS set ${props[$i]}=${props[((i+1))]} $fs 131 132 # quota, reservation, canmount can not be inherited. 133 # 134 if [[ ${props[$i]} != "quota" && \ 135 ${props[$i]} != "reservation" && \ 136 ${props[$i]} != "canmount" ]]; 137 then 138 exec_record $ZFS inherit ${props[$i]} $fs 139 fi 140 141 ((i += 2)) 142done 143exec_record $ZFS create -V 64M $vol 144exec_record $ZFS set volsize=32M $vol 145exec_record $ZFS snapshot $fssnap 146exec_record $ZFS snapshot $volsnap 147exec_record $ZFS snapshot $fssnap2 148exec_record $ZFS snapshot $volsnap2 149log_must eval "$ZFS send -i $fssnap $fssnap2 > $tmpfile" 150log_must eval "$ZFS send -i $volsnap $volsnap2 > $tmpfile2" 151exec_record $ZFS destroy $fssnap2 152exec_record $ZFS destroy $volsnap2 153exec_record eval "$ZFS receive $fs < $tmpfile" 154exec_record eval "$ZFS receive $vol < $tmpfile2" 155exec_record $ZFS rollback -r $fssnap 156exec_record $ZFS rollback -r $volsnap 157exec_record $ZFS clone $fssnap $fsclone 158exec_record $ZFS clone $volsnap $volclone 159exec_record $ZFS rename $fs $newfs 160exec_record $ZFS rename $vol $newvol 161exec_record $ZFS promote $fsclone 162exec_record $ZFS promote $volclone 163exec_record $ZFS destroy $newfs 164exec_record $ZFS destroy $newvol 165exec_record $ZFS destroy -rf $fsclone 166exec_record $ZFS destroy -rf $volclone 167 168format_history $TESTPOOL $REAL_HISTORY 169 170log_must $DIFF $REAL_HISTORY $EXPECT_HISTORY 171 172log_pass "zfs sub-commands which modify state are logged passed." 173