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 create valid send streams as expected. 38# 39# STRATEGY: 40# 1. Fill in fs with some data 41# 2. Create a full send streams with the fs 42# 3. Receive the send stream and verify the data integrity 43# 4. Fill in fs with some new data 44# 5. Create an incremental send stream with the fs 45# 6. Receive the incremental send stream and verify the data integrity. 46# 47 48verify_runnable "both" 49 50function cleanup 51{ 52 for snap in $init_snap $inc_snap $rst_snap $rst_inc_snap; do 53 snapexists $snap && \ 54 log_must zfs destroy -f $snap 55 done 56 57 datasetexists $rst_root && \ 58 log_must zfs destroy -Rf $rst_root 59 60 for file in $full_bkup $inc_bkup \ 61 $init_data $inc_data 62 do 63 [[ -e $file ]] && \ 64 log_must rm -f $file 65 done 66 67 [[ -d $TESTDIR1 ]] && \ 68 log_must rm -rf $TESTDIR1 69 70} 71 72log_assert "Verify 'zfs send' can create valid send streams as expected." 73log_onexit cleanup 74 75init_snap=$TESTPOOL/$TESTFS@init_snap 76inc_snap=$TESTPOOL/$TESTFS@inc_snap 77full_bkup=/var/tmp/fullbkup.$$ 78inc_bkup=/var/tmp/incbkup.$$ 79init_data=$TESTDIR/$TESTFILE1 80inc_data=$TESTDIR/$TESTFILE2 81orig_sum="" 82rst_sum="" 83rst_root=$TESTPOOL/rst_ctr 84rst_snap=$rst_root/$TESTFS@init_snap 85rst_inc_snap=$rst_root/$TESTFS@inc_snap 86rst_data=$TESTDIR1/$TESTFS/$TESTFILE1 87rst_inc_data=$TESTDIR1/$TESTFS/$TESTFILE2 88 89 90log_note "Verify 'zfs send' can create full send stream." 91 92#Pre-paration 93log_must zfs create $rst_root 94[[ ! -d $TESTDIR1 ]] && \ 95 log_must mkdir -p $TESTDIR1 96log_must zfs set mountpoint=$TESTDIR1 $rst_root 97 98file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT 99 100log_must zfs snapshot $init_snap 101zfs send $init_snap > $full_bkup 102(( $? != 0 )) && \ 103 log_fail "'zfs send' fails to create full send" 104 105log_note "Verify the send stream is valid to receive." 106 107log_must zfs receive $rst_snap <$full_bkup 108receive_check $rst_snap ${rst_snap%%@*} 109compare_cksum $init_data $rst_data 110 111log_note "Verify 'zfs send -i' can create incremental send stream." 112 113file_write -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0 114 115log_must zfs snapshot $inc_snap 116zfs send -i $init_snap $inc_snap > $inc_bkup 117(( $? != 0 )) && \ 118 log_fail "'zfs send -i' fails to create incremental send" 119 120log_note "Verify the incremental send stream is valid to receive." 121 122log_must zfs rollback $rst_snap 123log_must zfs receive $rst_inc_snap <$inc_bkup 124receive_check $rst_inc_snap 125compare_cksum $inc_data $rst_inc_data 126 127log_pass "Verifying 'zfs receive' succeed." 128