1#!/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) 2018 by Delphix. All rights reserved. 16# 17 18. $STF_SUITE/tests/functional/redacted_send/redacted.kshlib 19 20# 21# Description: 22# Verify that compressed send streams are redacted correctly. 23# 24# Strategy: 25# 1. Receive a redacted compressed send stream, verifying compression and 26# redaction. 27# 2. Receive an incremental on the full receive, verifying compression and 28# redaction. 29# 30 31typeset ds_name="compressed" 32typeset sendfs="$POOL/$ds_name" 33typeset recvfs="$POOL2/$ds_name" 34typeset clone="$POOL/${ds_name}_clone" 35typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 36typeset stream=$(mktemp $tmpdir/stream.XXXX) 37setup_dataset $ds_name "-o compress=lz4" 38typeset send_mnt="$(get_prop mountpoint $sendfs)" 39typeset clone_mnt="$(get_prop mountpoint $clone)" 40 41log_onexit redacted_cleanup $sendfs $recvfs 42 43log_must stride_dd -i /dev/urandom -o $clone_mnt/f1 -b $((128 * 1024)) -c 4 -s 2 44log_must zfs snapshot $clone@snap1 45log_must rm $clone_mnt/f2 46log_must zfs snapshot $clone@snap2 47 48log_must zfs redact $sendfs@snap book1 $clone@snap1 $clone@snap2 49log_must eval "zfs send -c --redact book1 $sendfs@snap >$stream" 50log_must eval "zfs recv $recvfs <$stream" 51log_must stream_has_features $stream compressed lz4 redacted 52compare_files $sendfs $recvfs "f1" "$RANGE4" 53verify_stream_size $stream $sendfs 54log_must mount_redacted -f $recvfs 55verify_stream_size $stream $recvfs 56log_must unmount_redacted $recvfs 57 58log_must eval "zfs send -c -i $sendfs@snap $clone@snap1 >$stream" 59log_must eval "zfs recv $POOL2/inc1 <$stream" 60log_must stream_has_features $stream compressed lz4 61typeset mntpnt=$(get_prop mountpoint $POOL2) 62log_must diff $clone_mnt/f1 $mntpnt/inc1/f1 63log_must diff $send_mnt/f2 $mntpnt/inc1/f2 64 65log_must eval "zfs send -c -i $sendfs@snap $clone@snap2 >$stream" 66log_must eval "zfs recv $POOL2/inc2 <$stream" 67log_must stream_has_features $stream compressed lz4 68log_must diff $clone_mnt/f1 $mntpnt/inc1/f1 69[[ -f $mntpnt/inc2/f2 ]] && log_fail "File f2 should not exist." 70 71log_pass "Compressed send streams are redacted correctly." 72