1#!/bin/ksh -p
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) 2022 by Nutanix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/rsend/rsend.kshlib
19
20#
21# Description:
22# Verify resumability of full ZFS send/receive on existing dataset
23#
24# Strategy:
25# 1. Start a full ZFS send with redirect output to a file
26# 2. Mess up the contents of the stream state file on disk
27# 3. Try ZFS receive, which should fail with a checksum mismatch error
28# 4. ZFS send to the stream state file again using the receive_resume_token
29# 5. Verify ZFS receive without "-F" option (force recvflag) fails.
30# 6. Verify ZFS receive with "-F" option completes successfully.
31# 7. Repeat steps on an incremental ZFS send. It should complete
32#    successfully without "-F" option.
33#
34
35verify_runnable "both"
36
37sendfs=$POOL/sendfs
38recvfs=$POOL2/recvfs
39streamfs=$POOL/stream
40
41log_assert "Verify resumability of full ZFS send/receive on existing dataset"
42log_onexit resume_cleanup $sendfs $streamfs
43
44test_fs_setup $sendfs $recvfs $streamfs
45
46# Full send/recv on existing dataset
47log_must zfs create -o readonly=on $recvfs
48log_must eval "zfs send -c -v $sendfs@a >/$streamfs/1"
49mess_send_file /$streamfs/1
50log_mustnot eval "zfs recv -suvF $recvfs </$streamfs/1"
51token=$(get_prop receive_resume_token $recvfs)
52log_must eval "zfs send -t $token  >/$streamfs/2"
53log_mustnot eval "zfs recv -suv $recvfs </$streamfs/2"
54log_must eval "zfs recv -suvF $recvfs </$streamfs/2"
55file_check $sendfs $recvfs
56
57# Incremental send/recv
58log_must eval "zfs send -c -v -i @a $sendfs@b >/$streamfs/3"
59mess_send_file /$streamfs/3
60log_mustnot eval "zfs recv -suvF $recvfs </$streamfs/3"
61token=$(get_prop receive_resume_token $recvfs)
62log_must eval "zfs send -t $token  >/$streamfs/4"
63log_must eval "zfs recv -suv $recvfs </$streamfs/4"
64file_check $sendfs $recvfs
65
66log_pass "Verify resumability of full ZFS send/receive on existing dataset"
67