]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_clone_livelist.ksh
Update ZTS to work on FreeBSD
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_destroy / zfs_destroy_clone_livelist.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright (c) 2018 by Delphix. All rights reserved.
15 #
16
17 # DESCRIPTION
18 # Verify zfs destroy test for clones with the livelist feature
19 # enabled.
20
21 # STRATEGY
22 # 1. One clone with an empty livelist
23 # - create the clone, check that livelist exists
24 # - delete the clone, check that livelist is eventually
25 # destroyed
26 # 2. One clone with populated livelist
27 # - create the clone, check that livelist exists
28 # - write multiple files to the clone
29 # - delete the clone, check that livelist is eventually
30 # destroyed
31 # 3. Multiple clones with empty livelists
32 # - same as 1. but with multiple clones
33 # 4. Multiple clones with populated livelists
34 # - same as 2. but with multiple clones
35
36 . $STF_SUITE/include/libtest.shlib
37 . $STF_SUITE/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib
38
39 function cleanup
40 {
41 datasetexists $TESTPOOL/$TESTFS1 && zfs destroy -R $TESTPOOL/$TESTFS1
42 # reset the livelist sublist size to its original value
43 set_tunable64 $LIVELIST_MAX_ENTRIES $ORIGINAL_MAX
44 }
45
46 function clone_write_file
47 {
48 log_must mkfile 1m /$TESTPOOL/$1/$2
49 log_must zpool sync $TESTPOOL
50 }
51
52 function test_one_empty
53 {
54 clone_dataset $TESTFS1 snap $TESTCLONE
55
56 log_must zfs destroy $TESTPOOL/$TESTCLONE
57 check_livelist_gone
58 }
59
60 function test_one
61 {
62 clone_dataset $TESTFS1 snap $TESTCLONE
63
64 clone_write_file $TESTCLONE $TESTFILE0
65 clone_write_file $TESTCLONE $TESTFILE1
66 clone_write_file $TESTCLONE $TESTFILE2
67 log_must rm /$TESTPOOL/$TESTCLONE/$TESTFILE0
68 log_must rm /$TESTPOOL/$TESTCLONE/$TESTFILE2
69 check_livelist_exists $TESTCLONE
70
71 log_must zfs destroy $TESTPOOL/$TESTCLONE
72 check_livelist_gone
73 }
74
75 function test_multiple_empty
76 {
77 clone_dataset $TESTFS1 snap $TESTCLONE
78 clone_dataset $TESTFS1 snap $TESTCLONE1
79 clone_dataset $TESTFS1 snap $TESTCLONE2
80
81 log_must zfs destroy $TESTPOOL/$TESTCLONE
82 log_must zfs destroy $TESTPOOL/$TESTCLONE1
83 log_must zfs destroy $TESTPOOL/$TESTCLONE2
84 check_livelist_gone
85 }
86
87 function test_multiple
88 {
89 clone_dataset $TESTFS1 snap $TESTCLONE
90 clone_dataset $TESTFS1 snap $TESTCLONE1
91 clone_dataset $TESTFS1 snap $TESTCLONE2
92
93 clone_write_file $TESTCLONE $TESTFILE0
94
95 clone_write_file $TESTCLONE1 $TESTFILE0
96 clone_write_file $TESTCLONE1 $TESTFILE1
97 clone_write_file $TESTCLONE1 $TESTFILE2
98
99 clone_write_file $TESTCLONE2 $TESTFILE0
100 log_must rm /$TESTPOOL/$TESTCLONE2/$TESTFILE0
101 clone_write_file $TESTCLONE2 $TESTFILE1
102 log_must rm /$TESTPOOL/$TESTCLONE2/$TESTFILE1
103
104 check_livelist_exists $TESTCLONE
105 check_livelist_exists $TESTCLONE1
106 check_livelist_exists $TESTCLONE2
107
108 log_must zfs destroy $TESTPOOL/$TESTCLONE
109 log_must zfs destroy $TESTPOOL/$TESTCLONE1
110 log_must zfs destroy $TESTPOOL/$TESTCLONE2
111 check_livelist_gone
112 }
113
114 function test_promote
115 {
116 clone_dataset $TESTFS1 snap $TESTCLONE
117
118 log_must zfs promote $TESTPOOL/$TESTCLONE
119 check_livelist_gone
120 log_must zfs destroy -R $TESTPOOL/$TESTCLONE
121 }
122
123 ORIGINAL_MAX=$(get_tunable $LIVELIST_MAX_ENTRIES)
124
125 log_onexit cleanup
126 log_must zfs create $TESTPOOL/$TESTFS1
127 log_must mkfile 20m /$TESTPOOL/$TESTFS1/atestfile
128 log_must zfs snapshot $TESTPOOL/$TESTFS1@snap
129
130 # set a small livelist entry size to more easily test multiple entry livelists
131 set_tunable64 $LIVELIST_MAX_ENTRIES 20
132
133 test_one_empty
134 test_one
135 test_multiple_empty
136 test_multiple
137 test_promote
138
139 log_pass "Clone with the livelist feature enabled could be destroyed," \
140 "also could be promoted and destroyed as expected."