1#!/bin/ksh -p 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# Copyright (c) 2020 by Datto, Inc. All rights reserved. 17# 18 19. $STF_SUITE/tests/functional/rsend/rsend.kshlib 20. $STF_SUITE/include/math.shlib 21 22# 23# Description: 24# Verify compression features show up in zstream dump 25# 26# Strategy: 27# 1. Create a full compressed send stream 28# 2. Verify zstream dump shows this stream has the relevant features 29# 3. Verify zstream dump's accounting of logical and compressed size is correct 30# 4. Verify the toname from a resume token 31# 5. Verify it fails with corrupted resume token 32# 6. Verify it fails with missing resume token 33# 34 35verify_runnable "both" 36 37log_assert "Verify zstream dump correctly interprets compressed send streams." 38log_onexit cleanup_pool $POOL2 39 40typeset sendfs=$POOL2/fs 41typeset streamfs=$POOL2/fs2 42typeset recvfs=$POOL2/fs3 43 44log_must zfs create -o compress=lz4 $sendfs 45log_must zfs create -o compress=lz4 $streamfs 46typeset dir=$(get_prop mountpoint $sendfs) 47write_compressible $dir 16m 48log_must zfs snapshot $sendfs@full 49 50log_must eval "zfs send -c $sendfs@full >$BACKDIR/full" 51log_must stream_has_features $BACKDIR/full lz4 compressed 52zstream dump -v $BACKDIR/full > $BACKDIR/dump.out 53 54lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \ 55 $BACKDIR/dump.out) 56lsize_prop=$(get_prop logicalused $sendfs) 57within_percent $lsize $lsize_prop 90 || log_fail \ 58 "$lsize and $lsize_prop differed by too much" 59 60csize=$(awk '/^WRITE [^0]/ {csize += $27} END {printf("%d", csize)}' \ 61 $BACKDIR/dump.out) 62csize_prop=$(get_prop used $sendfs) 63within_percent $csize $csize_prop 90 || log_fail \ 64 "$csize and $csize_prop differed by too much" 65 66get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs 67resume_token=$(</$streamfs/resume_token) 68to_name_fs=$sendfs 69log_must eval "zstream token $resume_token | grep $to_name_fs" 70 71bad_resume_token="1-1162e8285b-100789c6360" 72log_mustnot eval "zstream token $bad_resume_token 2>&1" 73log_mustnot eval "zstream token 2>&1" 74 75log_pass "zstream dump correctly interprets compressed send streams." 76