aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/include/libtest.shlib
diff options
context:
space:
mode:
authorLOLi <[email protected]>2017-07-28 23:12:34 +0200
committerBrian Behlendorf <[email protected]>2017-07-28 14:12:34 -0700
commit650258d7c786b8e62ca847a926f6f038cd3e5d94 (patch)
treefa73fa616fd82d562bc143efcd8e25e94aa7e2bf /tests/zfs-tests/include/libtest.shlib
parentf06f53fa3f566056fd3a03737032f1bd6bcf48bc (diff)
zfs promote|rename .../%recv should be an error
If we are in the middle of an incremental 'zfs receive', the child .../%recv will exist. If we run 'zfs promote' .../%recv, it will "work", but then zfs gets confused about the status of the new dataset. Attempting to do this promote should be an error. Similarly renaming .../%recv datasets should not be allowed. Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #4843 Closes #6339
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r--tests/zfs-tests/include/libtest.shlib35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 88594c201..b6ac41dfa 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -351,6 +351,41 @@ function create_bookmark
log_must zfs bookmark $fs_vol@$snap $fs_vol#$bkmark
}
+#
+# Create a temporary clone result of an interrupted resumable 'zfs receive'
+# $1 Destination filesystem name. Must not exist, will be created as the result
+# of this function along with its %recv temporary clone
+# $2 Source filesystem name. Must not exist, will be created and destroyed
+#
+function create_recv_clone
+{
+ typeset recvfs="$1"
+ typeset sendfs="${2:-$TESTPOOL/create_recv_clone}"
+ typeset snap="$sendfs@snap1"
+ typeset incr="$sendfs@snap2"
+ typeset mountpoint="$TESTDIR/create_recv_clone"
+ typeset sendfile="$TESTDIR/create_recv_clone.zsnap"
+
+ [[ -z $recvfs ]] && log_fail "Recv filesystem's name is undefined."
+
+ datasetexists $recvfs && log_fail "Recv filesystem must not exist."
+ datasetexists $sendfs && log_fail "Send filesystem must not exist."
+
+ log_must zfs create -o mountpoint="$mountpoint" $sendfs
+ log_must zfs snapshot $snap
+ log_must eval "zfs send $snap | zfs recv -u $recvfs"
+ log_must mkfile 1m "$mountpoint/data"
+ log_must zfs snapshot $incr
+ log_must eval "zfs send -i $snap $incr | dd bs=10K count=1 > $sendfile"
+ log_mustnot eval "zfs recv -su $recvfs < $sendfile"
+ log_must zfs destroy -r $sendfs
+ log_must rm -f "$sendfile"
+
+ if [[ $(get_prop 'inconsistent' "$recvfs/%recv") -ne 1 ]]; then
+ log_fail "Error creating temporary $recvfs/%recv clone"
+ fi
+}
+
function default_mirror_setup
{
default_mirror_setup_noexit $1 $2 $3