]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/rsend/send-c_volume.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / rsend / send-c_volume.ksh
1 #!/bin/ksh -p
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
30 function cleanup
31 {
32         log_must_busy zfs destroy -r $vol
33         cleanup_pool $POOL2
34 }
35
36 verify_runnable "both"
37
38 log_assert "Verify compressed send works with volumes"
39 log_onexit cleanup
40
41 typeset vol="$POOL/newvol"
42 typeset vol2="$POOL2/newvol"
43 typeset voldev="$ZVOL_DEVDIR/$POOL/newvol"
44 typeset voldev2="$ZVOL_DEVDIR/$POOL2/newvol"
45 typeset data1=$BACKDIR/file.0
46 typeset data2=$BACKDIR/file.1
47 typeset megs=8
48
49 log_must zfs create -V 256m -o compress=lz4 $vol
50
51 write_compressible $BACKDIR ${megs}m 2
52 md5_1=$(md5digest $data1)
53 md5_2=$(md5digest $data2)
54
55 log_must dd if=$data1 of=$voldev bs=1024k
56 log_must zfs snapshot $vol@snap
57
58 log_must eval "zfs send -c $vol@snap >$BACKDIR/full"
59 log_must eval "zfs recv -d $POOL2 <$BACKDIR/full"
60
61 verify_stream_size $BACKDIR/full $vol
62 verify_stream_size $BACKDIR/full $vol2
63 md5=$(dd if=$voldev2 bs=1024k count=$megs 2>/dev/null | md5digest)
64 [[ $md5 = $md5_1 ]] || log_fail "md5 mismatch: $md5 != $md5_1"
65
66 # Repeat, for an incremental send
67 log_must dd seek=$megs if=$data2 of=$voldev bs=1024k
68 log_must zfs snapshot $vol@snap2
69
70 log_must eval "zfs send -c -i snap $vol@snap2 >$BACKDIR/inc"
71 log_must eval "zfs recv -d $POOL2 <$BACKDIR/inc"
72
73 verify_stream_size $BACKDIR/inc $vol 90 $vol@snap
74 verify_stream_size $BACKDIR/inc $vol2 90 $vol2@snap
75 md5=$(dd skip=$megs if=$voldev2 bs=1024k count=$megs 2>/dev/null | md5digest)
76 [[ $md5 = $md5_2 ]] || log_fail "md5 mismatch: $md5 != $md5_2"
77
78 log_pass "Verify compressed send works with volumes"