]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_008_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_promote / zfs_promote_008_pos.ksh
1 #!/bin/ksh
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) 2016 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33
34 #
35 # DESCRIPTION:
36 #       'zfs promote' can successfully promote a volume clone.
37 #
38 # STRATEGY:
39 #       1. Create a volume clone
40 #       2. Promote the volume clone
41 #       3. Verify the dependency changed.
42 #
43
44 verify_runnable "global"
45
46 function cleanup
47 {
48         if snapexists $csnap; then
49                 log_must zfs promote $vol
50         fi
51
52         destroy_dataset "$snap" "-rR"
53 }
54
55 log_assert "'zfs promote' can promote a volume clone."
56 log_onexit cleanup
57
58 vol=$TESTPOOL/$TESTVOL
59 snap=$vol@$TESTSNAP
60 clone=$TESTPOOL/volclone
61 csnap=$clone@$TESTSNAP
62
63 if ! snapexists $snap ; then
64         log_must zfs snapshot $snap
65         log_must zfs clone $snap $clone
66 fi
67
68 log_must zfs promote $clone
69
70 # verify the 'promote' operation
71 ! snapexists $csnap && \
72                 log_fail "Snapshot $csnap doesn't exist after zfs promote."
73 snapexists $snap && \
74         log_fail "Snapshot $snap is still there after zfs promote."
75
76 origin_prop=$(get_prop origin $vol)
77 [[ "$origin_prop" != "$csnap" ]] && \
78         log_fail "The dependency of $vol is not correct."
79 origin_prop=$(get_prop origin $clone)
80 [[ "$origin_prop" != "-" ]] && \
81          log_fail "The dependency of $clone is not correct."
82
83 log_pass "'zfs promote' can promote volume clone as expected."
84