]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/rsend/send_partial_dataset.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / rsend / send_partial_dataset.ksh
1 #!/bin/ksh
2
3 #
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
7 # a.0 of the CDDL.
8 #
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.
12 #
13
14 #
15 # Copyright (c) 2019 Datto Inc.
16 # Copyright (c) 2020 by Delphix. All rights reserved.
17 #
18
19 . $STF_SUITE/include/libtest.shlib
20 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
21
22 #
23 # Description:
24 # Verify that a partially received dataset can be sent with
25 # 'zfs send --saved'.
26 #
27 # Strategy:
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
33 #
34
35 verify_runnable "both"
36
37 log_assert "Verify that a partially received dataset can be sent with " \
38         "'zfs send --saved'."
39
40 function cleanup
41 {
42         destroy_dataset $POOL/testfs2 "-r"
43         destroy_dataset $POOL/stream "-r"
44         destroy_dataset $POOL/recvfs "-r"
45         destroy_dataset $POOL/partialfs "-r"
46 }
47 log_onexit cleanup
48
49 log_must zfs create $POOL/testfs2
50 log_must zfs create $POOL/stream
51 mntpnt=$(get_prop mountpoint $POOL/testfs2)
52
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
66
67 # Perform saved send without incremental
68 log_mustnot eval "zfs send --saved $POOL/recvfullfs | zfs recv -s " \
69         "$POOL/partialfs"
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
74
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
83
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
93
94 # Perform negative tests for invalid command inputs
95 set -A badargs \
96         "" \
97         "$POOL/recvfs@a" \
98         "-i $POOL/recvfs@a $POOL/recvfs@b" \
99         "-R $POOL/recvfs" \
100         "-p $POOL/recvfs" \
101         "-I $POOL/recvfs" \
102         "-h $POOL/recvfs"
103
104 while (( i < ${#badargs[*]} ))
105 do
106         log_mustnot eval "zfs send --saved ${badargs[i]} >/dev/null"
107         (( i = i + 1 ))
108 done
109
110 log_pass "A partially received dataset can be sent with 'zfs send --saved'."