xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh (revision 856f710c9dc323b39da5935194d7928ffb99b67f)
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) 2015, 2016 by Delphix. All rights reserved.
19#
20
21. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib
22
23#
24# DESCRIPTION:
25#   Verifying 'zfs receive' works correctly on deduplicated streams
26#
27# STRATEGY:
28#   1. Create some snapshots with duplicated data
29#   2. Send a deduplicated stream of the last snapshot
30#   3. Attempt to receive the deduplicated stream
31#
32
33src_fs=$TESTPOOL/drecvsrc
34temppool=recvtank
35dst_fs=$temppool/drecvdest
36streamfile=/var/tmp/drecvstream.$$
37tpoolfile=/temptank.$$
38
39function cleanup
40{
41    for fs in $src_fs $dst_fs; do
42        datasetexists $fs && log_must zfs destroy -rf $fs
43    done
44    zpool destroy $temppool
45    [[ -f $streamfile ]] && log_must rm -f $streamfile
46    [[ -f $tpoolfile ]] && log_must rm -f $tpoolfile
47}
48
49log_assert "Verifying 'zfs receive' works correctly on deduplicated streams"
50log_onexit cleanup
51
52truncate -s 100M $tpoolfile
53log_must zpool create $temppool $tpoolfile
54log_must zfs create $src_fs
55src_mnt=$(get_prop mountpoint $src_fs) || log_fail "get_prop mountpoint $src_fs"
56
57echo blah > $src_mnt/blah
58zfs snapshot $src_fs@base
59
60echo grumble > $src_mnt/grumble
61echo blah > $src_mnt/blah2
62zfs snapshot $src_fs@snap2
63
64echo grumble > $src_mnt/mumble
65echo blah > $src_mnt/blah3
66zfs snapshot $src_fs@snap3
67
68log_must eval "zfs send -D -R $src_fs@snap3 > $streamfile"
69log_must eval "zfs receive -v $dst_fs < $streamfile"
70
71cleanup
72
73log_pass "Verifying 'zfs receive' works correctly on deduplicated streams"
74