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 2008 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: snapshot_012_pos 33# 34# DESCRIPTION: 35# Verify 'snapshot -r' can create snapshot for promoted clone, and vice 36# versa, a clone filesystem from the snapshot created by 'snapshot -r' 37# can be correctly promoted. 38# 39# STRATEGY: 40# 1. Create a dataset tree 41# 2. snapshot a filesystem and clone the snapshot 42# 3. promote the clone 43# 4. snapshot -r the dataset tree 44# 5. verify that the snapshot of cloned filesystem is created correctly 45# 6. clone a snapshot from the snapshot tree 46# 7. promote the clone 47# 8. verify that the clone is promoted correctly. 48# 49# TESTABILITY: explicit 50# 51# TEST_AUTOMATION_LEVEL: automated 52# 53# CODING_STATUS: COMPLETED (2006-06-20) 54# 55# __stc_assertion_end 56# 57################################################################################ 58 59verify_runnable "both" 60 61function cleanup 62{ 63 if datasetexists $clone1; then 64 log_must $ZFS promote $ctrfs 65 log_must $ZFS destroy $clone1 66 fi 67 68 snapexists $snapctr && \ 69 log_must $ZFS destroy -r $snapctr 70 71 if snapexists $clone@$TESTSNAP1; then 72 log_must $ZFS promote $ctrfs 73 log_must $ZFS destroy -rR $ctrfs@$TESTSNAP1 74 fi 75} 76 77log_assert "Verify that 'snapshot -r' can work with 'zfs promote'." 78log_onexit cleanup 79 80ctr=$TESTPOOL/$TESTCTR 81ctrfs=$ctr/$TESTFS1 82clone=$ctr/$TESTCLONE 83clone1=$ctr/$TESTCLONE1 84snappool=$SNAPPOOL 85snapfs=$SNAPFS 86snapctr=$ctr@$TESTSNAP 87snapctrclone=$clone@$TESTSNAP 88snapctrclone1=$clone1@$TESTSNAP 89snapctrfs=$SNAPCTR 90 91#preparation for testing 92log_must $ZFS snapshot $ctrfs@$TESTSNAP1 93log_must $ZFS clone $ctrfs@$TESTSNAP1 $clone 94log_must $ZFS promote $clone 95 96log_must $ZFS snapshot -r $snapctr 97 98! snapexists $snapctrclone && \ 99 log_fail "'snapshot -r' fails to create $snapctrclone for $ctr/$TESTCLONE." 100 101log_must $ZFS clone $snapctrfs $clone1 102log_must $ZFS promote $clone1 103 104#verify the origin value is correct. 105orig_value=$(get_prop origin $ctrfs) 106if ! snapexists $snapctrclone1 || [[ "$orig_value" != "$snapctrclone1" ]]; then 107 log_fail "'zfs promote' fails to promote $clone which is cloned from \ 108 $snapctrfs." 109fi 110 111log_pass "'snapshot -r' can work with 'zfs promote' as expected." 112