1 #! /usr/local/bin/ksh93 -p
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.
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.
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]
26 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
29 # ident "@(#)snapshot_012_pos.ksh 1.3 08/05/14 SMI"
31 . $STF_SUITE/include/libtest.kshlib
33 ################################################################################
35 # __stc_assertion_start
37 # ID: snapshot_012_pos
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.
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.
54 # TESTABILITY: explicit
56 # TEST_AUTOMATION_LEVEL: automated
58 # CODING_STATUS: COMPLETED (2006-06-20)
62 ################################################################################
64 verify_runnable "both"
68 if datasetexists $clone1; then
69 log_must $ZFS promote $ctrfs
70 log_must $ZFS destroy $clone1
73 snapexists $snapctr && \
74 log_must $ZFS destroy -r $snapctr
76 if snapexists $clone@$TESTSNAP1; then
77 log_must $ZFS promote $ctrfs
78 log_must $ZFS destroy -rR $ctrfs@$TESTSNAP1
82 log_assert "Verify that 'snapshot -r' can work with 'zfs promote'."
85 ctr=$TESTPOOL/$TESTCTR
88 clone1=$ctr/$TESTCLONE1
91 snapctr=$ctr@$TESTSNAP
92 snapctrclone=$clone@$TESTSNAP
93 snapctrclone1=$clone1@$TESTSNAP
96 #preparation for testing
97 log_must $ZFS snapshot $ctrfs@$TESTSNAP1
98 log_must $ZFS clone $ctrfs@$TESTSNAP1 $clone
99 log_must $ZFS promote $clone
101 log_must $ZFS snapshot -r $snapctr
103 ! snapexists $snapctrclone && \
104 log_fail "'snapshot -r' fails to create $snapctrclone for $ctr/$TESTCLONE."
106 log_must $ZFS clone $snapctrfs $clone1
107 log_must $ZFS promote $clone1
109 #verify the origin value is correct.
110 orig_value=$(get_prop origin $ctrfs)
111 if ! snapexists $snapctrclone1 || [[ "$orig_value" != "$snapctrclone1" ]]; then
112 log_fail "'zfs promote' fails to promote $clone which is cloned from \
116 log_pass "'snapshot -r' can work with 'zfs promote' as expected."