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 ZFS send/receive with the -D (dedup) flag in
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# the presence of a corrupted stream.
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# Strategy:
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens# 1. Start a full ZFS send with the -D flag (dedup), 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#
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensverify_runnable "both"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrenslog_assert "Verify resumability of full ZFS send/receive with the -D " \
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens "(dedup) flag"
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrenssendfs=$POOL/sendfs
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensrecvfs=$POOL2/recvfs
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensstreamfs=$POOL/stream
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmellog_onexit resume_cleanup $sendfs $streamfs
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel
ac89d1e83d4735655102d06f099fb2d21bf120f6John Kennedytest_fs_setup $sendfs $recvfs
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyresume_test "zfs send -D -v $sendfs@a" $streamfs $recvfs
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrensfile_check $sendfs $recvfs
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrenslog_pass "Verify resumability of full ZFS send/receive with the -D " \
9c3fd1216fa7fb02cfbc78a2518a686d54b48ab8Matthew Ahrens "(dedup) flag"