9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#!/usr/bin/ksh
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# This file and its contents are supplied under the terms of the
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# Common Development and Distribution License ("CDDL"), version 1.0.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# You may only use this file in accordance with the terms of version
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 1.0 of the CDDL.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# A full copy of the text of the CDDL should have accompanied this
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# source. A copy of the CDDL is also available via the Internet at
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# http://www.illumos.org/license/CDDL.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2014, 2016 by Delphix. All rights reserved.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens. $STF_SUITE/include/libtest.shlib
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens. $STF_SUITE/tests/functional/rsend/rsend.kshlib
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# Description:
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# Verify resumability of a full and incremental ZFS send/receive in the
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# presence of a corrupted stream.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# Strategy:
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 1. Start a full ZFS send, redirect output to a file
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 2. Mess up the contents of the stream state file on disk
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 3. Try ZFS receive, which should fail with a checksum mismatch error
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 4. ZFS send to the stream state file again using the receive_resume_token
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 5. ZFS receieve and verify the receive completes successfully
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 6. Repeat steps on an incremental ZFS send
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedy# 7. Repeat the entire procedure for a dataset at the pool root
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensverify_runnable "both"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrenslog_assert "Verify resumability of a full and incremental ZFS send/receive " \
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens "in the presence of a corrupted stream"
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmellog_onexit resume_cleanup $sendfs $streamfs
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmelsendfs=$POOL/sendfs
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedyrecvfs=$POOL3/recvfs
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedystreamfs=$POOL2/stream
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedyfor sendfs in $POOL2/sendfs $POOL2; do
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedy test_fs_setup $sendfs $recvfs
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedy resume_test "zfs send -v $sendfs@a" $streamfs $recvfs
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedy resume_test "zfs send -v -i @a $sendfs@b" $streamfs $recvfs
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedy file_check $sendfs $recvfs
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedydone
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrenslog_pass "Verify resumability of a full and incremental ZFS send/receive " \
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens "in the presence of a corrupted stream"