4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version a.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2019 Datto Inc.
16 # Copyright (c) 2020 by Delphix. All rights reserved.
19 . $STF_SUITE/include/libtest.shlib
20 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
24 # Verify that a partially received dataset can be sent with
28 # 1. Setup a pool with partially received filesystem
29 # 2. Perform saved send without incremental
30 # 3. Perform saved send with incremental
31 # 4. Perform saved send with incremental, resuming from a token
32 # 5. Perform negative tests for invalid command inputs
35 verify_runnable "both"
37 log_assert "Verify that a partially received dataset can be sent with " \
42 destroy_dataset $POOL/testfs2 "-r"
43 destroy_dataset $POOL/stream "-r"
44 destroy_dataset $POOL/recvfs "-r"
45 destroy_dataset $POOL/partialfs "-r"
49 log_must zfs create $POOL/testfs2
50 log_must zfs create $POOL/stream
51 mntpnt=$(get_prop mountpoint $POOL/testfs2)
53 # Setup a pool with partially received filesystems
54 log_must mkfile 1m $mntpnt/filea
55 log_must zfs snap $POOL/testfs2@a
56 log_must mkfile 1m $mntpnt/fileb
57 log_must zfs snap $POOL/testfs2@b
58 log_must eval "zfs send $POOL/testfs2@a | zfs recv $POOL/recvfs"
59 log_must eval "zfs send -i $POOL/testfs2@a $POOL/testfs2@b > " \
60 "/$POOL/stream/inc.send"
61 log_must eval "zfs send $POOL/testfs2@b > /$POOL/stream/full.send"
62 mess_send_file /$POOL/stream/full.send
63 mess_send_file /$POOL/stream/inc.send
64 log_mustnot zfs recv -s $POOL/recvfullfs < /$POOL/stream/full.send
65 log_mustnot zfs recv -s $POOL/recvfs < /$POOL/stream/inc.send
67 # Perform saved send without incremental
68 log_mustnot eval "zfs send --saved $POOL/recvfullfs | zfs recv -s " \
70 token=$(zfs get -Hp -o value receive_resume_token $POOL/partialfs)
71 log_must eval "zfs send -t $token | zfs recv -s $POOL/partialfs"
72 file_check $POOL/recvfullfs $POOL/partialfs
73 log_must zfs destroy -r $POOL/partialfs
75 # Perform saved send with incremental
76 log_must eval "zfs send $POOL/recvfs@a | zfs recv $POOL/partialfs"
77 log_mustnot eval "zfs send --saved $POOL/recvfs | " \
78 "zfs recv -s $POOL/partialfs"
79 token=$(zfs get -Hp -o value receive_resume_token $POOL/partialfs)
80 log_must eval "zfs send -t $token | zfs recv -s $POOL/partialfs"
81 file_check $POOL/recvfs $POOL/partialfs
82 log_must zfs destroy -r $POOL/partialfs
84 # Perform saved send with incremental, resuming from token
85 log_must eval "zfs send $POOL/recvfs@a | zfs recv $POOL/partialfs"
86 log_must eval "zfs send --saved $POOL/recvfs > " \
87 "/$POOL/stream/partial.send"
88 mess_send_file /$POOL/stream/partial.send
89 log_mustnot zfs recv -s $POOL/partialfs < /$POOL/stream/partial.send
90 token=$(zfs get -Hp -o value receive_resume_token $POOL/partialfs)
91 log_must eval "zfs send -t $token | zfs recv -s $POOL/partialfs"
92 file_check $POOL/recvfs $POOL/partialfs
94 # Perform negative tests for invalid command inputs
98 "-i $POOL/recvfs@a $POOL/recvfs@b" \
104 while (( i < ${#badargs[*]} ))
106 log_mustnot eval "zfs send --saved ${badargs[i]} >/dev/null"
110 log_pass "A partially received dataset can be sent with 'zfs send --saved'."