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# ident "@(#)history_008_pos.ksh 1.3 09/01/12 SMI" 28# 29 30. $STF_SUITE/tests/history/history_common.kshlib 31. $STF_SUITE/tests/cli_root/zfs_rollback/zfs_rollback_common.kshlib 32 33################################################################################# 34# 35# __stc_assertion_start 36# 37# ID: history_008_pos 38# 39# DESCRIPTION: 40# Internal journal records all the recursively operations. 41# 42# STRATEGY: 43# 1. Create a filesystem and several sub-filesystems in it. 44# 2. Make recursively snapshot. 45# 3. Verify internal journal records all the recursively operations. 46# 4. Do the same verification to inherit, rollback and destroy. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2006-12-22) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "global" 59 60$ZFS 2>&1 | $GREP "allow" > /dev/null 61(($? != 0)) && log_unsupported 62 63function cleanup 64{ 65 [[ -f $REAL_HISTORY ]] && $RM -f $REAL_HISTORY 66 [[ -f $ADD_HISTORY ]] && $RM -f $ADD_HISTORY 67 if datasetexists $root_testfs; then 68 log_must $ZFS destroy -rf $root_testfs 69 fi 70 log_must $ZFS create $root_testfs 71} 72 73log_assert "Internal journal records all the recursively operations." 74log_onexit cleanup 75 76root_testfs=$TESTPOOL/$TESTFS 77fs1=$root_testfs/fs1; fs2=$root_testfs/fs2; fs3=$root_testfs/fs3 78for fs in $fs1 $fs2 $fs3; do 79 log_must $ZFS create $fs 80done 81 82# 83# Verify 'zfs snapshot -r' 84# 85format_history $TESTPOOL $REAL_HISTORY -i 86log_must $ZFS snapshot -r ${root_testfs}@snap 87additional_history $TESTPOOL $ADD_HISTORY -i 88for ds in $fs1 $fs2 $fs3 ; do 89 log_must verify_history $ADD_HISTORY "snapshot" ${ds}@snap 90done 91 92log_must $ZFS snapshot ${root_testfs}@snap2 93log_must $ZFS snapshot ${root_testfs}@snap3 94typeset snap2_id=$(get_dataset_id ${root_testfs}@snap2) 95typeset snap3_id=$(get_dataset_id ${root_testfs}@snap3) 96 97# 98# Verify 'zfs rollback -r' 99# 100format_history $TESTPOOL $REAL_HISTORY -i 101log_must $ZFS rollback -r ${root_testfs}@snap 102additional_history $TESTPOOL $ADD_HISTORY -i 103 104cat $ADD_HISTORY 105for ds_id in ${snap2_id} ${snap3_id}; do 106 log_must verify_destroyed $ADD_HISTORY $ds_id 107done 108log_must verify_direct_history $ADD_HISTORY "rollback -r" $root_testfs 109 110# 111# Verify 'zfs inherit -r' 112# 113format_history $TESTPOOL $REAL_HISTORY -i 114log_must $ZFS inherit -r mountpoint $root_testfs 115additional_history $TESTPOOL $ADD_HISTORY -i 116cat $ADD_HISTORY 117for ds in $fs1 $fs2 $fs3 $root_testfs; do 118 log_must verify_history $ADD_HISTORY "inherit" $ds 119done 120log_must verify_direct_history $ADD_HISTORY "inherit -r mountpoint" $root_testfs 121 122# Initial original $REAL_HISTORY 123format_history $TESTPOOL $REAL_HISTORY -i 124 125fs1_id=$(get_dataset_id $fs1) 126fs2_id=$(get_dataset_id $fs2) 127fs3_id=$(get_dataset_id $fs3) 128root_id=$(get_dataset_id $root_testfs) 129fs1_snap_id=$(get_dataset_id ${fs1}@snap) 130fs2_snap_id=$(get_dataset_id ${fs2}@snap) 131fs3_snap_id=$(get_dataset_id ${fs3}@snap) 132root_snap_id=$(get_dataset_id ${root_testfs}@snap) 133 134# 135# Verify 'zfs destroy -r' 136# 137log_must $ZFS destroy -r $root_testfs 138additional_history $TESTPOOL $ADD_HISTORY -i 139cat $ADD_HISTORY 140for ds_id in ${fs1_id} ${fs2_id} ${fs3_id} ${root_id} ${fs1_snap_id} ${fs2_snap_id} ${fs3_snap_id} ${root_snap_id}; do 141 log_must verify_destroyed $ADD_HISTORY $ds_id 142done 143log_must verify_direct_history $ADD_HISTORY "destroy -r" $root_testfs 144 145log_pass "Internal journal records all the recursively operations passed." 146