]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_012_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_receive / zfs_receive_012_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 2016, OmniTI Computer Consulting, Inc. All rights reserved.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 #       refquota, like regular quota, is loosely enforced.  A dataset
26 #       can exceed its refquota by one transaction.  This loose enforcement
27 #       used to cause problems upon receiving a datastream where its
28 #       refquota is slightly exceeded.  This test confirms that we can
29 #       successfully receive a slightly over refquota stream.
30 #
31 # STRATEGY:
32 #       1. Create a filesystem.
33 #       2. Set a refquota.
34 #       3. Snapshot the filesystem.
35 #       4. Send a replication stream to a new filesystem.
36 #       5. On the original filesystem, fill it up to its quota.
37 #       6. Snapshot the original filesystem again.
38 #       7. Send an incremental stream to the same new filesystem.
39 #
40
41 verify_runnable "both"
42
43 typeset streamfile=$TEST_BASE_DIR/streamfile.$$
44
45 function cleanup
46 {
47         log_must rm $streamfile
48         log_must zfs destroy -rf $TESTPOOL/$TESTFS1
49         log_must zfs destroy -rf $TESTPOOL/$TESTFS2
50 }
51
52 log_assert "The allowable slight refquota overage is properly sent-and-" \
53         "received."
54 log_onexit cleanup
55
56 orig=$TESTPOOL/$TESTFS1
57 dest=$TESTPOOL/$TESTFS2
58
59 #       1. Create a filesystem.
60 log_must zfs create $orig
61 origdir=$(get_prop mountpoint $orig)
62
63 #       2. Set a refquota.
64 log_must zfs set refquota=50M $orig
65
66 #       3. Snapshot the filesystem.
67 log_must zfs snapshot $orig@1
68
69 #       4. Send a replication stream to a new filesystem.
70 log_must eval "zfs send -R $orig@1 > $streamfile"
71 log_must eval "zfs recv $dest < $streamfile"
72
73 #       5. On the original filesystem, fill it up to its quota.
74 cat < /dev/urandom > $origdir/fill-it-up
75
76 #       6. Snapshot the original filesystem again.
77 log_must zfs snapshot $orig@2
78
79 #       7. Send an incremental stream to the same new filesystem.
80 log_must eval "zfs send -I 1 -R $orig@2 > $streamfile"
81 log_must eval "zfs recv $dest < $streamfile"
82
83 log_pass "Verified receiving a slightly-over-refquota stream succeeds."