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# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/tests/rsend/rsend.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: rsend_011_pos 34# 35# DESCRIPTION: 36# Changes made by 'zfs inherit' can be properly received. 37# 38# STRATEGY: 39# 1. Inherit property for filesystem and volume 40# 2. Send and restore them in the target pool 41# 3. Verify all the datasets can be properly backup and receive 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2007-10-10) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55function cleanup 56{ 57 unmount_all_safe > /dev/null 2>&1 58 log_must cleanup_pool $POOL 59 log_must cleanup_pool $POOL2 60 61 log_must setup_test_model $POOL 62} 63 64log_assert "Verify changes made by 'zfs inherit' can be properly received." 65log_onexit cleanup 66 67# 68# Setting all the $FS properties as local value, 69# 70for prop in $(fs_inherit_prop); do 71 value=$(get_prop $prop $POOL/$FS) 72 log_must $ZFS set $prop=$value $POOL/$FS 73done 74 75# 76# Inherit propertes in sub-datasets 77# 78for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do 79 for prop in $(fs_inherit_prop) ; do 80 $ZFS inherit $prop $ds 81 if (($? !=0 )); then 82 log_fail "$ZFS inherit $prop $ds" 83 fi 84 done 85done 86if is_global_zone ; then 87 for prop in $(vol_inherit_prop) ; do 88 $ZFS inherit $prop $POOL/$FS/vol 89 if (($? !=0 )); then 90 log_fail "$ZFS inherit $prop $POOL/$FS/vol" 91 fi 92 done 93fi 94 95# 96# Verify datasets can be backup and restore correctly 97# Unmount $POOL/$FS to avoid two fs mount in the same mountpoint 98# 99log_must eval "$ZFS send -R $POOL@final > $BACKDIR/pool-R" 100log_must $ZFS unmount -f $POOL/$FS 101log_must eval "$ZFS receive -d -F $POOL2 < $BACKDIR/pool-R" 102 103dstds=$(get_dst_ds $POOL $POOL2) 104# 105# Define all the POOL/POOL2 datasets pair 106# 107set -A pair "$POOL" "$dstds" \ 108 "$POOL/$FS" "$dstds/$FS" \ 109 "$POOL/$FS/fs1" "$dstds/$FS/fs1" \ 110 "$POOL/$FS/fs1/fs2" "$dstds/$FS/fs1/fs2" \ 111 "$POOL/pclone" "$dstds/pclone" \ 112 "$POOL/$FS/fs1/fclone" "$dstds/$FS/fs1/fclone" 113 114if is_global_zone ; then 115 typeset -i n=${#pair[@]} 116 pair[((n))]="$POOL/vol"; pair[((n+1))]="$dstds/vol" 117 pair[((n+2))]="$POOL/$FS/vol" pair[((n+3))]="$dstds/$FS/vol" 118fi 119 120# 121# Verify all the sub-datasets can be properly received. 122# 123log_must cmp_ds_subs $POOL $dstds 124typeset -i i=0 125while ((i < ${#pair[@]})); do 126 log_must cmp_ds_cont ${pair[$i]} ${pair[((i+1))]} 127 log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} 128 129 ((i += 2)) 130done 131 132log_pass "Changes made by 'zfs inherit' can be properly received." 133