xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/rsend/send-cD.ksh (revision edd580643f2cf1434e252cd7779e83182ea84945)
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, 2018 by Delphix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/rsend/rsend.kshlib
19
20#
21# Description:
22# Verify that the -c and -D flags do not interfere with each other.
23#
24# Strategy:
25# 1. Write unique data to a filesystem and create a compressed, deduplicated
26#    full stream.
27# 2. Verify that the stream and send dataset show the same size
28# 3. Make several copies of the original data, and create both full and
29#    incremental compressed, deduplicated send streams
30# 4. Verify the full stream is no bigger than the stream from step 1
31# 5. Verify the streams can be received correctly.
32#
33
34verify_runnable "both"
35
36log_assert "Verify that the -c and -D flags do not interfere with each other"
37log_onexit cleanup_pool $POOL2
38
39typeset sendfs=$POOL2/sendfs
40typeset recvfs=$POOL2/recvfs
41typeset stream0=$BACKDIR/stream.0
42typeset stream1=$BACKDIR/stream.1
43typeset inc=$BACKDIR/stream.inc
44
45log_must zfs create -o compress=lz4 $sendfs
46log_must zfs create -o compress=lz4 $recvfs
47typeset dir=$(get_prop mountpoint $sendfs)
48# Don't use write_compressible: we want compressible but undedupable data here.
49log_must eval "dd if=/dev/urandom bs=1024k count=4 | base64 >$dir/file"
50log_must zfs snapshot $sendfs@snap0
51log_must eval "zfs send -D -c $sendfs@snap0 >$stream0"
52
53# The stream size should match at this point because the data is all unique
54verify_stream_size $stream0 $sendfs
55
56for i in {0..3}; do
57	log_must cp $dir/file $dir/file.$i
58done
59log_must zfs snapshot $sendfs@snap1
60
61# The stream sizes should match, since the second stream contains no new blocks
62log_must eval "zfs send -D -c $sendfs@snap1 >$stream1"
63typeset size0=$(stat -c %s $stream0)
64typeset size1=$(stat -c %s $stream1)
65within_percent $size0 $size1 90 || log_fail "$size0 and $size1"
66
67# Finally, make sure the receive works correctly.
68log_must eval "zfs send -D -c -i snap0 $sendfs@snap1 >$inc"
69log_must eval "zfs recv -d $recvfs <$stream0"
70log_must eval "zfs recv -d $recvfs <$inc"
71cmp_ds_cont $sendfs $recvfs
72
73# The size of the incremental should be the same as the initial send.
74typeset size2=$(stat -c %s $inc)
75within_percent $size0 $size2 90 || log_fail "$size0 and $size1"
76
77log_pass "The -c and -D flags do not interfere with each other"
78