Permalink
Browse files

added refquota test script ans setup.ksh for refreserv test script

added modified command.cfg (ex. /usr/local/sbin/zpool)
  • Loading branch information...
1 parent 8ab8bfd commit e51c2b674dd568d578fd6a94701748f76e89833c @shrirang shrirang committed Nov 22, 2010
@@ -126,13 +126,13 @@ export USERDEL=/usr/sbin/userdel
export USERMOD=/usr/sbin/usermod
export WAIT=wait
export WC=/usr/bin/wc
-export ZFS=/sbin/zfs
-export ZPOOL=/sbin/zpool
+export ZFS=/usr/local/sbin/zfs
+export ZPOOL=/usr/local/sbin/zpool
export ZONEADM=
export ZONECFG=
export ZLOGIN=
export ZONENAME=
-export ZDB=/sbin/zdb
+export ZDB=/usr/local/sbin/zdb
export RUNWATTR=
export MD5SUM=/bin/md5osum
export CMDS="\
@@ -0,0 +1,47 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "@(#)Makefile 1.1 08/02/27 SMI"
+#
+
+STF_USER_CONFIGURE=
+STF_ROOT_CONFIGURE=
+
+STF_ROOT_SETUP=setup
+STF_USER_SETUP=
+
+STF_ROOT_CLEANUP=cleanup
+STF_USER_CLEANUP=
+
+STF_ROOT_TESTCASES=refquota_001_pos refquota_002_pos refquota_003_pos \
+ refquota_004_pos refquota_005_pos refquota_006_neg
+STF_USER_TESTCASES=
+
+STF_ENVFILES=refquota.cfg
+STF_INCLUDES=
+
+STF_DONTBUILDMODES=true
+
+include $(STF_TOOLS)/Makefiles/Makefile.master
@@ -0,0 +1,40 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "@(#)cleanup.ksh 1.1 08/02/27 SMI"
+#
+
+. $STF_SUITE/include/libtest.kshlib
+. $STF_SUITE/commands.cfg
+. $STF_SUITE/include/default_common_varible.kshlib
+. $STF_TOOLS/contrib/include/logapi.kshlib
+
+#verify_runnable "both"
+#if ! fs_prop_exist "refquota" ; then
+# log_unsupported "refquota is not supported by this release."
+#fi
+
+default_cleanup
@@ -0,0 +1,29 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "@(#)refquota.cfg 1.2 08/08/15 SMI"
+#
+
+export TESTFILE=testfile$$
@@ -0,0 +1,97 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "@(#)refquota_001_pos.ksh 1.1 08/02/27 SMI"
+#
+
+. $STF_SUITE/include/libtest.kshlib
+. $STF_SUITE/commands.cfg
+. $STF_SUITE/tests/functional/refquota/refquota.cfg
+. $STF_SUITE/include/default_common_varible.kshlib
+
+#################################################################################
+#
+# __stc_assertion_start
+#
+# ID: refquota_001_pos
+#
+# DESCRIPTION:
+# refquota limits the amount of space a dataset can consume, but does
+# not include space used by descendents.
+#
+# STRATEGY:
+# 1. Setting refquota in given filesystem
+# 2. Create descendent filesystem
+# 3. Verify refquota limits the amount of space a dataset can consume
+# 4. Verify the limit does not impact descendents
+#
+# TESTABILITY: explicit
+#
+# TEST_AUTOMATION_LEVEL: automated
+#
+# CODING_STATUS: COMPLETED (2007-12-13)
+#
+# __stc_assertion_end
+#
+################################################################################
+
+verify_runnable "both"
+
+function cleanup
+{
+ log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
+ log_must $ZFS create $TESTPOOL/$TESTFS
+ log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
+}
+
+log_assert "refquota limits the amount of space a dataset can consume, " \
+ "but does not include space used by descendents."
+log_onexit cleanup
+
+fs=$TESTPOOL/$TESTFS
+sub=$fs/sub
+log_must $ZFS create $sub
+
+log_must $ZFS set refquota=10M $fs
+mntpnt=$(get_prop mountpoint $fs)
+
+#log_mustnot $MKFILE 11M $mntpnt/file
+log_mustnot $DD if=/dev/zero of=$mntpnt/file bs=1M count=11
+#log_must $MKFILE 9M $mntpnt/file
+log_must $DD if=/dev/zero of=$mntpnt/file bs=1M count=9
+log_must $ZFS snapshot $fs@snap
+#log_mustnot $MKFILE 2M $mntpnt/file2
+log_mustnot $DD if=/dev/zero of=$mntpnt/file2 bs=1M count=2
+
+mntpnt=$(get_prop mountpoint $sub)
+#log_must $MKFILE 10M $mntpnt/file
+log_must $DD if=/dev/zero of=$mntpnt/file bs=1M count=10
+log_must $ZFS snapshot $sub@snap
+#log_must $MKFILE 10 $mntpnt/file2
+log_must $DD if=/dev/zero of=$mntpnt/file2 bs=1M count=10
+
+log_pass "refquota limits the amount of space a dataset can consume, " \
+ "but does not include space used by descendents."
@@ -0,0 +1,106 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "@(#)refquota_002_pos.ksh 1.1 08/02/27 SMI"
+#
+
+. $STF_SUITE/include/libtest.kshlib
+. $STF_SUITE/commands.cfg
+. $STF_SUITE/tests/functional/refquota/refquota.cfg
+. $STF_SUITE/include/default_common_varible.kshlib
+
+#################################################################################
+#
+# __stc_assertion_start
+#
+# ID: refquota_002_pos
+#
+# DESCRIPTION:
+# Quotas are enforced using the minimum of the two properties:
+# quota & refquota
+#
+# STRATEGY:
+# 1. Set value for quota and refquota. Quota less than refquota.
+# 2. Creating file which should be limited by quota.
+# 3. Switch the value of quota and refquota.
+# 4. Verify file should be limited by refquota.
+#
+# TESTABILITY: explicit
+#
+# TEST_AUTOMATION_LEVEL: automated
+#
+# CODING_STATUS: COMPLETED (2007-11-02)
+#
+# __stc_assertion_end
+#
+################################################################################
+
+verify_runnable "both"
+
+function cleanup
+{
+ log_must $ZFS destroy -rf $TESTPOOL/$TESTFS
+ log_must $ZFS create $TESTPOOL/$TESTFS
+ log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
+}
+
+log_assert "Quotas are enforced using the minimum of the two properties"
+log_onexit cleanup
+
+fs=$TESTPOOL/$TESTFS
+log_must $ZFS set quota=15M $fs
+log_must $ZFS set refquota=25M $fs
+
+mntpnt=$(get_prop mountpoint $fs)
+#log_mustnot $MKFILE 20M $mntpnt/$TESTFILE
+log_mustnot $DD if=/dev/zero of=$mntpnt/$TESTFILE bs=1M count=20
+typeset -i used quota
+used=$(get_prop used $fs)
+quota=$(get_prop quota $fs)
+((used = used / (1024 * 1024)))
+((quota = quota / (1024 * 1024)))
+if [[ $used -ne $quota ]]; then
+ log_fail "ERROR: $used -ne $quota Quotas are not limited by quota"
+fi
+
+#
+# Switch the value of them and try again
+#
+log_must $RM $mntpnt/$TESTFILE
+log_must $ZFS set quota=25M $fs
+log_must $ZFS set refquota=15M $fs
+
+#log_mustnot $MKFILE 20M $mntpnt/$TESTFILE
+log_mustnot $DD if=/dev/zero of=$mntpnt/$TESTFILE bs=1M count=20
+used=$(get_prop used $fs)
+refquota=$(get_prop refquota $fs)
+((used = used / (1024 * 1024)))
+((refquota = refquota / (1024 * 1024)))
+if [[ $used -ne $refquota ]]; then
+ log_fail "ERROR: $used -ne $refquota Quotas are not limited by refquota"
+fi
+
+log_pass "Quotas are enforced using the minimum of the two properties"
Oops, something went wrong.

0 comments on commit e51c2b6

Please sign in to comment.