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