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/include/libtest.shlib 19. $STF_SUITE/tests/functional/redacted_send/redacted.kshlib 20 21# 22# Description: 23# Test that receiving sends from redaction bookmarks and redacted datasets 24# works correctly in certain edge cases. 25# 1. Send A(B,C,D) to pool2. 26# 2. Verify send from A(B, C, D) can be received onto it. 27# 3. Verify send from A(B, C) can be received onto it. 28# 4. Verify send from A() can be received onto it. 29# 5. Verify send from A(E) cannot be received onto it. 30# 6. Verify send from redaction bookmark for A(B, C) can be received onto it. 31# 7. Verify send from redaction bookmark for A() can be received onto it. 32# 8. Verify send from redaction bookmark for A(E) cannot be received onto it. 33# 34 35typeset ds_name="origin" 36typeset sendfs="$POOL/$ds_name" 37typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" 38typeset stream=$(mktemp $tmpdir/stream.XXXX) 39setup_dataset $ds_name '' setup_incrementals 40typeset dsA=$sendfs@snap0 41typeset dsB=$POOL/hole@snap 42typeset dsC=$POOL/rm@snap 43typeset dsD=$POOL/write@snap 44typeset dsE=$POOL/stride3@snap 45typeset dsF=$POOL/stride5@snap 46typeset targ=$POOL2/targfs@snap 47 48log_onexit redacted_cleanup $sendfs $POOL2/rBCD $POOL2/targfs \ 49 $POOL2/rBC $POOL2/rE 50 51# Set up all the filesystems and clones. 52log_must zfs redact $dsA BCD $dsB $dsC $dsD 53log_must eval "zfs send --redact BCD $dsA >$stream" 54log_must eval "zfs receive $POOL2/rBCD <$stream" 55log_must eval "zfs receive $targ <$stream" 56 57log_must zfs redact $dsA BC $dsB $dsC 58log_must eval "zfs send --redact BC $dsA >$stream" 59log_must eval "zfs receive $POOL2/rBC <$stream" 60 61log_must zfs redact $dsA E $dsE 62log_must eval "zfs send --redact E $dsA >$stream" 63log_must eval "zfs receive $POOL2/rE <$stream" 64 65log_must eval "zfs send $dsF >$stream" 66log_must eval "zfs receive -o origin=$POOL2/rBCD@snap0 $POOL2/BCDrF <$stream" 67log_must eval "zfs receive -o origin=$POOL2/rBC@snap0 $POOL2/BCrF <$stream" 68log_must eval "zfs receive -o origin=$POOL2/rE@snap0 $POOL2/ErF <$stream" 69 70# Run tests from redacted datasets. 71log_must eval "zfs send -i $POOL2/rBCD@snap0 $POOL2/BCDrF@snap >$stream" 72log_must eval "zfs receive -o origin=$targ $POOL2/tdBCD <$stream" 73 74log_must eval "zfs send -i $POOL2/rBC@snap0 $POOL2/BCrF@snap >$stream" 75log_must eval "zfs receive -o origin=$targ $POOL2/tdBC <$stream" 76 77log_must eval "zfs send -i $POOL2/rE@snap0 $POOL2/ErF@snap >$stream" 78log_mustnot eval "zfs receive -o origin=$targ $POOL2/tdE <$stream" 79 80# Run tests from redaction bookmarks. 81log_must eval "zfs send -i $sendfs#BC $dsF >$stream" 82log_must eval "zfs receive -o origin=$targ $POOL2/tbBC <$stream" 83 84log_must eval "zfs send -i $sendfs#E $dsF >$stream" 85log_mustnot eval "zfs receive -o origin=$targ $POOL2/tbE <$stream" 86 87log_pass "Verify sends from redacted datasets and bookmarks work correctly." 88