]>
Commit | Line | Data |
---|---|---|
30af21b0 PD |
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 incrementals (redacted and normal) work with redacted datasets. | |
23 | # | |
24 | # Strategy: | |
25 | # 1. Test normal incrementals from the original snap to a subset of the | |
26 | # redaction list. | |
27 | # 2. Test receipt of intermediate clones, and their children. | |
28 | # 3. Test receipt with origin snap specified by '-o origin='. | |
29 | # 4. Test incrementals from redaction bookmarks. | |
30 | # | |
31 | ||
32 | typeset ds_name="incrementals" | |
33 | typeset sendfs="$POOL/$ds_name" | |
34 | typeset recvfs="$POOL2/$ds_name" | |
35 | typeset clone="$POOL/${ds_name}_clone" | |
36 | typeset tmpdir="$(get_prop mountpoint $POOL)/tmp" | |
37 | typeset stream=$(mktemp $tmpdir/stream.XXXX) | |
38 | setup_dataset $ds_name '' setup_incrementals | |
39 | typeset clone_mnt="$(get_prop mountpoint $clone)" | |
40 | typeset send_mnt="$(get_prop mountpoint $sendfs)" | |
41 | typeset recv_mnt="/$POOL2/$ds_name" | |
42 | ||
43 | log_onexit redacted_cleanup $sendfs $recvfs $POOL2/rfs | |
44 | ||
45 | # Setup a redacted send using a redaction list at varying depth. | |
46 | log_must zfs redact $sendfs@snap0 book1 $POOL/rm@snap $POOL/stride3@snap \ | |
47 | $POOL/stride5@snap | |
48 | log_must eval "zfs send --redact book1 $sendfs@snap0 >$stream" | |
49 | log_must eval "zfs receive $POOL2/rfs <$stream" | |
50 | ||
51 | # Verify receipt of normal incrementals to redaction list members. | |
52 | log_must eval "zfs send -i $sendfs@snap0 $POOL/stride3@snap >$stream" | |
53 | log_must eval "zfs recv $POOL2/rstride3 <$stream" | |
669683c4 | 54 | log_must directory_diff /$POOL/stride3 /$POOL2/rstride3 |
30af21b0 PD |
55 | log_must eval "zfs send -i $sendfs@snap0 $POOL/stride5@snap >$stream" |
56 | log_must eval "zfs recv $POOL2/rstride5 <$stream" | |
669683c4 | 57 | log_must directory_diff /$POOL/stride5 /$POOL2/rstride5 |
30af21b0 PD |
58 | |
59 | # But not a normal child that we weren't redacted with respect to. | |
60 | log_must eval "zfs send -i $sendfs@snap0 $POOL/hole@snap >$stream" | |
61 | log_mustnot eval "zfs recv $POOL2/rhole@snap <$stream" | |
62 | ||
63 | # Verify we can receive an intermediate clone redacted with respect to a | |
64 | # subset of the original redaction list. | |
65 | log_must zfs redact $POOL/int@snap book2 $POOL/rm@snap | |
66 | log_must eval "zfs send -i $sendfs@snap0 --redact book2 $POOL/int@snap >$stream" | |
67 | log_must eval "zfs recv $POOL2/rint <$stream" | |
68 | compare_files $POOL/int $POOL2/rint "f1" "$RANGE0" | |
69 | compare_files $POOL/int $POOL2/rint "f2" "$RANGE15" | |
70 | compare_files $POOL/int $POOL2/rint "d1/f1" "$RANGE16" | |
71 | log_must mount_redacted -f $POOL2/rint | |
72 | ||
73 | # Verify we can receive grandchildren on the child. | |
74 | log_must eval "zfs send -i $POOL/int@snap $POOL/rm@snap >$stream" | |
75 | log_must eval "zfs receive $POOL2/rrm <$stream" | |
669683c4 | 76 | log_must directory_diff /$POOL/rm /$POOL2/rrm |
30af21b0 PD |
77 | |
78 | # But not a grandchild that the received child wasn't redacted with respect to. | |
79 | log_must eval "zfs send -i $POOL/int@snap $POOL/write@snap >$stream" | |
80 | log_mustnot eval "zfs recv $POOL2/rwrite<$stream" | |
81 | ||
82 | # Verify we cannot receive an intermediate clone that isn't redacted with | |
83 | # respect to a subset of the original redaction list. | |
84 | log_must zfs redact $POOL/int@snap book4 $POOL/rm@snap $POOL/write@snap | |
85 | log_must eval "zfs send -i $sendfs@snap0 --redact book4 $POOL/int@snap >$stream" | |
86 | log_mustnot eval "zfs recv $POOL2/rint <$stream" | |
87 | log_must zfs redact $POOL/int@snap book5 $POOL/write@snap | |
88 | log_must eval "zfs send -i $sendfs@snap0 --redact book5 $POOL/int@snap >$stream" | |
89 | log_mustnot eval "zfs recv $POOL2/rint <$stream" | |
90 | log_mustnot zfs redact $POOL/int@snap book6 $POOL/hole@snap | |
91 | ||
92 | # Verify we can receive a full clone of the grandchild on the child. | |
93 | log_must eval "zfs send $POOL/write@snap >$stream" | |
94 | log_must eval "zfs recv -o origin=$POOL2/rint@snap $POOL2/rwrite <$stream" | |
669683c4 | 95 | log_must directory_diff /$POOL/write /$POOL2/rwrite |
30af21b0 PD |
96 | |
97 | # Along with other origins. | |
98 | log_must eval "zfs recv -o origin=$POOL2/rfs@snap0 $POOL2/rwrite1 <$stream" | |
669683c4 | 99 | log_must directory_diff /$POOL/write /$POOL2/rwrite1 |
30af21b0 | 100 | log_must eval "zfs recv -o origin=$POOL2@init $POOL2/rwrite2 <$stream" |
669683c4 | 101 | log_must directory_diff /$POOL/write /$POOL2/rwrite2 |
30af21b0 PD |
102 | log_must zfs destroy -R $POOL2/rwrite2 |
103 | ||
104 | log_must zfs destroy -R $POOL2/rfs | |
105 | ||
106 | # Write some data for tests of incremental sends from bookmarks | |
107 | log_must zfs snapshot $sendfs@snap1 | |
108 | log_must zfs clone $sendfs@snap1 $POOL/hole1 | |
109 | typeset mntpnt=$(get_prop mountpoint $POOL/hole1) | |
110 | log_must dd if=/dev/zero of=$mntpnt/f2 bs=128k count=16 conv=notrunc | |
111 | log_must zfs snapshot $POOL/hole1@snap | |
112 | log_must zfs clone $sendfs@snap1 $POOL/write1 | |
113 | mntpnt=$(get_prop mountpoint $POOL/write1) | |
114 | log_must dd if=/dev/urandom of=$mntpnt/f2 bs=128k count=16 conv=notrunc | |
115 | log_must zfs snapshot $POOL/write1@snap | |
116 | log_must zfs clone $POOL/int@snap $POOL/write2 | |
117 | mntpnt=$(get_prop mountpoint $POOL/write2) | |
118 | log_must dd if=/dev/urandom of=$mntpnt/f2 bs=128k count=16 conv=notrunc | |
119 | log_must zfs snapshot $POOL/write2@snap | |
120 | ||
121 | # Setup a redacted send using a redaction list at varying depth. | |
122 | log_must zfs redact $sendfs@snap0 book7 $POOL/rm@snap $POOL/stride3@snap \ | |
123 | $POOL/stride5@snap | |
124 | log_must eval "zfs send --redact book7 $sendfs@snap0 >$stream" | |
125 | log_must eval "zfs receive $POOL2/rfs <$stream" | |
126 | ||
127 | # Verify we can receive a redacted incremental sending from the bookmark. | |
128 | log_must zfs redact $sendfs@snap1 book8 $POOL/write1@snap | |
129 | log_must eval "zfs send -i $sendfs#book7 --redact book8 $sendfs@snap1 >$stream" | |
130 | log_must eval "zfs receive $POOL2/rfs <$stream" | |
131 | # The stride3 and stride5 snaps redact 3 128k blocks at block offsets 0 15 and | |
132 | # 30 of f2. The write1 snap only covers the first two of those three blocks. | |
133 | compare_files $sendfs $POOL2/rfs "f2" "$RANGE12" | |
134 | log_must mount_redacted -f $POOL2/rfs | |
135 | log_must diff $send_mnt/f1 /$POOL2/rfs/f1 | |
136 | log_must diff $send_mnt/d1/f1 /$POOL2/rfs/d1/f1 | |
137 | unmount_redacted $POOL2/rfs | |
138 | ||
139 | # Verify we can receive a normal child we weren't redacted with respect to by | |
140 | # sending from the bookmark. | |
141 | log_must eval "zfs send -i $sendfs#book7 $POOL/hole1@snap >$stream" | |
142 | log_must eval "zfs recv $POOL2/rhole1 <$stream" | |
669683c4 | 143 | log_must directory_diff /$POOL/hole1 /$POOL2/rhole1 |
30af21b0 PD |
144 | |
145 | # Verify we can receive an intermediate clone redacted with respect to a | |
146 | # non-subset if we send from the bookmark. | |
147 | log_must zfs redact $POOL/int@snap book9 $POOL/write2@snap | |
148 | log_must eval "zfs send -i $sendfs#book7 --redact book9 $POOL/int@snap >$stream" | |
149 | log_must eval "zfs receive $POOL2/rint <$stream" | |
150 | compare_files $sendfs $POOL2/rint "f2" "$RANGE12" | |
151 | ||
152 | log_pass "Incrementals (redacted and normal) work with redacted datasets." |