xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/rsend/send-c_volume.ksh (revision 8c69cc8fbe729fa7b091e901c4b50508ccc6bb33)
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 correctly handles volumes
23#
24# Strategy:
25# 1. Write compressible data into a volume, take a snap
26# 2. Verify the compressed stream is the correct size, and has the correct data
27# 3. Repeat step 2 for an incremental compressed stream
28#
29
30function cleanup
31{
32	log_must zfs destroy -r $vol
33	cleanup_pool $POOL2
34}
35
36verify_runnable "both"
37
38log_assert "Verify compressed send works with volumes"
39log_onexit cleanup
40
41typeset vol="$POOL/newvol"
42typeset vol2="$POOL2/newvol"
43typeset voldev="/dev/zvol/rdsk/$POOL/newvol"
44typeset voldev2="/dev/zvol/rdsk/$POOL2/newvol"
45typeset data1=$BACKDIR/file.0
46typeset data2=$BACKDIR/file.1
47typeset megs=8
48
49log_must zfs create -V 256m -o compress=lz4 $vol
50
51write_compressible $BACKDIR ${megs}m 2
52md5_1=$(md5sum $data1 | awk '{print $1}')
53md5_2=$(md5sum $data2 | awk '{print $1}')
54
55log_must dd if=$data1 of=$voldev bs=1024k
56log_must zfs snapshot $vol@snap
57
58log_must eval "zfs send -c $vol@snap >$BACKDIR/full"
59log_must eval "zfs recv -d $POOL2 <$BACKDIR/full"
60
61verify_stream_size $BACKDIR/full $vol
62verify_stream_size $BACKDIR/full $vol2
63md5=$(dd if=$voldev2 bs=1024k count=$megs 2>/dev/null | md5sum | \
64    awk '{print $1}')
65[[ $md5 = $md5_1 ]] || log_fail "md5 mismatch: $md5 != $md5_1"
66
67# Repeat, for an incremental send
68log_must dd oseek=$megs if=$data2 of=$voldev bs=1024k
69log_must zfs snapshot $vol@snap2
70
71log_must eval "zfs send -c -i snap $vol@snap2 >$BACKDIR/inc"
72log_must eval "zfs recv -d $POOL2 <$BACKDIR/inc"
73
74verify_stream_size $BACKDIR/inc $vol 90 $vol@snap
75verify_stream_size $BACKDIR/inc $vol2 90 $vol2@snap
76md5=$(dd iseek=$megs if=$voldev2 bs=1024k count=$megs 2>/dev/null | md5sum | \
77    awk '{print $1}')
78[[ $md5 = $md5_2 ]] || log_fail "md5 mismatch: $md5 != $md5_2"
79
80log_pass "Verify compressed send works with volumes"
81