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