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 send size estimates of redacted sends work correctly
25 # 1. Perform a redacted send with -nv and without, and verify the
26 # size estimate is the same as the size of the actual send.
27 # 2. Receive an incremental send from the redaction bookmark with
28 # -nv and without, and verify the size estimate is the same as
29 # the size of the actual send.
33 typeset sendfs="$POOL/$ds_name"
34 typeset clone="$POOL/${ds_name}_clone2"
35 setup_dataset $ds_name "-o compress=lz4"
36 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
37 typeset size=$(mktemp $tmpdir/size.XXXX)
38 typeset size2=$(mktemp $tmpdir/size.XXXX)
40 log_onexit redacted_cleanup $sendfs $clone
41 log_must zfs clone $sendfs@snap $clone
42 typeset clone_mnt="$(get_prop mountpoint $clone)"
43 log_must rm -rf $clone_mnt/*
44 log_must zfs snapshot $clone@snap
45 log_must zfs redact $sendfs@snap book $clone@snap
46 log_must eval "zfs send -nvP --redact book $sendfs@snap | \
47 grep '^size' | awk '{print \$2}' >$size"
48 log_must eval "zfs send --redact book $sendfs@snap | wc -c \
50 bytes1=$(cat $size | tr -d '[[:space:]]')
51 bytes2=$(cat $size2 | tr -d '[[:space:]]')
52 [[ "$bytes1" -eq "$bytes2" ]] || \
53 log_fail "Full sizes differ: estimate $bytes1 and actual $bytes2"
55 log_must zfs snapshot $sendfs@snap2
56 log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | \
57 grep '^size' | awk '{print \$2}' >$size"
58 log_must eval "zfs send -i $sendfs#book $sendfs@snap2 | wc -c >$size2"
59 bytes1=$(cat $size | tr -d '[[:space:]]')
60 bytes2=$(cat $size2 | tr -d '[[:space:]]')
61 [[ "$bytes1" -eq "$bytes2" ]] || \
62 log_fail "Incremental sizes differ: estimate $bytes1 and actual $bytes2"
64 log_pass "Size estimates of redacted sends estimate accurately."