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