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 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)rsend_008_pos.ksh 1.2 09/01/12 SMI" 30# 31 32. $STF_SUITE/tests/rsend/rsend.kshlib 33 34################################################################################# 35# 36# __stc_assertion_start 37# 38# ID: rsend_008_pos 39# 40# DESCRIPTION: 41# Changes made by 'zfs promote' can be properly received. 42# 43# STRATEGY: 44# 1. Separately promote pool clone, filesystem clone and volume clone. 45# 2. Recursively backup all the POOL and restore in POOL2 46# 3. Verify all the datesets and property be properly received. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2007-08-27) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60# Origin Clone 61# 62set -A dtst "$POOL" "$POOL/pclone" \ 63 "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" 64if is_global_zone ; then 65 typeset -i n=${#dtst[@]} 66 dtst[((n))]="$POOL/$FS/vol"; dtst[((n+1))]="$POOL/$FS/vclone" 67fi 68 69function cleanup 70{ 71 typeset origin 72 typeset -i i=0 73 while ((i < ${#dtst[@]})); do 74 origin=$(get_prop origin ${dtst[$i]}) 75 76 if [[ $origin != "-" ]]; then 77 log_must $ZFS promote ${dtst[$i]} 78 fi 79 80 ((i += 2)) 81 done 82 83 origin=$(get_prop origin $POOL2) 84 if [[ $origin != "-" ]]; then 85 log_must $ZFS promote $POOL2 86 fi 87 log_must cleanup_pool $POOL2 88} 89 90log_assert "Changes made by 'zfs promote' can be properly received." 91log_onexit cleanup 92 93typeset -i i=0 94while ((i < ${#dtst[@]})); do 95 log_must $ZFS promote ${dtst[((i+1))]} 96 97 ((i += 2)) 98done 99 100# 101# Verify zfs send -R should succeed 102# 103log_must eval "$ZFS send -R $POOL@final > $BACKDIR/pool-final-R" 104log_must eval "$ZFS receive -d -F $POOL2 < $BACKDIR/pool-final-R" 105 106dstds=$(get_dst_ds $POOL $POOL2) 107# 108# Define all the POOL/POOL2 datasets pair 109# 110set -A pair "$POOL" "$dstds" \ 111 "$POOL/$FS" "$dstds/$FS" \ 112 "$POOL/$FS/fs1" "$dstds/$FS/fs1" \ 113 "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \ 114 "$POOL/pclone" "$dstds/pclone" \ 115 "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone" 116 117if is_global_zone ; then 118 typeset -i n=${#pair[@]} 119 pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol" 120 pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol" 121fi 122 123# 124# Verify all the sub-datasets can be properly received. 125# 126log_must cmp_ds_subs $POOL $dstds 127typeset -i i=0 128while ((i < ${#pair[@]})); do 129 log_must cmp_ds_cont ${pair[$i]} ${pair[((i+1))]} 130 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} 131 132 ((i += 2)) 133done 134 135# Verify the original filesystem can be promoted 136log_must $ZFS promote $dstds 137if is_global_zone ; then 138 log_must $ZFS promote $dstds/$FS/vol 139fi 140log_must $ZFS promote $dstds/$FS/fs1/fs2 141 142log_pass "Changes made by 'zfs promote' can be properly received." 143