1#!/usr/local/bin/ksh93 -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# __stc_assertion_start
30#
31# ID: userquota_011_pos
32#
33# DESCRIPTION:
34#       the userquota and groupquota will not change during zfs actions, such as
35#	snapshot,clone,rename,upgrade,send,receive.
36#
37#
38# STRATEGY:
39#       1. Create a pool, and create fs with preset user,group quota
40#       2. Check set user|group quota via zfs snapshot|clone|list -o
41#       3. Check the user|group quota can not change during zfs rename|upgrade|promote
42#       4. Check the user|group quota can not change during zfs clone
43#       5. Check the user|group quota can not change during zfs send/receive
44#
45# TESTABILITY: explicit
46#
47# TEST_AUTOMATION_LEVEL: automated
48#
49# CODING STATUS: COMPLETED (2009-04-16)
50#
51# __stc_assertion_end
52#
53###############################################################################
54
55. $STF_SUITE/include/libtest.kshlib
56. $STF_SUITE/tests/userquota/userquota_common.kshlib
57
58function cleanup
59{
60	for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do
61		if datasetexists $ds; then
62			log_must $ZFS destroy -rRf $ds
63		fi
64	done
65}
66
67log_onexit cleanup
68
69log_assert \
70	"the userquota and groupquota can't change during zfs actions"
71
72cleanup
73
74log_must $ZFS create -o userquota@$QUSER1=$UQUOTA_SIZE \
75	-o groupquota@$QGROUP=$GQUOTA_SIZE $TESTPOOL/fs
76
77log_must $ZFS snapshot $TESTPOOL/fs@snap
78log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
79	$TESTPOOL >/dev/null 2>&1"
80
81log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs@snap "$UQUOTA_SIZE"
82log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs@snap "$GQUOTA_SIZE"
83
84
85log_note "clone fs gets its parent's userquota/groupquota initially"
86log_must $ZFS clone  -o userquota@$QUSER1=$UQUOTA_SIZE \
87		-o groupquota@$QGROUP=$GQUOTA_SIZE \
88		$TESTPOOL/fs@snap $TESTPOOL/fs-clone
89
90log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
91	$TESTPOOL >/dev/null 2>&1"
92
93log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE"
94log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE"
95
96log_must eval "$ZFS list -o userquota@$QUSER1,groupquota@$QGROUP \
97	$TESTPOOL/fs-clone >/dev/null 2>&1"
98
99log_note "zfs promote can not change the previously set user|group quota"
100log_must $ZFS promote $TESTPOOL/fs-clone
101
102log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
103	$TESTPOOL >/dev/null 2>&1"
104
105log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE"
106log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE"
107
108log_note "zfs send receive can not change the previously set user|group quota"
109log_must $ZFS send $TESTPOOL/fs-clone@snap | $ZFS receive $TESTPOOL/fs-rev
110
111log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
112	$TESTPOOL >/dev/null 2>&1"
113
114log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rev "$UQUOTA_SIZE"
115log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rev "$GQUOTA_SIZE"
116
117log_note "zfs rename can not change the previously set user|group quota"
118log_must $ZFS rename $TESTPOOL/fs-rev $TESTPOOL/fs-rename
119
120log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
121	$TESTPOOL  >/dev/null 2>&1"
122
123log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rename "$UQUOTA_SIZE"
124log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE"
125
126log_note "zfs upgrade can not change the previously set user|group quota"
127log_must $ZFS upgrade $TESTPOOL/fs-rename
128
129log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
130	$TESTPOOL >/dev/null 2>&1"
131
132log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rename "$UQUOTA_SIZE"
133log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE"
134
135log_pass \
136	"the userquota and groupquota can't change during zfs actions"
137