]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / redacted_send / redacted_resume.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 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.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) 2018 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
19
20 #
21 # Description:
22 # Verify that resumable send works correctly with redacted streams.
23 #
24 # Strategy:
25 # 1. Do a full redacted resumable send.
26 # 2. Verify the received contents are correct.
27 # 3. Do an incremental redacted resumable send.
28 # 4. Verify the received contents are correct.
29 # 5. Verify that recv -A removes a partially received dataset.
30 #
31
32 typeset ds_name="resume"
33 typeset sendfs="$POOL/$ds_name"
34 typeset recvfs="$POOL2/$ds_name"
35 typeset clone="$POOL/${ds_name}_clone"
36 typeset clone1="$POOL/${ds_name}_clone1"
37 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
38 typeset stream=$(mktemp $tmpdir/stream.XXXX)
39 setup_dataset $ds_name ''
40 typeset clone_mnt="$(get_prop mountpoint $clone)"
41 typeset send_mnt="$(get_prop mountpoint $sendfs)"
42 typeset recv_mnt="/$POOL2/$ds_name"
43
44 log_onexit redacted_cleanup $sendfs $recvfs
45
46 log_must stride_dd -i /dev/urandom -o $clone_mnt/f2 -b 512 -c 64 -s 512
47 log_must zfs snapshot $clone@snap1
48
49 # Do the full resumable send
50 log_must zfs redact $sendfs@snap book1 $clone@snap1
51 resume_test "zfs send --redact book1 $sendfs@snap" $tmpdir $recvfs
52 log_must mount_redacted -f $recvfs
53 log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 1
54 log_must diff $send_mnt/f1 $recv_mnt/f1
55 log_must eval "get_diff $send_mnt/f2 $recv_mnt/f2 >$tmpdir/get_diff.out"
56 typeset range=$(cat $tmpdir/get_diff.out)
57 [[ "$RANGE9" = "$range" ]] || log_fail "Unexpected range: $range"
58
59 log_must dd if=/dev/urandom of=$send_mnt/f3 bs=1024k count=3
60 log_must zfs snapshot $sendfs@snap2
61 log_must zfs clone $sendfs@snap2 $clone1
62 typeset clone1_mnt="$(get_prop mountpoint $clone1)"
63 log_must dd if=/dev/urandom of=$clone1_mnt/f3 bs=128k count=3 conv=notrunc
64 log_must zfs snapshot $clone1@snap
65
66 # Do the incremental resumable send
67 log_must zfs redact $sendfs@snap2 book2 $clone1@snap
68 resume_test "zfs send --redact book2 -i $sendfs#book1 $sendfs@snap2" \
69     $tmpdir $recvfs
70 log_must diff $send_mnt/f1 $recv_mnt/f1
71 log_must diff $send_mnt/f2 $recv_mnt/f2
72 log_must eval "get_diff $send_mnt/f3 $recv_mnt/f3 >$tmpdir/get_diff.out"
73 range=$(cat $tmpdir/get_diff.out)
74 [[ "$RANGE10" = "$range" ]] || log_fail "Unexpected range: $range"
75
76 # Test recv -A works properly and verify saved sends are not allowed
77 log_mustnot zfs recv -A $recvfs
78 log_must zfs destroy -R $recvfs
79 log_mustnot zfs recv -A $recvfs
80 log_must eval "zfs send --redact book1 $sendfs@snap >$stream"
81 dd if=$stream bs=64k count=1 | log_mustnot zfs receive -s $recvfs
82 [[ "-" = $(get_prop receive_resume_token $recvfs) ]] && \
83     log_fail "Receive token not found."
84 log_mustnot eval "zfs send --saved --redact book1 $recvfs > /dev/null"
85 log_must zfs recv -A $recvfs
86 log_must datasetnonexists $recvfs
87
88 log_pass "Resumable send works correctly with redacted streams."