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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_send/zfs_send.cfg
37 # Verify 'zfs send' can create valid send streams as expected.
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.
48 verify_runnable "both"
52 for snap in $init_snap $inc_snap $rst_snap $rst_inc_snap; do
54 log_must zfs destroy -f $snap
57 datasetexists $rst_root && \
58 log_must zfs destroy -Rf $rst_root
60 for file in $full_bkup $inc_bkup \
67 [[ -d $TESTDIR1 ]] && \
68 log_must rm -rf $TESTDIR1
72 log_assert "Verify 'zfs send' can create valid send streams as expected."
75 init_snap=$TESTPOOL/$TESTFS@init_snap
76 inc_snap=$TESTPOOL/$TESTFS@inc_snap
77 full_bkup=$TEST_BASE_DIR/fullbkup.$$
78 inc_bkup=$TEST_BASE_DIR/incbkup.$$
79 init_data=$TESTDIR/$TESTFILE1
80 inc_data=$TESTDIR/$TESTFILE2
83 rst_root=$TESTPOOL/rst_ctr
84 rst_snap=$rst_root/$TESTFS@init_snap
85 rst_inc_snap=$rst_root/$TESTFS@inc_snap
86 rst_data=$TESTDIR1/$TESTFS/$TESTFILE1
87 rst_inc_data=$TESTDIR1/$TESTFS/$TESTFILE2
90 log_note "Verify 'zfs send' can create full send stream."
93 log_must zfs create $rst_root
94 [[ ! -d $TESTDIR1 ]] && \
95 log_must mkdir -p $TESTDIR1
96 log_must zfs set mountpoint=$TESTDIR1 $rst_root
98 file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT
100 log_must zfs snapshot $init_snap
101 zfs send $init_snap > $full_bkup
103 log_fail "'zfs send' fails to create full send"
105 log_note "Verify the send stream is valid to receive."
107 log_must zfs receive $rst_snap <$full_bkup
108 receive_check $rst_snap ${rst_snap%%@*}
109 compare_cksum $init_data $rst_data
111 log_note "Verify 'zfs send -i' can create incremental send stream."
113 file_write -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0
115 log_must zfs snapshot $inc_snap
116 zfs send -i $init_snap $inc_snap > $inc_bkup
118 log_fail "'zfs send -i' fails to create incremental send"
120 log_note "Verify the incremental send stream is valid to receive."
122 log_must zfs rollback $rst_snap
123 log_must zfs receive $rst_inc_snap <$inc_bkup
124 receive_check $rst_inc_snap
125 compare_cksum $inc_data $rst_inc_data
127 log_pass "Verifying 'zfs receive' succeed."