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 a.0. 6# You may only use this file in accordance with the terms of version 7# a.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) 2019 Datto Inc. 16# Copyright (c) 2020 by Delphix. All rights reserved. 17# 18 19. $STF_SUITE/include/libtest.shlib 20. $STF_SUITE/tests/functional/rsend/rsend.kshlib 21 22# 23# Description: 24# Verify that a partially received dataset can be sent with 25# 'zfs send --saved'. 26# 27# Strategy: 28# 1. Setup a pool with partially received filesystem 29# 2. Perform saved send without incremental 30# 3. Perform saved send with incremental 31# 4. Perform saved send with incremental, resuming from a token 32# 5. Perform negative tests for invalid command inputs 33# 34 35verify_runnable "both" 36 37log_assert "Verify that a partially received dataset can be sent with " \ 38 "'zfs send --saved'." 39 40function cleanup 41{ 42 destroy_dataset $POOL/testfs2 "-r" 43 destroy_dataset $POOL/stream "-r" 44 destroy_dataset $POOL/recvfs "-r" 45 destroy_dataset $POOL/partialfs "-r" 46} 47log_onexit cleanup 48 49log_must zfs create -o compression=off $POOL/testfs2 50log_must zfs create $POOL/stream 51mntpnt=$(get_prop mountpoint $POOL/testfs2) 52 53# Setup a pool with partially received filesystems 54log_must mkfile 1m $mntpnt/filea 55log_must zfs snap $POOL/testfs2@a 56log_must mkfile 1m $mntpnt/fileb 57log_must zfs snap $POOL/testfs2@b 58log_must eval "zfs send $POOL/testfs2@a | zfs recv $POOL/recvfs" 59log_must eval "zfs send -i $POOL/testfs2@a $POOL/testfs2@b > " \ 60 "/$POOL/stream/inc.send" 61log_must eval "zfs send $POOL/testfs2@b > /$POOL/stream/full.send" 62mess_send_file /$POOL/stream/full.send 63mess_send_file /$POOL/stream/inc.send 64log_mustnot zfs recv -s $POOL/recvfullfs < /$POOL/stream/full.send 65log_mustnot zfs recv -s $POOL/recvfs < /$POOL/stream/inc.send 66 67# Perform saved send without incremental 68log_mustnot eval "zfs send --saved $POOL/recvfullfs | zfs recv -s " \ 69 "$POOL/partialfs" 70token=$(zfs get -Hp -o value receive_resume_token $POOL/partialfs) 71log_must eval "zfs send -t $token | zfs recv -s $POOL/partialfs" 72file_check $POOL/recvfullfs $POOL/partialfs 73log_must zfs destroy -r $POOL/partialfs 74 75# Perform saved send with incremental 76log_must eval "zfs send $POOL/recvfs@a | zfs recv $POOL/partialfs" 77log_mustnot eval "zfs send --saved $POOL/recvfs | " \ 78 "zfs recv -s $POOL/partialfs" 79token=$(zfs get -Hp -o value receive_resume_token $POOL/partialfs) 80log_must eval "zfs send -t $token | zfs recv -s $POOL/partialfs" 81file_check $POOL/recvfs $POOL/partialfs 82log_must zfs destroy -r $POOL/partialfs 83 84# Perform saved send with incremental, resuming from token 85log_must eval "zfs send $POOL/recvfs@a | zfs recv $POOL/partialfs" 86log_must eval "zfs send --saved $POOL/recvfs > " \ 87 "/$POOL/stream/partial.send" 88mess_send_file /$POOL/stream/partial.send 89log_mustnot zfs recv -s $POOL/partialfs < /$POOL/stream/partial.send 90token=$(zfs get -Hp -o value receive_resume_token $POOL/partialfs) 91log_must eval "zfs send -t $token | zfs recv -s $POOL/partialfs" 92file_check $POOL/recvfs $POOL/partialfs 93 94# Perform negative tests for invalid command inputs 95set -A badargs \ 96 "" \ 97 "$POOL/recvfs@a" \ 98 "-i $POOL/recvfs@a $POOL/recvfs@b" \ 99 "-R $POOL/recvfs" \ 100 "-p $POOL/recvfs" \ 101 "-I $POOL/recvfs" \ 102 "-h $POOL/recvfs" 103 104while (( i < ${#badargs[*]} )) 105do 106 log_mustnot eval "zfs send --saved ${badargs[i]} > /dev/null" 107 (( i = i + 1 )) 108done 109 110log_pass "A partially received dataset can be sent with 'zfs send --saved'." 111