]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh
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) 2017 Datto, Inc. All rights reserved.
21 .
$STF_SUITE/include
/libtest.shlib
25 # ZFS should receive streams from raw sends.
28 # 1. Create an encrypted dataset
29 # 2. Create a file and get its checksum
30 # 3. Snapshot the dataset
31 # 4. Attempt to receive a raw send stream as a child of an unencrypted dataset
32 # 5. Verify the key is unavailable
33 # 6. Attempt to load the key and mount the dataset
34 # 7. Verify the cheksum of the file is the same as the original
35 # 8. Attempt to receive a raw send stream as a child of an encrypted dataset
36 # 9. Verify the key is unavailable
37 # 10. Attempt to load the key and mount the dataset
38 # 11. Verify the cheksum of the file is the same as the original
41 verify_runnable
"both"
45 datasetexists
$TESTPOOL/$TESTFS1 && \
46 log_must zfs destroy
-r $TESTPOOL/$TESTFS1
48 datasetexists
$TESTPOOL/$TESTFS2 && \
49 log_must zfs destroy
-r $TESTPOOL/$TESTFS2
54 log_assert
"ZFS should receive streams from raw sends"
56 typeset passphrase
="password"
57 typeset snap
="$TESTPOOL/$TESTFS1@snap"
59 log_must
eval "echo $passphrase | zfs create -o encryption=on" \
60 "-o keyformat=passphrase $TESTPOOL/$TESTFS1"
62 log_must mkfile
1M
/$TESTPOOL/$TESTFS1/$TESTFILE0
63 typeset checksum
=$
(md5sum /$TESTPOOL/$TESTFS1/$TESTFILE0 | \
66 log_must zfs snapshot
$snap
68 log_note
"Verify ZFS can receive a raw send stream from an encrypted dataset"
69 log_must
eval "zfs send -w $snap | zfs receive $TESTPOOL/$TESTFS2"
71 keystatus
=$
(get_prop keystatus
$TESTPOOL/$TESTFS2)
72 [[ "$keystatus" == "unavailable" ]] || \
73 log_fail
"Expected keystatus unavailable, got $keystatus"
75 log_must
eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS2"
77 typeset cksum1
=$
(md5sum /$TESTPOOL/$TESTFS2/$TESTFILE0 |
awk '{ print $1 }')
78 [[ "$cksum1" == "$checksum" ]] || \
79 log_fail
"Checksums differ ($cksum1 != $checksum)"
81 log_must
eval "zfs send -w $snap | zfs receive $TESTPOOL/$TESTFS1/c1"
83 keystatus
=$
(get_prop keystatus
$TESTPOOL/$TESTFS1/c1
)
84 [[ "$keystatus" == "unavailable" ]] || \
85 log_fail
"Expected keystatus unavailable, got $keystatus"
87 log_must
eval "echo $passphrase | zfs mount -l $TESTPOOL/$TESTFS1/c1"
88 typeset cksum2
=$
(md5sum /$TESTPOOL/$TESTFS1/c
1/$TESTFILE0 | \
90 [[ "$cksum2" == "$checksum" ]] || \
91 log_fail
"Checksums differ ($cksum2 != $checksum)"
93 log_pass
"ZFS can receive streams from raw sends"