5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2018 by Datto Inc. All rights reserved.
21 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
25 # Verify that a raw zfs send and receive can deal with several different
26 # types of file layouts.
29 # 1. Create a new encrypted filesystem
30 # 2. Add an empty file to the filesystem
31 # 3. Add a small 512 byte file to the filesystem
32 # 4. Add a larger 32M file to the filesystem
33 # 5. Add a large sparse file to the filesystem
34 # 6. Add 1000 empty files to the filesystem
35 # 7. Add a file with a large xattr value
36 # 8. Use xattrtest to create files with random xattrs (with and without xattrs=on)
37 # 9. Take a snapshot of the filesystem
38 # 10. Remove the 1000 empty files to the filesystem
39 # 11. Take another snapshot of the filesystem
40 # 12. Send and receive both snapshots
41 # 13. Mount the filesystem and check the contents
44 verify_runnable "both"
48 datasetexists $TESTPOOL/$TESTFS2 && \
49 log_must zfs destroy -r $TESTPOOL/$TESTFS2
50 datasetexists $TESTPOOL/recv && \
51 log_must zfs destroy -r $TESTPOOL/recv
52 [[ -f $keyfile ]] && log_must rm $keyfile
53 [[ -f $sendfile ]] && log_must rm $sendfile
57 log_assert "Verify 'zfs send -w' works with many different file layouts"
59 typeset keyfile=/$TESTPOOL/pkey
60 typeset sendfile=/$TESTPOOL/sendfile
61 typeset sendfile2=/$TESTPOOL/sendfile2
63 # Create an encrypted dataset
64 log_must eval "echo 'password' > $keyfile"
65 log_must zfs create -o encryption=on -o keyformat=passphrase \
66 -o keylocation=file://$keyfile $TESTPOOL/$TESTFS2
68 # Create files with varied layouts on disk
69 log_must touch /$TESTPOOL/$TESTFS2/empty
70 log_must mkfile 512 /$TESTPOOL/$TESTFS2/small
71 log_must mkfile 32M /$TESTPOOL/$TESTFS2/full
72 log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS2/sparse \
73 bs=512 count=1 seek=1048576 >/dev/null 2>&1
75 log_must mkdir -p /$TESTPOOL/$TESTFS2/dir
76 for i in {1..1000}; do
77 log_must mkfile 512 /$TESTPOOL/$TESTFS2/dir/file-$i
80 log_must mkdir -p /$TESTPOOL/$TESTFS2/xattrondir
81 log_must zfs set xattr=on $TESTPOOL/$TESTFS2
82 log_must xattrtest -f 10 -x 3 -s 32768 -r -k -p /$TESTPOOL/$TESTFS2/xattrondir
83 log_must mkdir -p /$TESTPOOL/$TESTFS2/xattrsadir
84 log_must zfs set xattr=sa $TESTPOOL/$TESTFS2
85 log_must xattrtest -f 10 -x 3 -s 32768 -r -k -p /$TESTPOOL/$TESTFS2/xattrsadir
88 log_must zfs set compression=on xattr=sa $TESTPOOL/$TESTFS2
89 log_must touch /$TESTPOOL/$TESTFS2/attrs
90 log_must eval "python -c 'print \"a\" * 4096' | \
91 set_xattr_stdin bigval /$TESTPOOL/$TESTFS2/attrs"
92 log_must zfs set compression=off xattr=on $TESTPOOL/$TESTFS2
94 log_must zfs snapshot $TESTPOOL/$TESTFS2@snap1
96 # Remove the empty files created in the first snapshot
97 for i in {1..1000}; do
98 log_must rm /$TESTPOOL/$TESTFS2/dir/file-$i
102 log_must zfs snapshot $TESTPOOL/$TESTFS2@snap2
103 expected_cksum=$(recursive_cksum /$TESTPOOL/$TESTFS2)
105 log_must eval "zfs send -wp $TESTPOOL/$TESTFS2@snap1 > $sendfile"
106 log_must eval "zfs send -wp -i @snap1 $TESTPOOL/$TESTFS2@snap2 > $sendfile2"
108 log_must eval "zfs recv -F $TESTPOOL/recv < $sendfile"
109 log_must eval "zfs recv -F $TESTPOOL/recv < $sendfile2"
110 log_must zfs load-key $TESTPOOL/recv
112 log_must zfs mount -a
113 actual_cksum=$(recursive_cksum /$TESTPOOL/recv)
114 [[ "$expected_cksum" != "$actual_cksum" ]] && \
115 log_fail "Recursive checksums differ ($expected_cksum != $actual_cksum)"
117 log_must xattrtest -f 10 -o3 -y -p /$TESTPOOL/recv/xattrondir
118 log_must xattrtest -f 10 -o3 -y -p /$TESTPOOL/recv/xattrsadir
120 log_pass "Verified 'zfs send -w' works with many different file layouts"