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