12fae26bdSAlan Somers#!/usr/local/bin/ksh93 -p 22fae26bdSAlan Somers# 32fae26bdSAlan Somers# CDDL HEADER START 42fae26bdSAlan Somers# 52fae26bdSAlan Somers# The contents of this file are subject to the terms of the 62fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 72fae26bdSAlan Somers# You may not use this file except in compliance with the License. 82fae26bdSAlan Somers# 92fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 112fae26bdSAlan Somers# See the License for the specific language governing permissions 122fae26bdSAlan Somers# and limitations under the License. 132fae26bdSAlan Somers# 142fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 152fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 172fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 182fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 192fae26bdSAlan Somers# 202fae26bdSAlan Somers# CDDL HEADER END 212fae26bdSAlan Somers# 222fae26bdSAlan Somers 232fae26bdSAlan Somers# 242fae26bdSAlan Somers# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 252fae26bdSAlan Somers# Use is subject to license terms. 262fae26bdSAlan Somers 272fae26bdSAlan Somers. $STF_SUITE/tests/rsend/rsend.kshlib 282fae26bdSAlan Somers 292fae26bdSAlan Somers################################################################################# 302fae26bdSAlan Somers# 312fae26bdSAlan Somers# __stc_assertion_start 322fae26bdSAlan Somers# 332fae26bdSAlan Somers# ID: rsend_008_pos 342fae26bdSAlan Somers# 352fae26bdSAlan Somers# DESCRIPTION: 362fae26bdSAlan Somers# Changes made by 'zfs promote' can be properly received. 372fae26bdSAlan Somers# 382fae26bdSAlan Somers# STRATEGY: 392fae26bdSAlan Somers# 1. Separately promote pool clone, filesystem clone and volume clone. 402fae26bdSAlan Somers# 2. Recursively backup all the POOL and restore in POOL2 412fae26bdSAlan Somers# 3. Verify all the datesets and property be properly received. 422fae26bdSAlan Somers# 432fae26bdSAlan Somers# TESTABILITY: explicit 442fae26bdSAlan Somers# 452fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated 462fae26bdSAlan Somers# 472fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2007-08-27) 482fae26bdSAlan Somers# 492fae26bdSAlan Somers# __stc_assertion_end 502fae26bdSAlan Somers# 512fae26bdSAlan Somers################################################################################ 522fae26bdSAlan Somers 532fae26bdSAlan Somersverify_runnable "both" 542fae26bdSAlan Somers 552fae26bdSAlan Somers# Origin Clone 562fae26bdSAlan Somers# 572fae26bdSAlan Somersset -A dtst "$POOL" "$POOL/pclone" \ 582fae26bdSAlan Somers "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" 592fae26bdSAlan Somersif is_global_zone ; then 602fae26bdSAlan Somers typeset -i n=${#dtst[@]} 612fae26bdSAlan Somers dtst[((n))]="$POOL/$FS/vol"; dtst[((n+1))]="$POOL/$FS/vclone" 622fae26bdSAlan Somersfi 632fae26bdSAlan Somers 642fae26bdSAlan Somersfunction cleanup 652fae26bdSAlan Somers{ 662fae26bdSAlan Somers typeset origin 672fae26bdSAlan Somers typeset -i i=0 682fae26bdSAlan Somers while ((i < ${#dtst[@]})); do 692fae26bdSAlan Somers origin=$(get_prop origin ${dtst[$i]}) 702fae26bdSAlan Somers 712fae26bdSAlan Somers if [[ $origin != "-" ]]; then 722fae26bdSAlan Somers log_must $ZFS promote ${dtst[$i]} 732fae26bdSAlan Somers fi 742fae26bdSAlan Somers 752fae26bdSAlan Somers ((i += 2)) 762fae26bdSAlan Somers done 772fae26bdSAlan Somers 782fae26bdSAlan Somers origin=$(get_prop origin $POOL2) 792fae26bdSAlan Somers if [[ $origin != "-" ]]; then 802fae26bdSAlan Somers log_must $ZFS promote $POOL2 812fae26bdSAlan Somers fi 822fae26bdSAlan Somers log_must cleanup_pool $POOL2 832fae26bdSAlan Somers} 842fae26bdSAlan Somers 852fae26bdSAlan Somerslog_assert "Changes made by 'zfs promote' can be properly received." 862fae26bdSAlan Somerslog_onexit cleanup 872fae26bdSAlan Somers 882fae26bdSAlan Somerstypeset -i i=0 892fae26bdSAlan Somerswhile ((i < ${#dtst[@]})); do 902fae26bdSAlan Somers log_must $ZFS promote ${dtst[((i+1))]} 912fae26bdSAlan Somers 922fae26bdSAlan Somers ((i += 2)) 932fae26bdSAlan Somersdone 942fae26bdSAlan Somers 952fae26bdSAlan Somers# 962fae26bdSAlan Somers# Verify zfs send -R should succeed 972fae26bdSAlan Somers# 982fae26bdSAlan Somerslog_must eval "$ZFS send -R $POOL@final > $BACKDIR/pool-final-R" 992fae26bdSAlan Somerslog_must eval "$ZFS receive -d -F $POOL2 < $BACKDIR/pool-final-R" 1002fae26bdSAlan Somers 1012fae26bdSAlan Somersdstds=$(get_dst_ds $POOL $POOL2) 1022fae26bdSAlan Somers# 1032fae26bdSAlan Somers# Define all the POOL/POOL2 datasets pair 1042fae26bdSAlan Somers# 1052fae26bdSAlan Somersset -A pair "$POOL" "$dstds" \ 1062fae26bdSAlan Somers "$POOL/$FS" "$dstds/$FS" \ 1072fae26bdSAlan Somers "$POOL/$FS/fs1" "$dstds/$FS/fs1" \ 1082fae26bdSAlan Somers "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \ 1092fae26bdSAlan Somers "$POOL/pclone" "$dstds/pclone" \ 1102fae26bdSAlan Somers "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone" 1112fae26bdSAlan Somers 1122fae26bdSAlan Somersif is_global_zone ; then 1132fae26bdSAlan Somers typeset -i n=${#pair[@]} 1142fae26bdSAlan Somers pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol" 1152fae26bdSAlan Somers pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol" 1162fae26bdSAlan Somersfi 1172fae26bdSAlan Somers 1182fae26bdSAlan Somers# 1192fae26bdSAlan Somers# Verify all the sub-datasets can be properly received. 1202fae26bdSAlan Somers# 1212fae26bdSAlan Somerslog_must cmp_ds_subs $POOL $dstds 1222fae26bdSAlan Somerstypeset -i i=0 1232fae26bdSAlan Somerswhile ((i < ${#pair[@]})); do 1242fae26bdSAlan Somers log_must cmp_ds_cont ${pair[$i]} ${pair[((i+1))]} 1252fae26bdSAlan Somers log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} 1262fae26bdSAlan Somers 1272fae26bdSAlan Somers ((i += 2)) 1282fae26bdSAlan Somersdone 1292fae26bdSAlan Somers 1302fae26bdSAlan Somers# Verify the original filesystem can be promoted 1312fae26bdSAlan Somerslog_must $ZFS promote $dstds 1322fae26bdSAlan Somersif is_global_zone ; then 1332fae26bdSAlan Somers log_must $ZFS promote $dstds/$FS/vol 1342fae26bdSAlan Somersfi 1352fae26bdSAlan Somerslog_must $ZFS promote $dstds/$FS/fs1/fs2 1362fae26bdSAlan Somers 1372fae26bdSAlan Somerslog_pass "Changes made by 'zfs promote' can be properly received." 138