xref: /freebsd/tests/sys/cddl/zfs/tests/userquota/userquota_test.sh (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1# CDDL HEADER START
2#
3# The contents of this file are subject to the terms of the
4# Common Development and Distribution License (the "License").
5# You may not use this file except in compliance with the License.
6#
7# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8# or http://www.opensolaris.org/os/licensing.
9# See the License for the specific language governing permissions
10# and limitations under the License.
11#
12# When distributing Covered Code, include this CDDL HEADER in each
13# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14# If applicable, add the following below this CDDL HEADER, with the
15# fields enclosed by brackets "[]" replaced with your own identifying
16# information: Portions Copyright [yyyy] [name of copyright owner]
17#
18# CDDL HEADER END
19#
20
21# $FreeBSD$
22
23#
24# Copyright 2012 Spectra Logic.  All rights reserved.
25# Use is subject to license terms.
26#
27
28
29atf_test_case groupspace_001_pos cleanup
30groupspace_001_pos_head()
31{
32	atf_set "descr" "Check the zfs groupspace with all possible parameters"
33	atf_set "require.progs" "ksh93 zfs runwattr"
34}
35groupspace_001_pos_body()
36{
37	. $(atf_get_srcdir)/../../include/default.cfg
38	. $(atf_get_srcdir)/userquota_common.kshlib
39	. $(atf_get_srcdir)/userquota.cfg
40
41	verify_disk_count "$DISKS" 1
42	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
43	ksh93 $(atf_get_srcdir)/groupspace_001_pos.ksh || atf_fail "Testcase failed"
44}
45groupspace_001_pos_cleanup()
46{
47	. $(atf_get_srcdir)/../../include/default.cfg
48	. $(atf_get_srcdir)/userquota_common.kshlib
49	. $(atf_get_srcdir)/userquota.cfg
50
51	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
52}
53
54
55atf_test_case groupspace_002_pos cleanup
56groupspace_002_pos_head()
57{
58	atf_set "descr" "Check the zfs groupspace used and quota"
59	atf_set "require.progs" "ksh93 zfs runwattr"
60}
61groupspace_002_pos_body()
62{
63	. $(atf_get_srcdir)/../../include/default.cfg
64	. $(atf_get_srcdir)/userquota_common.kshlib
65	. $(atf_get_srcdir)/userquota.cfg
66
67	verify_disk_count "$DISKS" 1
68	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
69	ksh93 $(atf_get_srcdir)/groupspace_002_pos.ksh || atf_fail "Testcase failed"
70}
71groupspace_002_pos_cleanup()
72{
73	. $(atf_get_srcdir)/../../include/default.cfg
74	. $(atf_get_srcdir)/userquota_common.kshlib
75	. $(atf_get_srcdir)/userquota.cfg
76
77	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
78}
79
80
81atf_test_case userquota_001_pos cleanup
82userquota_001_pos_head()
83{
84	atf_set "descr" "If write operation overwrite {user|group}quota size, it will fail"
85	atf_set "require.progs" "ksh93 zfs runwattr"
86}
87userquota_001_pos_body()
88{
89	. $(atf_get_srcdir)/../../include/default.cfg
90	. $(atf_get_srcdir)/userquota_common.kshlib
91	. $(atf_get_srcdir)/userquota.cfg
92
93	verify_disk_count "$DISKS" 1
94	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
95	ksh93 $(atf_get_srcdir)/userquota_001_pos.ksh || atf_fail "Testcase failed"
96}
97userquota_001_pos_cleanup()
98{
99	. $(atf_get_srcdir)/../../include/default.cfg
100	. $(atf_get_srcdir)/userquota_common.kshlib
101	. $(atf_get_srcdir)/userquota.cfg
102
103	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
104}
105
106
107atf_test_case userquota_002_pos cleanup
108userquota_002_pos_head()
109{
110	atf_set "descr" "the userquota and groupquota can be set during zpool,zfs creation"
111	atf_set "require.progs" "ksh93 zpool zfs"
112}
113userquota_002_pos_body()
114{
115	. $(atf_get_srcdir)/../../include/default.cfg
116	. $(atf_get_srcdir)/userquota_common.kshlib
117	. $(atf_get_srcdir)/userquota.cfg
118
119	verify_disk_count "$DISKS" 1
120	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
121	ksh93 $(atf_get_srcdir)/userquota_002_pos.ksh || atf_fail "Testcase failed"
122}
123userquota_002_pos_cleanup()
124{
125	. $(atf_get_srcdir)/../../include/default.cfg
126	. $(atf_get_srcdir)/userquota_common.kshlib
127	. $(atf_get_srcdir)/userquota.cfg
128
129	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
130}
131
132
133atf_test_case userquota_003_pos cleanup
134userquota_003_pos_head()
135{
136	atf_set "descr" "Check the basic function of set/get userquota and groupquota on fs"
137	atf_set "require.progs" "ksh93 zfs"
138}
139userquota_003_pos_body()
140{
141	. $(atf_get_srcdir)/../../include/default.cfg
142	. $(atf_get_srcdir)/userquota_common.kshlib
143	. $(atf_get_srcdir)/userquota.cfg
144
145	verify_disk_count "$DISKS" 1
146	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
147	ksh93 $(atf_get_srcdir)/userquota_003_pos.ksh || atf_fail "Testcase failed"
148}
149userquota_003_pos_cleanup()
150{
151	. $(atf_get_srcdir)/../../include/default.cfg
152	. $(atf_get_srcdir)/userquota_common.kshlib
153	. $(atf_get_srcdir)/userquota.cfg
154
155	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
156}
157
158
159atf_test_case userquota_004_pos cleanup
160userquota_004_pos_head()
161{
162	atf_set "descr" "Check the basic function of {user|group} used"
163	atf_set "require.progs" "ksh93 runwattr"
164}
165userquota_004_pos_body()
166{
167	. $(atf_get_srcdir)/../../include/default.cfg
168	. $(atf_get_srcdir)/userquota_common.kshlib
169	. $(atf_get_srcdir)/userquota.cfg
170
171	verify_disk_count "$DISKS" 1
172	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
173	ksh93 $(atf_get_srcdir)/userquota_004_pos.ksh || atf_fail "Testcase failed"
174}
175userquota_004_pos_cleanup()
176{
177	. $(atf_get_srcdir)/../../include/default.cfg
178	. $(atf_get_srcdir)/userquota_common.kshlib
179	. $(atf_get_srcdir)/userquota.cfg
180
181	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
182}
183
184
185atf_test_case userquota_005_neg cleanup
186userquota_005_neg_head()
187{
188	atf_set "descr" "Check the invalid parameter of zfs set user|group quota"
189	atf_set "require.progs" "ksh93 zfs"
190}
191userquota_005_neg_body()
192{
193	. $(atf_get_srcdir)/../../include/default.cfg
194	. $(atf_get_srcdir)/userquota_common.kshlib
195	. $(atf_get_srcdir)/userquota.cfg
196
197	verify_disk_count "$DISKS" 1
198	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
199	ksh93 $(atf_get_srcdir)/userquota_005_neg.ksh || atf_fail "Testcase failed"
200}
201userquota_005_neg_cleanup()
202{
203	. $(atf_get_srcdir)/../../include/default.cfg
204	. $(atf_get_srcdir)/userquota_common.kshlib
205	. $(atf_get_srcdir)/userquota.cfg
206
207	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
208}
209
210
211atf_test_case userquota_006_pos cleanup
212userquota_006_pos_head()
213{
214	atf_set "descr" "Check the invalid parameter of zfs get user|group quota"
215	atf_set "require.progs" "ksh93 zfs"
216}
217userquota_006_pos_body()
218{
219	. $(atf_get_srcdir)/../../include/default.cfg
220	. $(atf_get_srcdir)/userquota_common.kshlib
221	. $(atf_get_srcdir)/userquota.cfg
222
223	verify_disk_count "$DISKS" 1
224	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
225	ksh93 $(atf_get_srcdir)/userquota_006_pos.ksh || atf_fail "Testcase failed"
226}
227userquota_006_pos_cleanup()
228{
229	. $(atf_get_srcdir)/../../include/default.cfg
230	. $(atf_get_srcdir)/userquota_common.kshlib
231	. $(atf_get_srcdir)/userquota.cfg
232
233	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
234}
235
236
237atf_test_case userquota_007_pos cleanup
238userquota_007_pos_head()
239{
240	atf_set "descr" "Check set user|group quota to larger than the quota size of a fs"
241	atf_set "require.progs" "ksh93 zfs runwattr"
242}
243userquota_007_pos_body()
244{
245	. $(atf_get_srcdir)/../../include/default.cfg
246	. $(atf_get_srcdir)/userquota_common.kshlib
247	. $(atf_get_srcdir)/userquota.cfg
248
249	verify_disk_count "$DISKS" 1
250	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
251	ksh93 $(atf_get_srcdir)/userquota_007_pos.ksh || atf_fail "Testcase failed"
252}
253userquota_007_pos_cleanup()
254{
255	. $(atf_get_srcdir)/../../include/default.cfg
256	. $(atf_get_srcdir)/userquota_common.kshlib
257	. $(atf_get_srcdir)/userquota.cfg
258
259	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
260}
261
262
263atf_test_case userquota_008_pos cleanup
264userquota_008_pos_head()
265{
266	atf_set "descr" "Check zfs get all will not print out user|group quota"
267	atf_set "require.progs" "ksh93 zfs"
268}
269userquota_008_pos_body()
270{
271	. $(atf_get_srcdir)/../../include/default.cfg
272	. $(atf_get_srcdir)/userquota_common.kshlib
273	. $(atf_get_srcdir)/userquota.cfg
274
275	verify_disk_count "$DISKS" 1
276	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
277	ksh93 $(atf_get_srcdir)/userquota_008_pos.ksh || atf_fail "Testcase failed"
278}
279userquota_008_pos_cleanup()
280{
281	. $(atf_get_srcdir)/../../include/default.cfg
282	. $(atf_get_srcdir)/userquota_common.kshlib
283	. $(atf_get_srcdir)/userquota.cfg
284
285	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
286}
287
288
289atf_test_case userquota_009_pos cleanup
290userquota_009_pos_head()
291{
292	atf_set "descr" "Check the snapshot's user|group quota"
293	atf_set "require.progs" "ksh93 zfs"
294}
295userquota_009_pos_body()
296{
297	. $(atf_get_srcdir)/../../include/default.cfg
298	. $(atf_get_srcdir)/userquota_common.kshlib
299	. $(atf_get_srcdir)/userquota.cfg
300
301	verify_disk_count "$DISKS" 1
302	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
303	ksh93 $(atf_get_srcdir)/userquota_009_pos.ksh || atf_fail "Testcase failed"
304}
305userquota_009_pos_cleanup()
306{
307	. $(atf_get_srcdir)/../../include/default.cfg
308	. $(atf_get_srcdir)/userquota_common.kshlib
309	. $(atf_get_srcdir)/userquota.cfg
310
311	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
312}
313
314
315atf_test_case userquota_010_pos cleanup
316userquota_010_pos_head()
317{
318	atf_set "descr" "overwrite any of the {user|group}quota size, it will fail"
319	atf_set "require.progs" "ksh93 zfs runwattr"
320}
321userquota_010_pos_body()
322{
323	. $(atf_get_srcdir)/../../include/default.cfg
324	. $(atf_get_srcdir)/userquota_common.kshlib
325	. $(atf_get_srcdir)/userquota.cfg
326
327	verify_disk_count "$DISKS" 1
328	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
329	ksh93 $(atf_get_srcdir)/userquota_010_pos.ksh || atf_fail "Testcase failed"
330}
331userquota_010_pos_cleanup()
332{
333	. $(atf_get_srcdir)/../../include/default.cfg
334	. $(atf_get_srcdir)/userquota_common.kshlib
335	. $(atf_get_srcdir)/userquota.cfg
336
337	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
338}
339
340
341atf_test_case userquota_011_pos cleanup
342userquota_011_pos_head()
343{
344	atf_set "descr" "the userquota and groupquota can't change during zfs actions"
345	atf_set "require.progs" "ksh93 zfs"
346}
347userquota_011_pos_body()
348{
349	. $(atf_get_srcdir)/../../include/default.cfg
350	. $(atf_get_srcdir)/userquota_common.kshlib
351	. $(atf_get_srcdir)/userquota.cfg
352
353	verify_disk_count "$DISKS" 1
354	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
355	ksh93 $(atf_get_srcdir)/userquota_011_pos.ksh || atf_fail "Testcase failed"
356}
357userquota_011_pos_cleanup()
358{
359	. $(atf_get_srcdir)/../../include/default.cfg
360	. $(atf_get_srcdir)/userquota_common.kshlib
361	. $(atf_get_srcdir)/userquota.cfg
362
363	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
364}
365
366
367atf_test_case userquota_012_neg cleanup
368userquota_012_neg_head()
369{
370	atf_set "descr" "Check  set userquota and groupquota on snapshot"
371	atf_set "require.progs" "ksh93 zfs"
372}
373userquota_012_neg_body()
374{
375	. $(atf_get_srcdir)/../../include/default.cfg
376	. $(atf_get_srcdir)/userquota_common.kshlib
377	. $(atf_get_srcdir)/userquota.cfg
378
379	verify_disk_count "$DISKS" 1
380	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
381	ksh93 $(atf_get_srcdir)/userquota_012_neg.ksh || atf_fail "Testcase failed"
382}
383userquota_012_neg_cleanup()
384{
385	. $(atf_get_srcdir)/../../include/default.cfg
386	. $(atf_get_srcdir)/userquota_common.kshlib
387	. $(atf_get_srcdir)/userquota.cfg
388
389	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
390}
391
392
393atf_test_case userspace_001_pos cleanup
394userspace_001_pos_head()
395{
396	atf_set "descr" "Check the zfs userspace with all possible parameters"
397	atf_set "require.progs" "ksh93 zfs runwattr"
398}
399userspace_001_pos_body()
400{
401	. $(atf_get_srcdir)/../../include/default.cfg
402	. $(atf_get_srcdir)/userquota_common.kshlib
403	. $(atf_get_srcdir)/userquota.cfg
404
405	verify_disk_count "$DISKS" 1
406	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
407	ksh93 $(atf_get_srcdir)/userspace_001_pos.ksh || atf_fail "Testcase failed"
408}
409userspace_001_pos_cleanup()
410{
411	. $(atf_get_srcdir)/../../include/default.cfg
412	. $(atf_get_srcdir)/userquota_common.kshlib
413	. $(atf_get_srcdir)/userquota.cfg
414
415	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
416}
417
418
419atf_test_case userspace_002_pos cleanup
420userspace_002_pos_head()
421{
422	atf_set "descr" "Check the zfs userspace used and quota"
423	atf_set "require.progs" "ksh93 zfs runwattr"
424}
425userspace_002_pos_body()
426{
427	. $(atf_get_srcdir)/../../include/default.cfg
428	. $(atf_get_srcdir)/userquota_common.kshlib
429	. $(atf_get_srcdir)/userquota.cfg
430
431	verify_disk_count "$DISKS" 1
432	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
433	ksh93 $(atf_get_srcdir)/userspace_002_pos.ksh || atf_fail "Testcase failed"
434}
435userspace_002_pos_cleanup()
436{
437	. $(atf_get_srcdir)/../../include/default.cfg
438	. $(atf_get_srcdir)/userquota_common.kshlib
439	. $(atf_get_srcdir)/userquota.cfg
440
441	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
442}
443
444
445atf_init_test_cases()
446{
447
448	atf_add_test_case groupspace_001_pos
449	atf_add_test_case groupspace_002_pos
450	atf_add_test_case userquota_001_pos
451	atf_add_test_case userquota_002_pos
452	atf_add_test_case userquota_003_pos
453	atf_add_test_case userquota_004_pos
454	atf_add_test_case userquota_005_neg
455	atf_add_test_case userquota_006_pos
456	atf_add_test_case userquota_007_pos
457	atf_add_test_case userquota_008_pos
458	atf_add_test_case userquota_009_pos
459	atf_add_test_case userquota_010_pos
460	atf_add_test_case userquota_011_pos
461	atf_add_test_case userquota_012_neg
462	atf_add_test_case userspace_001_pos
463	atf_add_test_case userspace_002_pos
464}
465