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 resumable send works correctly with redacted streams. 23# 24# Strategy: 25# 1. Do a full redacted resumable send. 26# 2. Verify the received contents are correct. 27# 3. Do an incremental redacted resumable send. 28# 4. Verify the received contents are correct. 29# 5. Verify that recv -A removes a partially received dataset. 30# 31 32typeset ds_name="resume" 33typeset sendfs="$POOL/$ds_name" 34typeset recvfs="$POOL2/$ds_name" 35typeset clone="$POOL/${ds_name}_clone" 36typeset clone1="$POOL/${ds_name}_clone1" 37typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 38typeset stream=$(mktemp $tmpdir/stream.XXXX) 39setup_dataset $ds_name '' 40typeset clone_mnt="$(get_prop mountpoint $clone)" 41typeset send_mnt="$(get_prop mountpoint $sendfs)" 42typeset recv_mnt="/$POOL2/$ds_name" 43 44log_onexit redacted_cleanup $sendfs $recvfs 45 46log_must stride_dd -i /dev/urandom -o $clone_mnt/f2 -b 512 -c 64 -s 512 47log_must zfs snapshot $clone@snap1 48 49# Do the full resumable send 50log_must zfs redact $sendfs@snap book1 $clone@snap1 51resume_test "zfs send --redact book1 $sendfs@snap" $tmpdir $recvfs 52log_must mount_redacted -f $recvfs 53log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 1 54log_must diff $send_mnt/f1 $recv_mnt/f1 55log_must eval "get_diff $send_mnt/f2 $recv_mnt/f2 >$tmpdir/get_diff.out" 56typeset range=$(cat $tmpdir/get_diff.out) 57[[ "$RANGE9" = "$range" ]] || log_fail "Unexpected range: $range" 58 59log_must dd if=/dev/urandom of=$send_mnt/f3 bs=1024k count=3 60log_must zfs snapshot $sendfs@snap2 61log_must zfs clone $sendfs@snap2 $clone1 62typeset clone1_mnt="$(get_prop mountpoint $clone1)" 63log_must dd if=/dev/urandom of=$clone1_mnt/f3 bs=128k count=3 conv=notrunc 64log_must zfs snapshot $clone1@snap 65 66# Do the incremental resumable send 67log_must zfs redact $sendfs@snap2 book2 $clone1@snap 68resume_test "zfs send --redact book2 -i $sendfs#book1 $sendfs@snap2" \ 69 $tmpdir $recvfs 70log_must diff $send_mnt/f1 $recv_mnt/f1 71log_must diff $send_mnt/f2 $recv_mnt/f2 72log_must eval "get_diff $send_mnt/f3 $recv_mnt/f3 >$tmpdir/get_diff.out" 73range=$(cat $tmpdir/get_diff.out) 74[[ "$RANGE10" = "$range" ]] || log_fail "Unexpected range: $range" 75 76# Test recv -A works properly and verify saved sends are not allowed 77log_mustnot zfs recv -A $recvfs 78log_must zfs destroy -R $recvfs 79log_mustnot zfs recv -A $recvfs 80log_must eval "zfs send --redact book1 $sendfs@snap >$stream" 81dd if=$stream bs=64k count=1 | log_mustnot zfs receive -s $recvfs 82[[ "-" = $(get_prop receive_resume_token $recvfs) ]] && \ 83 log_fail "Receive token not found." 84log_mustnot eval "zfs send --saved --redact book1 $recvfs > /dev/null" 85log_must zfs recv -A $recvfs 86log_must datasetnonexists $recvfs 87 88log_pass "Resumable send works correctly with redacted streams." 89