1#!/bin/ksh -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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib 33. $STF_SUITE/tests/functional/cli_root/zfs_send/zfs_send.cfg 34 35# 36# DESCRIPTION: 37# Verify 'zfs send' can generate valid streams with a property setup. 38# 39# STRATEGY: 40# 1. Setup property for filesystem 41# 2. Fill in some data into filesystem 42# 3. Create a full send streams 43# 4. Receive the send stream 44# 5. Verify the receive result 45# 46 47verify_runnable "both" 48 49function cleanup 50{ 51 snapexists $snap && destroy_dataset $snap 52 datasetexists $ctr && destroy_dataset $ctr -r 53 54 [[ -e $origfile ]] && \ 55 log_must rm -f $origfile 56 57 [[ -e $stream ]] && \ 58 log_must rm -f $stream 59} 60 61function do_testing # <prop> <prop_value> 62{ 63 typeset property=$1 64 typeset prop_val=$2 65 66 log_must zfs set $property=$prop_val $fs 67 file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT 68 log_must zfs snapshot $snap 69 zfs send $snap > $stream 70 (( $? != 0 )) && \ 71 log_fail "'zfs send' fails to create send streams." 72 zfs receive -d $ctr <$stream 73 (( $? != 0 )) && \ 74 log_fail "'zfs receive' fails to receive send streams." 75 76 #verify receive result 77 ! datasetexists $rstfs && \ 78 log_fail "'zfs receive' fails to restore $rstfs" 79 ! snapexists $rstfssnap && \ 80 log_fail "'zfs receive' fails to restore $rstfssnap" 81 if [[ ! -e $rstfile ]] || [[ ! -e $rstsnapfile ]]; then 82 log_fail " Data lost after receiving stream" 83 fi 84 85 compare_cksum $origfile $rstfile 86 compare_cksum $origsnapfile $rstsnapfile 87 88 #Destroy datasets and stream for next testing 89 log_must zfs destroy $snap 90 if is_global_zone ; then 91 log_must zfs destroy -r $rstfs 92 else 93 log_must zfs destroy -r $ds_path 94 fi 95 log_must rm -f $stream 96} 97 98log_assert "Verify 'zfs send' generates valid streams with a property setup" 99log_onexit cleanup 100 101fs=$TESTPOOL/$TESTFS 102snap=$fs@$TESTSNAP 103ctr=$TESTPOOL/$TESTCTR 104if is_global_zone; then 105 rstfs=$ctr/$TESTFS 106else 107 ds_path=$ctr/${ZONE_CTR}0 108 rstfs=$ds_path/$TESTFS 109fi 110rstfssnap=$rstfs@$TESTSNAP 111snapdir=".zfs/snapshot/$TESTSNAP" 112origfile=$TESTDIR/$TESTFILE1 113rstfile=/$rstfs/$TESTFILE1 114origsnapfile=$TESTDIR/$snapdir/$TESTFILE1 115rstsnapfile=/$rstfs/$snapdir/$TESTFILE1 116stream=$TEST_BASE_DIR/streamfile.$$ 117 118set -A props "compression" "checksum" "recordsize" 119set -A propval "on lzjb" "on fletcher2 fletcher4 sha256" \ 120 "512 1k 4k 8k 16k 32k 64k 128k" 121 122#Create a dataset to receive the send stream 123log_must zfs create $ctr 124 125typeset -i i=0 126while (( i < ${#props[*]} )) 127do 128 for value in ${propval[i]} 129 do 130 do_testing ${props[i]} $value 131 done 132 133 (( i = i + 1 )) 134done 135 136log_pass "'zfs send' generates streams with a property setup as expected." 137