]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/rsend/send_encrypted_files.ksh
be9d33be9a7f91ad5bfa532a45ecd8bec0fdf4c8
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
28 # 1. Create a new encrypted filesystem
29 # 2. Add an empty file to the filesystem
30 # 3. Add a small 512 byte file to the filesystem
31 # 4. Add a larger 32M file to the filesystem
32 # 5. Add a large sparse file to the filesystem
33 # 6. Add a 3 files that are to be truncated later
34 # 7. Add 1000 empty files to the filesystem
35 # 8. Add a file with a large xattr value
36 # 9. Use xattrtest to create files with random xattrs (with and without xattrs=on)
37 # 10. Take a snapshot of the filesystem
38 # 11. Truncate one of the files from 32M to 128k
39 # 12. Truncate one of the files from 512k to 384k
40 # 13. Truncate one of the files from 512k to 0 to 384k
41 # 14. Remove the 1000 empty files to the filesystem
42 # 15. Take another snapshot of the filesystem
43 # 16. Send and receive both snapshots
44 # 17. Mount the filesystem and check the contents
47 verify_runnable
"both"
51 datasetexists
$TESTPOOL/$TESTFS2 && \
52 log_must zfs destroy
-r $TESTPOOL/$TESTFS2
53 datasetexists
$TESTPOOL/recv
&& \
54 log_must zfs destroy
-r $TESTPOOL/recv
55 [[ -f $keyfile ]] && log_must
rm $keyfile
56 [[ -f $sendfile ]] && log_must
rm $sendfile
60 log_assert
"Verify 'zfs send -w' works with many different file layouts"
62 typeset keyfile
=/$TESTPOOL/pkey
63 typeset sendfile
=/$TESTPOOL/sendfile
64 typeset sendfile2
=/$TESTPOOL/sendfile2
66 # Create an encrypted dataset
67 log_must
eval "echo 'password' > $keyfile"
68 log_must zfs create
-o encryption
=on
-o keyformat
=passphrase \
69 -o keylocation
=file://$keyfile $TESTPOOL/$TESTFS2
71 # Create files with vaired layouts on disk
72 log_must
touch /$TESTPOOL/$TESTFS2/empty
73 log_must mkfile
512 /$TESTPOOL/$TESTFS2/small
74 log_must mkfile
32M
/$TESTPOOL/$TESTFS2/full
75 log_must
dd if=/dev
/urandom of
=/$TESTPOOL/$TESTFS2/sparse \
76 bs
=512 count
=1 seek
=1048576 >/dev
/null
2>&1
77 log_must mkfile
32M
/$TESTPOOL/$TESTFS2/truncated
78 log_must mkfile
524288 /$TESTPOOL/$TESTFS2/truncated2
79 log_must mkfile
524288 /$TESTPOOL/$TESTFS2/truncated3
81 log_must mkdir
-p /$TESTPOOL/$TESTFS2/dir
82 for i
in {1.
.1000}; do
83 log_must mkfile
512 /$TESTPOOL/$TESTFS2/dir
/file-
$i
86 log_must mkdir
-p /$TESTPOOL/$TESTFS2/xattrondir
87 log_must zfs
set xattr
=on
$TESTPOOL/$TESTFS2
88 log_must xattrtest
-f 10 -x 3 -s 32768 -r -k -p /$TESTPOOL/$TESTFS2/xattrondir
89 log_must mkdir
-p /$TESTPOOL/$TESTFS2/xattrsadir
90 log_must zfs
set xattr
=sa
$TESTPOOL/$TESTFS2
91 log_must xattrtest
-f 10 -x 3 -s 32768 -r -k -p /$TESTPOOL/$TESTFS2/xattrsadir
94 log_must zfs
set compression
=on xattr
=sa
$TESTPOOL/$TESTFS2
95 log_must
touch /$TESTPOOL/$TESTFS2/attrs
96 log_must
eval "python -c 'print \"a\" * 4096' | \
97 attr -s bigval /$TESTPOOL/$TESTFS2/attrs"
99 log_must zfs snapshot
$TESTPOOL/$TESTFS2@snap1
102 # Truncate files created in the first snapshot. The first tests
103 # truncating a large file to a single block. The second tests
104 # truncating one block off the end of a file without changing
105 # the required nlevels to hold it. The last tests handling
106 # of a maxblkid that is dropped and then raised again.
108 log_must truncate
-s 131072 /$TESTPOOL/$TESTFS2/truncated
109 log_must truncate
-s 393216 /$TESTPOOL/$TESTFS2/truncated2
110 log_must truncate
-s 0 /$TESTPOOL/$TESTFS2/truncated3
111 log_must zpool sync
$TESTPOOL
112 log_must
dd if=/dev
/urandom of
=/$TESTPOOL/$TESTFS2/truncated3 \
113 bs
=128k count
=3 iflag
=fullblock
115 # Remove the empty files created in the first snapshot
116 for i
in {1.
.1000}; do
117 log_must
rm /$TESTPOOL/$TESTFS2/dir
/file-
$i
121 log_must zfs snapshot
$TESTPOOL/$TESTFS2@snap2
122 expected_cksum
=$
(recursive_cksum
/$TESTPOOL/$TESTFS2)
124 log_must
eval "zfs send -wp $TESTPOOL/$TESTFS2@snap1 > $sendfile"
125 log_must
eval "zfs send -wp -i @snap1 $TESTPOOL/$TESTFS2@snap2 > $sendfile2"
127 log_must
eval "zfs recv -F $TESTPOOL/recv < $sendfile"
128 log_must
eval "zfs recv -F $TESTPOOL/recv < $sendfile2"
129 log_must zfs load-key
$TESTPOOL/recv
131 log_must zfs mount
-a
132 actual_cksum
=$
(recursive_cksum
/$TESTPOOL/recv
)
133 [[ "$expected_cksum" != "$actual_cksum" ]] && \
134 log_fail
"Recursive checksums differ ($expected_cksum != $actual_cksum)"
136 log_must xattrtest
-f 10 -o3 -y -p /$TESTPOOL/recv
/xattrondir
137 log_must xattrtest
-f 10 -o3 -y -p /$TESTPOOL/recv
/xattrsadir
139 log_pass
"Verified 'zfs send -w' works with many different file layouts"