]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_receive / zfs_receive_013_pos.ksh
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
33 src_fs=$TESTPOOL/drecvsrc
34 temppool=recvtank
35 dst_fs=$temppool/drecvdest
36 streamfile=$TEST_BASE_DIR/drecvstream.$$
37 tpoolfile=$TEST_BASE_DIR/temptank.$$
38
39 function 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
49 log_assert "Verifying 'zfs receive' works correctly on deduplicated streams"
50 log_onexit cleanup
51
52 truncate -s 100M $tpoolfile
53 log_must zpool create $temppool $tpoolfile
54 log_must zfs create $src_fs
55 src_mnt=$(get_prop mountpoint $src_fs) || log_fail "get_prop mountpoint $src_fs"
56
57 echo blah > $src_mnt/blah
58 zfs snapshot $src_fs@base
59
60 echo grumble > $src_mnt/grumble
61 echo blah > $src_mnt/blah2
62 zfs snapshot $src_fs@snap2
63
64 echo grumble > $src_mnt/mumble
65 echo blah > $src_mnt/blah3
66 zfs snapshot $src_fs@snap3
67
68 log_must eval "zfs send -D -R $src_fs@snap3 > $streamfile"
69 log_must eval "zfs receive -v $dst_fs < $streamfile"
70 log_must zfs destroy -r $dst_fs
71 log_must eval "zstream redup $streamfile | zfs receive -v $dst_fs"
72
73 cleanup
74
75 log_pass "Verifying 'zfs receive' works correctly on deduplicated streams"