]>
Commit | Line | Data |
---|---|---|
b5256303 TC |
1 | #!/bin/ksh -p |
2 | # | |
3 | # CDDL HEADER START | |
4 | # | |
5 | # This file and its contents are supplied under the terms of the | |
6 | # Common Development and Distribution License ("CDDL"), version 1.0. | |
7 | # You may only use this file in accordance with the terms of version | |
8 | # 1.0 of the CDDL. | |
9 | # | |
10 | # A full copy of the text of the CDDL should have accompanied this | |
11 | # source. A copy of the CDDL is also available via the Internet at | |
12 | # http://www.illumos.org/license/CDDL. | |
13 | # | |
14 | # CDDL HEADER END | |
15 | # | |
16 | ||
17 | # | |
18 | # Copyright (c) 2017 by Datto Inc. All rights reserved. | |
19 | # | |
20 | ||
21 | . $STF_SUITE/tests/functional/rsend/rsend.kshlib | |
22 | . $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib | |
23 | ||
24 | # | |
25 | # DESCRIPTION: | |
26 | # Raw recursive sends preserve filesystem structure. | |
27 | # | |
28 | # STRATEGY: | |
29 | # 1. Create an encrypted filesystem with a clone and a child | |
30 | # 2. Snapshot and send the filesystem tree | |
31 | # 3. Verify that the filesystem structure was correctly received | |
32 | # 4. Change the child to an encryption root and promote the clone | |
33 | # 5. Snapshot and send the filesystem tree again | |
34 | # 6. Verify that the new structure is received correctly | |
35 | # | |
36 | ||
37 | verify_runnable "both" | |
38 | ||
39 | function cleanup | |
40 | { | |
41 | log_must cleanup_pool $POOL | |
42 | log_must cleanup_pool $POOL2 | |
43 | log_must setup_test_model $POOL | |
44 | } | |
45 | ||
46 | log_assert "Raw recursive sends preserve filesystem structure." | |
47 | log_onexit cleanup | |
48 | ||
49 | # Create the filesystem heirarchy | |
50 | log_must cleanup_pool $POOL | |
51 | log_must eval "echo $PASSPHRASE | zfs create -o encryption=on" \ | |
52 | "-o keyformat=passphrase $POOL/$FS" | |
53 | log_must zfs snapshot $POOL/$FS@snap | |
54 | log_must zfs clone $POOL/$FS@snap $POOL/clone | |
55 | log_must zfs create $POOL/$FS/child | |
56 | ||
57 | # Back up the tree and verify the structure | |
58 | log_must zfs snapshot -r $POOL@before | |
59 | log_must eval "zfs send -wR $POOL@before > $BACKDIR/fs-before-R" | |
60 | log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/fs-before-R" | |
61 | dstds=$(get_dst_ds $POOL/$FS $POOL2) | |
62 | log_must cmp_ds_subs $POOL/$FS $dstds | |
63 | ||
64 | log_must verify_encryption_root $POOL/$FS $POOL/$FS | |
65 | log_must verify_keylocation $POOL/$FS "prompt" | |
66 | log_must verify_origin $POOL/$FS "-" | |
67 | ||
68 | log_must verify_encryption_root $POOL/clone $POOL/$FS | |
69 | log_must verify_keylocation $POOL/clone "none" | |
70 | log_must verify_origin $POOL/clone "$POOL/$FS@snap" | |
71 | ||
72 | log_must verify_encryption_root $POOL/$FS/child $POOL/$FS | |
73 | log_must verify_keylocation $POOL/$FS/child "none" | |
74 | ||
75 | # Alter the heirarchy and re-send | |
76 | log_must eval "echo $PASSPHRASE1 | zfs change-key -o keyformat=passphrase" \ | |
77 | "$POOL/$FS/child" | |
78 | log_must zfs promote $POOL/clone | |
79 | log_must zfs snapshot -r $POOL@after | |
80 | log_must eval "zfs send -wR -i $POOL@before $POOL@after >" \ | |
81 | "$BACKDIR/fs-after-R" | |
82 | log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/fs-after-R" | |
83 | log_must cmp_ds_subs $POOL/$FS $dstds | |
84 | ||
85 | log_must verify_encryption_root $POOL/$FS $POOL/clone | |
86 | log_must verify_keylocation $POOL/$FS "none" | |
87 | log_must verify_origin $POOL/$FS "$POOL/clone@snap" | |
88 | ||
89 | log_must verify_encryption_root $POOL/clone $POOL/clone | |
90 | log_must verify_keylocation $POOL/clone "prompt" | |
91 | log_must verify_origin $POOL/clone "-" | |
92 | ||
93 | log_must verify_encryption_root $POOL/$FS/child $POOL/$FS/child | |
94 | log_must verify_keylocation $POOL/$FS/child "prompt" | |
95 | ||
96 | log_pass "Raw recursive sends preserve filesystem structure." |