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