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
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.
15 # Copyright (c) 2018 by Delphix. All rights reserved.
18 . $STF_SUITE/include/libtest.shlib
19 . $STF_SUITE/tests/functional/redacted_send/redacted.kshlib
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.
35 typeset ds_name="origin"
36 typeset sendfs="$POOL/$ds_name"
37 typeset tmpdir="$(get_prop mountpoint $POOL)/tmp"
38 typeset stream=$(mktemp $tmpdir/stream.XXXX)
39 setup_dataset $ds_name '' setup_incrementals
40 typeset dsA=$sendfs@snap0
41 typeset dsB=$POOL/hole@snap
42 typeset dsC=$POOL/rm@snap
43 typeset dsD=$POOL/write@snap
44 typeset dsE=$POOL/stride3@snap
45 typeset dsF=$POOL/stride5@snap
46 typeset targ=$POOL2/targfs@snap
48 log_onexit redacted_cleanup $sendfs $POOL2/rBCD $POOL2/targfs \
51 # Set up all the filesystems and clones.
52 log_must zfs redact $dsA BCD $dsB $dsC $dsD
53 log_must eval "zfs send --redact BCD $dsA >$stream"
54 log_must eval "zfs receive $POOL2/rBCD <$stream"
55 log_must eval "zfs receive $targ <$stream"
57 log_must zfs redact $dsA BC $dsB $dsC
58 log_must eval "zfs send --redact BC $dsA >$stream"
59 log_must eval "zfs receive $POOL2/rBC <$stream"
61 log_must zfs redact $dsA E $dsE
62 log_must eval "zfs send --redact E $dsA >$stream"
63 log_must eval "zfs receive $POOL2/rE <$stream"
65 log_must eval "zfs send $dsF >$stream"
66 log_must eval "zfs receive -o origin=$POOL2/rBCD@snap0 $POOL2/BCDrF <$stream"
67 log_must eval "zfs receive -o origin=$POOL2/rBC@snap0 $POOL2/BCrF <$stream"
68 log_must eval "zfs receive -o origin=$POOL2/rE@snap0 $POOL2/ErF <$stream"
70 # Run tests from redacted datasets.
71 log_must eval "zfs send -i $POOL2/rBCD@snap0 $POOL2/BCDrF@snap >$stream"
72 log_must eval "zfs receive -o origin=$targ $POOL2/tdBCD <$stream"
74 log_must eval "zfs send -i $POOL2/rBC@snap0 $POOL2/BCrF@snap >$stream"
75 log_must eval "zfs receive -o origin=$targ $POOL2/tdBC <$stream"
77 log_must eval "zfs send -i $POOL2/rE@snap0 $POOL2/ErF@snap >$stream"
78 log_mustnot eval "zfs receive -o origin=$targ $POOL2/tdE <$stream"
80 # Run tests from redaction bookmarks.
81 log_must eval "zfs send -i $sendfs#BC $dsF >$stream"
82 log_must eval "zfs receive -o origin=$targ $POOL2/tbBC <$stream"
84 log_must eval "zfs send -i $sendfs#E $dsF >$stream"
85 log_mustnot eval "zfs receive -o origin=$targ $POOL2/tbE <$stream"
87 log_pass "Verify sends from redacted datasets and bookmarks work correctly."