15602294fSDan Kimmel#!/usr/bin/ksh 25602294fSDan Kimmel 35602294fSDan Kimmel# 45602294fSDan Kimmel# This file and its contents are supplied under the terms of the 55602294fSDan Kimmel# Common Development and Distribution License ("CDDL"), version 1.0. 65602294fSDan Kimmel# You may only use this file in accordance with the terms of version 75602294fSDan Kimmel# 1.0 of the CDDL. 85602294fSDan Kimmel# 95602294fSDan Kimmel# A full copy of the text of the CDDL should have accompanied this 105602294fSDan Kimmel# source. A copy of the CDDL is also available via the Internet at 115602294fSDan Kimmel# http://www.illumos.org/license/CDDL. 125602294fSDan Kimmel# 135602294fSDan Kimmel 145602294fSDan Kimmel# 15*a01b7f54SJohn Wren Kennedy# Copyright (c) 2015, 2018 by Delphix. All rights reserved. 165602294fSDan Kimmel# 175602294fSDan Kimmel 185602294fSDan Kimmel. $STF_SUITE/tests/functional/rsend/rsend.kshlib 195602294fSDan Kimmel 205602294fSDan Kimmel# 215602294fSDan Kimmel# Description: 225602294fSDan Kimmel# Verify that the -c and -D flags do not interfere with each other. 235602294fSDan Kimmel# 245602294fSDan Kimmel# Strategy: 255602294fSDan Kimmel# 1. Write unique data to a filesystem and create a compressed, deduplicated 265602294fSDan Kimmel# full stream. 275602294fSDan Kimmel# 2. Verify that the stream and send dataset show the same size 285602294fSDan Kimmel# 3. Make several copies of the original data, and create both full and 295602294fSDan Kimmel# incremental compressed, deduplicated send streams 305602294fSDan Kimmel# 4. Verify the full stream is no bigger than the stream from step 1 315602294fSDan Kimmel# 5. Verify the streams can be received correctly. 325602294fSDan Kimmel# 335602294fSDan Kimmel 345602294fSDan Kimmelverify_runnable "both" 355602294fSDan Kimmel 365602294fSDan Kimmellog_assert "Verify that the -c and -D flags do not interfere with each other" 375602294fSDan Kimmellog_onexit cleanup_pool $POOL2 385602294fSDan Kimmel 395602294fSDan Kimmeltypeset sendfs=$POOL2/sendfs 405602294fSDan Kimmeltypeset recvfs=$POOL2/recvfs 415602294fSDan Kimmeltypeset stream0=$BACKDIR/stream.0 425602294fSDan Kimmeltypeset stream1=$BACKDIR/stream.1 435602294fSDan Kimmeltypeset inc=$BACKDIR/stream.inc 445602294fSDan Kimmel 455602294fSDan Kimmellog_must zfs create -o compress=lz4 $sendfs 465602294fSDan Kimmellog_must zfs create -o compress=lz4 $recvfs 475602294fSDan Kimmeltypeset dir=$(get_prop mountpoint $sendfs) 485602294fSDan Kimmel# Don't use write_compressible: we want compressible but undedupable data here. 49*a01b7f54SJohn Wren Kennedylog_must eval "dd if=/dev/urandom bs=1024k count=4 | base64 >$dir/file" 505602294fSDan Kimmellog_must zfs snapshot $sendfs@snap0 515602294fSDan Kimmellog_must eval "zfs send -D -c $sendfs@snap0 >$stream0" 525602294fSDan Kimmel 535602294fSDan Kimmel# The stream size should match at this point because the data is all unique 545602294fSDan Kimmelverify_stream_size $stream0 $sendfs 555602294fSDan Kimmel 565602294fSDan Kimmelfor i in {0..3}; do 575602294fSDan Kimmel log_must cp $dir/file $dir/file.$i 585602294fSDan Kimmeldone 595602294fSDan Kimmellog_must zfs snapshot $sendfs@snap1 605602294fSDan Kimmel 615602294fSDan Kimmel# The stream sizes should match, since the second stream contains no new blocks 625602294fSDan Kimmellog_must eval "zfs send -D -c $sendfs@snap1 >$stream1" 635602294fSDan Kimmeltypeset size0=$(stat -c %s $stream0) 645602294fSDan Kimmeltypeset size1=$(stat -c %s $stream1) 655602294fSDan Kimmelwithin_percent $size0 $size1 90 || log_fail "$size0 and $size1" 665602294fSDan Kimmel 675602294fSDan Kimmel# Finally, make sure the receive works correctly. 685602294fSDan Kimmellog_must eval "zfs send -D -c -i snap0 $sendfs@snap1 >$inc" 695602294fSDan Kimmellog_must eval "zfs recv -d $recvfs <$stream0" 705602294fSDan Kimmellog_must eval "zfs recv -d $recvfs <$inc" 715602294fSDan Kimmelcmp_ds_cont $sendfs $recvfs 725602294fSDan Kimmel 735602294fSDan Kimmel# The size of the incremental should be the same as the initial send. 745602294fSDan Kimmeltypeset size2=$(stat -c %s $inc) 755602294fSDan Kimmelwithin_percent $size0 $size2 90 || log_fail "$size0 and $size1" 765602294fSDan Kimmel 775602294fSDan Kimmellog_pass "The -c and -D flags do not interfere with each other" 78