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