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
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) 2018 by Delphix. All rights reserved.
18 . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
22 # Verify that redacted send works on volumes.
25 # 1. Write to a volume, then make a clone of that volume.
26 # 2. Receive a redacted stream that sends all blocks.
27 # 3. Receive a redacted stream that redacts the first half of the written area.
30 typeset ds_name="volume"
31 typeset sendvol="$POOL/$ds_name"
32 typeset recvvol="$POOL2/$ds_name"
33 typeset clone="$POOL/${ds_name}_clone"
34 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
35 typeset stream=$(mktemp $tmpdir/stream.XXXX)
36 typeset send_file="/dev/zvol/$sendvol"
37 typeset recv_file="/dev/zvol/$recvvol"
38 typeset clone_file="/dev/zvol/$clone"
40 log_onexit redacted_cleanup $sendvol $recvvol
42 log_must zfs create -b 8k -V 1g $sendvol
44 log_must zpool export $POOL
45 log_must zpool import $POOL
47 if ! is_disk_device $send_file; then
49 for t in 10 5 3 2 1; do
50 log_note "Polling $t seconds for device file."
53 is_disk_device $send_file && break
56 log_must dd if=/dev/urandom of=$send_file bs=8k count=64
57 log_must zfs snapshot $sendvol@snap
58 log_must zfs clone $sendvol@snap $clone
59 log_must zfs snapshot $clone@snap
61 log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 1
62 log_must zfs redact $sendvol@snap book1 $clone@snap
63 log_must eval "zfs send --redact book1 $sendvol@snap >$stream"
64 log_must eval "zfs recv $recvvol <$stream"
66 log_must zpool export $POOL2
67 log_must zpool import $POOL2
69 if ! is_disk_device $recv_file; then
71 for t in 10 5 3 2 1; do
72 log_note "Polling $t seconds for device file."
75 is_disk_device $recv_file && break
78 log_must dd if=$send_file of=$tmpdir/send.dd bs=8k count=64
79 log_must dd if=$recv_file of=$tmpdir/recv.dd bs=8k count=64
80 log_must diff $tmpdir/send.dd $tmpdir/recv.dd
81 log_must zfs destroy -R $recvvol
83 log_must dd if=/dev/urandom of=$clone_file bs=8k count=32
84 log_must zfs snapshot $clone@snap1
85 log_must zfs redact $sendvol@snap book2 $clone@snap1
86 log_must eval "zfs send --redact book2 $sendvol@snap >$stream"
87 log_must eval "zfs recv $recvvol <$stream"
89 log_must zpool export $POOL2
90 log_must zpool import $POOL2
92 if ! is_disk_device $recv_file; then
94 for t in 10 5 3 2 1; do
95 log_note "Polling $t seconds for device file."
98 is_disk_device $recv_file && break
101 log_must dd if=$send_file of=$tmpdir/send.dd bs=8k count=32 skip=32
102 log_must dd if=$recv_file of=$tmpdir/recv.dd bs=8k count=32 skip=32
103 log_must diff $tmpdir/send.dd $tmpdir/recv.dd
105 log_pass "Redacted send works correctly with volumes."