xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/projectquota/projectquota_002_pos.ksh (revision f67950b21e185934ccabe311516f4dcbdb00ef79)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27
28#
29# Copyright (c) 2017 by Fan Yong. All rights reserved.
30# Copyright 2019 Joyent, Inc.
31#
32
33. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
34
35#
36# DESCRIPTION:
37#	The project{obj}quota can be set during zpool or zfs creation
38#
39#
40# STRATEGY:
41#	1. Set project{obj}quota via "zpool -O or zfs create -o"
42#
43
44verify_runnable "global"
45
46function cleanup
47{
48	if poolexists $TESTPOOL1; then
49		log_must zpool destroy $TESTPOOL1
50	fi
51
52	if [[ -f $pool_vdev ]]; then
53		rm -f $pool_vdev
54	fi
55}
56
57log_onexit cleanup
58
59log_assert "The project{obj}quota can be set during zpool,zfs creation"
60
61typeset pool_vdev=$TEST_BASE_DIR/pool_dev.$$
62
63log_must mkfile 500m $pool_vdev
64
65if poolexists $TESTPOOL1; then
66	zpool destroy $TESTPOOL1
67fi
68
69log_must zpool create -O projectquota@$PRJID1=$PQUOTA_LIMIT \
70	-O projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL1 $pool_vdev
71
72log_must zfs create -o projectquota@$PRJID1=$PQUOTA_LIMIT \
73	-o projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $TESTPOOL1/fs
74
75log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
76	$TESTPOOL1 > /dev/null 2>&1"
77
78log_must check_quota "projectquota@$PRJID1" $TESTPOOL1 "$PQUOTA_LIMIT"
79log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL1 "$PQUOTA_OBJLIMIT"
80
81log_must eval "zfs list -r -o projectquota@$PRJID1,projectobjquota@$PRJID2 \
82	$TESTPOOL1 > /dev/null 2>&1"
83
84log_must check_quota "projectquota@$PRJID1" $TESTPOOL1/fs "$PQUOTA_LIMIT"
85log_must check_quota "projectobjquota@$PRJID2" $TESTPOOL1/fs "$PQUOTA_OBJLIMIT"
86
87log_pass "The project{obj}quota can be set during zpool,zfs creation"
88