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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: zfs_promote_002_pos 33# 34# DESCRIPTION: 35# 'zfs promote' can deal with multiple snapshots in the origin filesystem. 36# 37# STRATEGY: 38# 1. Create multiple snapshots and a clone of the last snapshot 39# 2. Promote the clone filesystem 40# 3. Verify the promoted filesystem included all snapshots 41# 42# TESTABILITY: explicit 43# 44# TEST_AUTOMATION_LEVEL: automated 45# 46# CODING_STATUS: COMPLETED (2006-05-16) 47# 48# __stc_assertion_end 49# 50################################################################################ 51 52verify_runnable "both" 53 54function cleanup 55{ 56 if snapexists $csnap1; then 57 log_must $ZFS promote $fs 58 fi 59 60 typeset ds 61 typeset data 62 for ds in $snap $snap1; do 63 log_must $ZFS destroy -rR $ds 64 done 65 for file in $TESTDIR/$TESTFILE0 $TESTDIR/$TESTFILE1; do 66 [[ -e $file ]] && $RM -f $file 67 done 68} 69 70log_assert "'zfs promote' can deal with multiple snapshots in a filesystem." 71log_onexit cleanup 72 73fs=$TESTPOOL/$TESTFS 74snap=$fs@$TESTSNAP 75snap1=$fs@$TESTSNAP1 76clone=$TESTPOOL/$TESTCLONE 77csnap=$clone@$TESTSNAP 78csnap1=$clone@$TESTSNAP1 79 80# setup for promote testing 81log_must $MKFILE $FILESIZE $TESTDIR/$TESTFILE0 82log_must $ZFS snapshot $snap 83log_must $MKFILE $FILESIZE $TESTDIR/$TESTFILE1 84log_must $RM -f $testdir/$TESTFILE0 85log_must $ZFS snapshot $snap1 86log_must $ZFS clone $snap1 $clone 87log_must $MKFILE $FILESIZE /$clone/$CLONEFILE 88 89log_must $ZFS promote $clone 90 91# verify the 'promote' operation 92for ds in $csnap $csnap1; do 93 ! snapexists $ds && \ 94 log_fail "Snapshot $ds doesn't exist after zfs promote." 95done 96for ds in $snap $snap1; do 97 snapexists $ds && \ 98 log_fail "Snapshot $ds is still there after zfs promote." 99done 100 101origin_prop=$(get_prop origin $fs) 102[[ "$origin_prop" != "$csnap1" ]] && \ 103 log_fail "The dependency of $fs is not correct." 104origin_prop=$(get_prop origin $clone) 105[[ "$origin_prop" != "-" ]] && \ 106 log_fail "The dependency of $clone is not correct." 107 108log_pass "'zfs promote' deal with multiple snapshots as expected." 109 110