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) 2015, Delphix. All rights reserved.
18 . $STF_SUITE/tests/functional/rsend/rsend.kshlib
19 . $STF_SUITE/include/properties.shlib
23 # Verify the stream size estimate given by -P accounts for compressed send.
24 # Verify the stream size given by -P accounts for compressed send."
27 # 1. For datasets of varied compression types do the following:
28 # 2. Write data, verify stream size estimates with and without -c
31 verify_runnable "both"
32 typeset send_ds="$POOL2/testfs"
33 typeset send_vol="$POOL2/vol"
34 typeset send_voldev="$ZVOL_DEVDIR/$POOL2/vol"
35 typeset file="$BACKDIR/file.0"
39 function get_estimated_size
45 typeset tmpfile=$(TMPDIR=$BACKDIR mktemp)
47 typeset tmpfile=$(mktemp -p $BACKDIR)
51 [[ $? -eq 0 ]] || log_fail "get_estimated_size: $cmd"
52 typeset size=$(eval "awk '\$2 == \"$ds\" {print \$3}' $tmpfile")
58 log_assert "Verify the stream size given by -P accounts for compressed send."
59 log_onexit cleanup_pool $POOL2
61 write_compressible $BACKDIR ${megs}m
63 for compress in "${compress_prop_vals[@]}"; do
64 datasetexists $send_ds && log_must_busy zfs destroy -r $send_ds
65 datasetexists $send_vol && log_must_busy zfs destroy -r $send_vol
66 log_must zfs create -o compress=$compress $send_ds
67 log_must zfs create -V 1g -o compress=$compress $send_vol
68 block_device_wait $send_voldev
70 typeset dir=$(get_prop mountpoint $send_ds)
71 log_must cp $file $dir
72 log_must zfs snapshot $send_ds@snap
73 log_must dd if=$file of=$send_voldev
74 log_must zfs snapshot $send_vol@snap
76 typeset ds_size=$(get_estimated_size "zfs send -nP $send_ds@snap")
77 typeset ds_lrefer=$(get_prop lrefer $send_ds)
78 within_percent $ds_size $ds_lrefer 90 || log_fail \
79 "$ds_size and $ds_lrefer differed by too much"
81 typeset vol_size=$(get_estimated_size "zfs send -nP $send_vol@snap")
82 typeset vol_lrefer=$(get_prop lrefer $send_vol)
83 within_percent $vol_size $vol_lrefer 90 || log_fail \
84 "$vol_size and $vol_lrefer differed by too much"
86 typeset ds_csize=$(get_estimated_size "zfs send -nP -c $send_ds@snap")
87 typeset ds_refer=$(get_prop refer $send_ds)
88 within_percent $ds_csize $ds_refer 90 || log_fail \
89 "$ds_csize and $ds_refer differed by too much"
91 typeset vol_csize=$(get_estimated_size "zfs send -nP -c $send_vol@snap")
92 typeset vol_refer=$(get_prop refer $send_vol)
93 within_percent $vol_csize $vol_refer 90 || log_fail \
94 "$vol_csize and $vol_refer differed by too much"
97 log_pass "The stream size given by -P accounts for compressed send."