xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
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/math.shlib
20
21#
22# Description:
23# Verify compression features show up in zstreamdump
24#
25# Strategy:
26# 1. Create a full compressed send stream
27# 2. Verify zstreamdump shows this stream has the relevant features
28# 3. Verify zstreamdump's accounting of logical and compressed size is correct
29#
30
31verify_runnable "both"
32
33log_assert "Verify zstreamdump correctly interprets compressed send streams."
34log_onexit cleanup_pool $POOL2
35
36typeset sendfs=$POOL2/fs
37
38log_must zfs create -o compress=lz4 $sendfs
39typeset dir=$(get_prop mountpoint $sendfs)
40write_compressible $dir 16m
41log_must zfs snapshot $sendfs@full
42
43log_must eval "zfs send -c $sendfs@full >$BACKDIR/full"
44log_must stream_has_features $BACKDIR/full lz4 compressed
45cat $BACKDIR/full | zstreamdump -v | parse_dump > $BACKDIR/dump.out
46
47lsize=$(awk '/^WRITE [^0]/ {lsize += $4} END {printf("%d", lsize)}' \
48    $BACKDIR/dump.out)
49lsize_prop=$(get_prop logicalused $sendfs)
50within_percent $lsize $lsize_prop 90 || log_fail \
51    "$lsize and $lsize_prop differed by too much"
52
53csize=$(awk '/^WRITE [^0]/ {csize += $5} END {printf("%d", csize)}' \
54    $BACKDIR/dump.out)
55csize_prop=$(get_prop used $sendfs)
56within_percent $csize $csize_prop 90 || log_fail \
57    "$csize and $csize_prop differed by too much"
58
59log_pass "zstreamdump correctly interprets compressed send streams."
60