1#!/usr/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) 2015 by Delphix. All rights reserved. 16# 17 18. $STF_SUITE/tests/functional/rsend/rsend.kshlib 19 20# 21# Description: 22# Verify the stream size estimate given by -P accounts for compressed send. 23# Verify the stream size given by -P accounts for compressed send." 24# 25# Strategy: 26# 1. For datasets of varied compression types do the following: 27# 2. Write data, verify stream size estimates with and without -c 28# 29 30verify_runnable "both" 31typeset compress_types="off gzip lz4" 32typeset send_ds="$POOL2/testfs" 33typeset send_vol="$POOL2/vol" 34typeset send_voldev="/dev/zvol/rdsk/$POOL2/vol" 35typeset file="$BACKDIR/file.0" 36typeset megs="16" 37typeset compress 38 39function get_estimated_size 40{ 41 typeset cmd=$1 42 typeset ds=${cmd##* } 43 typeset tmpfile=$(mktemp -p $BACKDIR) 44 45 eval "$cmd >$tmpfile" 46 [[ $? -eq 0 ]] || log_fail "get_estimated_size: $cmd" 47 typeset size=$(eval "awk '\$2 == \"$ds\" {print \$3}' $tmpfile") 48 rm -f $tmpfile 49 50 echo $size 51} 52 53log_assert "Verify the stream size given by -P accounts for compressed send." 54log_onexit cleanup_pool $POOL2 55 56write_compressible $BACKDIR ${megs}m 57 58for compress in $compress_types; do 59 datasetexists $send_ds && log_must zfs destroy -r $send_ds 60 datasetexists $send_vol && log_must zfs destroy -r $send_vol 61 log_must zfs create -o compress=$compress $send_ds 62 log_must zfs create -V 1g -o compress=$compress $send_vol 63 64 typeset dir=$(get_prop mountpoint $send_ds) 65 log_must cp $file $dir 66 log_must zfs snapshot $send_ds@snap 67 log_must dd if=$file of=$send_voldev 68 log_must zfs snapshot $send_vol@snap 69 70 typeset ds_size=$(get_estimated_size "zfs send -nP $send_ds@snap") 71 typeset ds_lrefer=$(get_prop lrefer $send_ds) 72 within_percent $ds_size $ds_lrefer 90 || log_fail \ 73 "$ds_size and $ds_lrefer differed by too much" 74 75 typeset vol_size=$(get_estimated_size "zfs send -nP $send_vol@snap") 76 typeset vol_lrefer=$(get_prop lrefer $send_vol) 77 within_percent $vol_size $vol_lrefer 90 || log_fail \ 78 "$vol_size and $vol_lrefer differed by too much" 79 80 typeset ds_csize=$(get_estimated_size "zfs send -nP -c $send_ds@snap") 81 typeset ds_refer=$(get_prop refer $send_ds) 82 within_percent $ds_csize $ds_refer 90 || log_fail \ 83 "$ds_csize and $ds_refer differed by too much" 84 85 typeset vol_csize=$(get_estimated_size "zfs send -nP -c $send_vol@snap") 86 typeset vol_refer=$(get_prop refer $send_vol) 87 within_percent $vol_csize $vol_refer 90 || log_fail \ 88 "$vol_csize and $vol_refer differed by too much" 89done 90 91log_pass "The the stream size given by -P accounts for compressed send." 92