]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_011_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zfs_receive / zfs_receive_011_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 2015, OmniTI Computer Consulting, Inc. All rights reserved.
19 #
20
21 #
22 # Copyright (c) 2016 by Delphix. All rights reserved.
23 #
24
25 . $STF_SUITE/include/libtest.shlib
26
27 #
28 # DESCRIPTION:
29 #       refquota should be sent-and-received, but it should not interfere with
30 #       the receipt of intermediate snapshots that may have preceded the
31 #       final snapshot, where the refquota should hold.
32 #
33 # STRATEGY:
34 #       1. Create a filesystem.
35 #       2. Create two equal-sized large files.
36 #       3. Snapshot the filesystem.
37 #       4. Remove one of the two large files.
38 #       5. Create a refquota larger than one file, but smaller than both.
39 #       6. Snapshot the filesystem again.
40 #       7. Send a replication stream of the second snapshot to a new filesystem.
41 #
42 #
43
44 verify_runnable "both"
45
46 typeset streamfile=$TEST_BASE_DIR/streamfile.$$
47
48 function cleanup
49 {
50         log_must rm $streamfile
51         log_must zfs destroy -rf $TESTPOOL/$TESTFS1
52         log_must zfs destroy -rf $TESTPOOL/$TESTFS2
53 }
54
55 log_assert "refquota is properly sent-and-received, regardless of any " \
56         "intermediate snapshots sent by a replication stream."
57 log_onexit cleanup
58
59 orig=$TESTPOOL/$TESTFS1
60 dest=$TESTPOOL/$TESTFS2
61 #       1. Create a filesystem.
62 log_must zfs create $orig
63 origdir=$(get_prop mountpoint $orig)
64
65 #       2. Create two equal-sized large files.
66 log_must mkfile 5M $origdir/file1
67 log_must mkfile 5M $origdir/file2
68 log_must sync
69
70 #       3. Snapshot the filesystem.
71 log_must zfs snapshot $orig@1
72
73 #       4. Remove one of the two large files.
74 log_must rm $origdir/file2
75 log_must sync
76
77 #       5. Create a refquota larger than one file, but smaller than both.
78 log_must zfs set refquota=8M $orig
79
80 #       6. Snapshot the filesystem again.
81 log_must zfs snapshot $orig@2
82
83 #       7. Send a replication stream of the second snapshot to a new filesystem.
84 log_must eval "zfs send -R $orig@2 > $streamfile"
85 log_must eval "zfs recv $dest < $streamfile"
86
87 log_pass "refquota is properly sent-and-received, regardless of any " \
88         "intermediate snapshots sent by a replication stream."