summaryrefslogtreecommitdiff
path: root/usr/src/test/zfs-tests/tests/functional/rsend/send_mixed_raw.ksh
blob: eea535af110029eba93ae3e395313caf63ce72a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#
#
# Copyright (c) 2019 Datto, Inc. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib

#
# DESCRIPTION:
#	Verify that 'zfs receive' produces an error when mixing
#	raw and non-raw sends in a way that would break IV set
#	consistency.
#
# STRATEGY:
#	1. Create an initial dataset with 3 snapshots.
#	2. Perform a raw send of the first snapshot to 2 other datasets.
#	3. Perform a non-raw send of the second snapshot to one of
#	   the other datasets. Perform a raw send from this dataset to
#	   the last one.
#	4. Attempt to raw send the final snapshot of the first dataset
#	   to the other 2 datasets, which should fail.
#	5. Repeat steps 1-4, but using bookmarks for incremental sends.
#
#
# A                 B             C     notes
# ------------------------------------------------------------------------------
# snap1 ---raw---> snap1 --raw--> snap1 # all snaps initialized via raw send
# snap2 -non-raw-> snap2 --raw--> snap2 # A sends non-raw to B, B sends raw to C
# snap3 ------------raw---------> snap3 # attempt send to C (should fail)
#


verify_runnable "both"

function cleanup
{
    datasetexists $TESTPOOL/$TESTFS3 && \
        log_must zfs destroy -r $TESTPOOL/$TESTFS3
    datasetexists $TESTPOOL/$TESTFS2 && \
        log_must zfs destroy -r $TESTPOOL/$TESTFS2
    datasetexists $TESTPOOL/$TESTFS1 && \
        log_must zfs destroy -r $TESTPOOL/$TESTFS1
}
log_onexit cleanup

log_assert "Mixing raw and non-raw receives should fail"

typeset passphrase="password"

log_must eval "echo $passphrase | zfs create -o encryption=on" \
    "-o keyformat=passphrase  $TESTPOOL/$TESTFS1"

log_must zfs snapshot $TESTPOOL/$TESTFS1@1
log_must touch /$TESTPOOL/$TESTFS1/a
log_must zfs snapshot $TESTPOOL/$TESTFS1@2
log_must touch /$TESTPOOL/$TESTFS1/b
log_must zfs snapshot $TESTPOOL/$TESTFS1@3

# Testing with snapshots
log_must eval "zfs send -w $TESTPOOL/$TESTFS1@1 |" \
    "zfs receive $TESTPOOL/$TESTFS2"
log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS2"
log_must eval "zfs send -w $TESTPOOL/$TESTFS2@1 |" \
    "zfs receive $TESTPOOL/$TESTFS3"
log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS3"

log_must eval "zfs send -i $TESTPOOL/$TESTFS1@1 $TESTPOOL/$TESTFS1@2 |" \
    "zfs receive $TESTPOOL/$TESTFS2"
log_must eval "zfs send -w -i $TESTPOOL/$TESTFS2@1 $TESTPOOL/$TESTFS2@2 |" \
    "zfs receive $TESTPOOL/$TESTFS3"

log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS1@2 $TESTPOOL/$TESTFS1@3 |" \
    "zfs receive $TESTPOOL/$TESTFS2"
log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS2@2 $TESTPOOL/$TESTFS2@3 |" \
    "zfs receive $TESTPOOL/$TESTFS3"

log_must zfs destroy -r $TESTPOOL/$TESTFS3
log_must zfs destroy -r $TESTPOOL/$TESTFS2

# Testing with bookmarks
log_must zfs bookmark $TESTPOOL/$TESTFS1@1 $TESTPOOL/$TESTFS1#b1
log_must zfs bookmark $TESTPOOL/$TESTFS1@2 $TESTPOOL/$TESTFS1#b2

log_must eval "zfs send -w $TESTPOOL/$TESTFS1@1 |" \
    "zfs receive $TESTPOOL/$TESTFS2"
log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS2"

log_must zfs bookmark $TESTPOOL/$TESTFS2@1 $TESTPOOL/$TESTFS2#b1

log_must eval "zfs send -w $TESTPOOL/$TESTFS2@1 |" \
    "zfs receive $TESTPOOL/$TESTFS3"
log_must eval "echo $passphrase | zfs load-key $TESTPOOL/$TESTFS3"

log_must eval "zfs send -i $TESTPOOL/$TESTFS1#b1 $TESTPOOL/$TESTFS1@2 |" \
    "zfs receive $TESTPOOL/$TESTFS2"
log_must eval "zfs send -w -i $TESTPOOL/$TESTFS2#b1 $TESTPOOL/$TESTFS2@2 |" \
    "zfs receive $TESTPOOL/$TESTFS3"

log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS1#b2" \
    "$TESTPOOL/$TESTFS1@3 | zfs receive $TESTPOOL/$TESTFS2"
log_mustnot eval "zfs send -w -i $TESTPOOL/$TESTFS2#b2" \
    "$TESTPOOL/$TESTFS2@3 | zfs receive $TESTPOOL/$TESTFS3"

log_pass "Mixing raw and non-raw receives fail as expected"