1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2017, Datto, Inc. All rights reserved.
19#
20
21. $STF_SUITE/include/libtest.shlib
22
23#
24# DESCRIPTION:
25# ZFS should perform raw sends of datasets.
26#
27# STRATEGY:
28# 1. Create an encrypted dataset
29# 2. Snapshot the default dataset and the encrypted dataset
30# 3. Attempt a raw send of both datasets
31# 4. Attempt a raw send with properties of both datasets
32# 5. Attempt a raw replication send of both datasets
33# 6. Unmount and unload the encrypted dataset key
34# 7. Attempt a raw send of the encrypted dataset
35#
36
37verify_runnable "both"
38
39function cleanup
40{
41	snapexists $snap && destroy_dataset $snap
42	datasetexists $TESTPOOL/$TESTFS1 && \
43		destroy_dataset $TESTPOOL/$TESTFS1 -r
44}
45
46log_onexit cleanup
47
48log_assert "ZFS should perform raw sends of datasets"
49
50typeset passphrase="password"
51typeset snap="$TESTPOOL/$TESTFS@snap"
52typeset snap1="$TESTPOOL/$TESTFS1@snap"
53
54log_must eval "echo $passphrase | zfs create -o encryption=on" \
55	"-o keyformat=passphrase $TESTPOOL/$TESTFS1"
56
57log_must zfs snapshot $snap
58log_must zfs snapshot $snap1
59
60log_must eval "zfs send -w $snap > /dev/null"
61log_must eval "zfs send -w $snap1 > /dev/null"
62
63log_note "Verify ZFS can perform raw sends with properties"
64log_must eval "zfs send -wp $snap > /dev/null"
65log_must eval "zfs send -wp $snap1 > /dev/null"
66
67log_note "Verify ZFS can perform raw replication sends"
68log_must eval "zfs send -wR $snap > /dev/null"
69log_must eval "zfs send -wR $snap1 > /dev/null"
70
71log_note "Verify ZFS can perform a raw send of an encrypted datasets with" \
72	"its key unloaded"
73log_must zfs unmount $TESTPOOL/$TESTFS1
74log_must zfs unload-key $TESTPOOL/$TESTFS1
75log_must eval "zfs send -w $snap1 > /dev/null"
76
77log_pass "ZFS performs raw sends of datasets"
78