1*5602294fSDan Kimmel#!/usr/bin/ksh 2*5602294fSDan Kimmel 3*5602294fSDan Kimmel# 4*5602294fSDan Kimmel# This file and its contents are supplied under the terms of the 5*5602294fSDan Kimmel# Common Development and Distribution License ("CDDL"), version 1.0. 6*5602294fSDan Kimmel# You may only use this file in accordance with the terms of version 7*5602294fSDan Kimmel# 1.0 of the CDDL. 8*5602294fSDan Kimmel# 9*5602294fSDan Kimmel# A full copy of the text of the CDDL should have accompanied this 10*5602294fSDan Kimmel# source. A copy of the CDDL is also available via the Internet at 11*5602294fSDan Kimmel# http://www.illumos.org/license/CDDL. 12*5602294fSDan Kimmel# 13*5602294fSDan Kimmel 14*5602294fSDan Kimmel# 15*5602294fSDan Kimmel# Copyright (c) 2015 by Delphix. All rights reserved. 16*5602294fSDan Kimmel# 17*5602294fSDan Kimmel 18*5602294fSDan Kimmel. $STF_SUITE/tests/functional/rsend/rsend.kshlib 19*5602294fSDan Kimmel. $STF_SUITE/include/math.shlib 20*5602294fSDan Kimmel 21*5602294fSDan Kimmel# 22*5602294fSDan Kimmel# Description: 23*5602294fSDan Kimmel# Verify compression features show up in zstreamdump 24*5602294fSDan Kimmel# 25*5602294fSDan Kimmel# Strategy: 26*5602294fSDan Kimmel# 1. Create a full compressed send stream 27*5602294fSDan Kimmel# 2. Verify zstreamdump shows this stream has the relevant features 28*5602294fSDan Kimmel# 3. Verify zstreamdump's accounting of logical and compressed size is correct 29*5602294fSDan Kimmel# 30*5602294fSDan Kimmel 31*5602294fSDan Kimmelverify_runnable "both" 32*5602294fSDan Kimmel 33*5602294fSDan Kimmellog_assert "Verify zstreamdump correctly interprets compressed send streams." 34*5602294fSDan Kimmellog_onexit cleanup_pool $POOL2 35*5602294fSDan Kimmel 36*5602294fSDan Kimmeltypeset sendfs=$POOL2/fs 37*5602294fSDan Kimmel 38*5602294fSDan Kimmellog_must zfs create -o compress=lz4 $sendfs 39*5602294fSDan Kimmeltypeset dir=$(get_prop mountpoint $sendfs) 40*5602294fSDan Kimmelwrite_compressible $dir 16m 41*5602294fSDan Kimmellog_must zfs snapshot $sendfs@full 42*5602294fSDan Kimmel 43*5602294fSDan Kimmellog_must eval "zfs send -c $sendfs@full >$BACKDIR/full" 44*5602294fSDan Kimmellog_must stream_has_features $BACKDIR/full lz4 compressed 45*5602294fSDan Kimmelcat $BACKDIR/full | zstreamdump -v | parse_dump > $BACKDIR/dump.out 46*5602294fSDan Kimmel 47*5602294fSDan Kimmellsize=$(awk '/^WRITE [^0]/ {lsize += $4} END {printf("%d", lsize)}' \ 48*5602294fSDan Kimmel $BACKDIR/dump.out) 49*5602294fSDan Kimmellsize_prop=$(get_prop logicalused $sendfs) 50*5602294fSDan Kimmelwithin_percent $lsize $lsize_prop 90 || log_fail \ 51*5602294fSDan Kimmel "$lsize and $lsize_prop differed by too much" 52*5602294fSDan Kimmel 53*5602294fSDan Kimmelcsize=$(awk '/^WRITE [^0]/ {csize += $5} END {printf("%d", csize)}' \ 54*5602294fSDan Kimmel $BACKDIR/dump.out) 55*5602294fSDan Kimmelcsize_prop=$(get_prop used $sendfs) 56*5602294fSDan Kimmelwithin_percent $csize $csize_prop 90 || log_fail \ 57*5602294fSDan Kimmel "$csize and $csize_prop differed by too much" 58*5602294fSDan Kimmel 59*5602294fSDan Kimmellog_pass "zstreamdump correctly interprets compressed send streams." 60