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. $STF_SUITE/include/properties.shlib 20 21# 22# Description: 23# Verify that the amount of data in a send -c stream matches compressratio. 24# 25# Strategy: 26# 1. For random compression types, and compressible / incompressible data: 27# 2. Create a snap with data 28# 3. Compare the size of the stream with the data on the dataset, adjusted 29# by compressratio for normal send, and compared to used for send -c. 30# 31 32verify_runnable "both" 33 34log_assert "Verify send -c streams are compressed" 35log_onexit cleanup_pool $POOL2 36 37typeset sendfs=$POOL2/$FS 38typeset megs=128 39 40for prop in $(get_rand_compress_any 6); do 41 for compressible in 'yes' 'no'; do 42 log_must zfs create -o compress=$prop $sendfs 43 44 if [[ $compressible = 'yes' ]]; then 45 write_compressible $(get_prop mountpoint $sendfs) \ 46 ${megs}m 47 else 48 typeset file="$(get_prop mountpoint $sendfs)/ddfile" 49 log_must dd if=/dev/urandom of=$file bs=1024k count=$megs 50 fi 51 52 log_must zfs snapshot $sendfs@snap 53 54 # Calculate the sizes and verify the compression ratio. 55 log_must eval "zfs send $sendfs@snap >$BACKDIR/uncompressed" 56 verify_stream_size $BACKDIR/uncompressed $sendfs 57 58 log_must eval "zfs send -c $sendfs@snap >$BACKDIR/compressed" 59 verify_stream_size $BACKDIR/compressed $sendfs 60 61 log_must rm $BACKDIR/uncompressed $BACKDIR/compressed 62 log_must zfs destroy -r $sendfs 63 done 64done 65 66log_pass "Verify send -c streams are compressed" 67