xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/rsend/send-c_incremental.ksh (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
1#!/usr/bin/ksh
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2015 by Delphix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/rsend/rsend.kshlib
19
20#
21# Description:
22# Verify that compressed send works correctly with incremental sends.
23#
24# Strategy:
25# 1. Randomly choose either a -i or -I incremental.
26# 2. Generate compressed incremental replication streams for a pool, a
27#    descendant dataset, and a volume.
28# 3. Receive these streams verifying both the contents, and intermediate
29#    snapshots are present or absent as appropriate to the -i or -I option.
30#
31
32verify_runnable "both"
33
34log_assert "Verify compressed send works with incremental send streams."
35log_onexit cleanup_pool $POOL2
36
37typeset opt=$(random_get "-i" "-I")
38typeset final dstlist list vol
39
40log_must eval "zfs send -R $POOL@final > $BACKDIR/final"
41log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/final"
42
43function do_checks
44{
45	log_must cmp_ds_cont $POOL $POOL2
46	[[ $opt = "-I" ]] && log_must cmp_ds_subs $POOL $POOL2
47	[[ $opt = "-i" ]] && log_mustnot cmp_ds_subs $POOL $POOL2
48
49	[[ $1 != "clean" ]] && return
50
51	cleanup_pool $POOL2
52	log_must eval "zfs send -R $POOL@final > $BACKDIR/final"
53	log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/final"
54}
55
56if is_global_zone; then
57	# Send from the pool root
58	final=$(getds_with_suffix $POOL2 @final)
59	list="$final $(getds_with_suffix $POOL2 @snapA)"
60	list="$list $(getds_with_suffix $POOL2 @snapB)"
61	list="$list $(getds_with_suffix $POOL2 @snapC)"
62
63	log_must eval "zfs send -c -R $opt @init $POOL2@final >$BACKDIR/pool"
64	log_must destroy_tree $list
65	log_must eval "zfs recv -d -F $POOL2 <$BACKDIR/pool"
66
67	dstlist=$(getds_with_suffix $POOL2 @final)
68	[[ $final != $dstlist ]] && log_fail "$final != $dstlist"
69
70	do_checks clean
71
72	# Send of a volume
73	vol=$POOL2/$FS/vol
74	final=$(getds_with_suffix $vol @final)
75	log_must eval "zfs send -c -R $opt @init $vol@final >$BACKDIR/vol"
76	log_must destroy_tree $vol@snapB $vol@snapC $vol@final
77	log_must eval "zfs recv -d -F $POOL2 <$BACKDIR/vol"
78
79	dstlist=$(getds_with_suffix $POOL2/$FS/vol @final)
80	[[ $final != $dstlist ]] && log_fail "$final != $dstlist"
81
82	do_checks clean
83fi
84
85# Send of a descendant fs
86final=$(getds_with_suffix $POOL2/$FS @final)
87list="$final $(getds_with_suffix $POOL2/$FS @snapA)"
88list="$list $(getds_with_suffix $POOL2/$FS @snapB)"
89list="$list $(getds_with_suffix $POOL2/$FS @snapC)"
90
91log_must eval "zfs send -c -R $opt @init $POOL2/$FS@final >$BACKDIR/fs"
92log_must destroy_tree $list
93log_must eval "zfs recv -d -F $POOL2 <$BACKDIR/fs"
94
95dstlist=$(getds_with_suffix $POOL2/$FS @final)
96[[ $final != $dstlist ]] && log_fail "$final != $dstlist"
97
98do_checks
99
100log_pass "Compressed send works with incremental send streams."
101