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