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 https://opensource.org/licenses/CDDL-1.0. 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 44verify_runnable "global" 45 46function cleanup 47{ 48 if snapexists $csnap; then 49 log_must zfs promote $vol 50 fi 51 52 destroy_dataset "$snap" "-rR" 53} 54 55log_assert "'zfs promote' can promote a volume clone." 56log_onexit cleanup 57 58vol=$TESTPOOL/$TESTVOL 59snap=$vol@$TESTSNAP 60clone=$TESTPOOL/volclone 61csnap=$clone@$TESTSNAP 62 63if ! snapexists $snap ; then 64 log_must zfs snapshot $snap 65 log_must zfs clone $snap $clone 66fi 67 68log_must zfs promote $clone 69 70# verify the 'promote' operation 71! snapexists $csnap && \ 72 log_fail "Snapshot $csnap doesn't exist after zfs promote." 73snapexists $snap && \ 74 log_fail "Snapshot $snap is still there after zfs promote." 75 76origin_prop=$(get_prop origin $vol) 77[[ "$origin_prop" != "$csnap" ]] && \ 78 log_fail "The dependency of $vol is not correct." 79origin_prop=$(get_prop origin $clone) 80[[ "$origin_prop" != "-" ]] && \ 81 log_fail "The dependency of $clone is not correct." 82 83log_pass "'zfs promote' can promote volume clone as expected." 84 85