Skip to content

Commit

Permalink
I have ported userquota script
Browse files Browse the repository at this point in the history
  • Loading branch information
vikramjadhav committed Dec 22, 2010
1 parent a54d993 commit 32d1463
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 23 deletions.
11 changes: 6 additions & 5 deletions ZFS-Test_Suite/tests/functional/userquota/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
#fi

log_must cleanup_quota
log_must clean_user_group

typeset mntp=$(get_prop mountpoint $QFS)
log_must $CHMOD 0755 $mntp

#typeset mntp=$(get_prop mountpoint $QFS)
#log_must $CHMOD 0755 $mntp
log_must $USERDEL $QUSER1
log_must $USERDEL $QUSER2
log_must $GROUPDEL $QGROUP
default_cleanup

7 changes: 5 additions & 2 deletions ZFS-Test_Suite/tests/functional/userquota/groupspace_001_pos
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
# __stc_assertion_end
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib


function cleanup
{
if datasetexists $snap_fs; then
Expand Down Expand Up @@ -82,7 +84,8 @@ typeset snap_fs=$QFS@snap

log_must $ZFS set groupquota@$QGROUP=500m $QFS
mkmount_writable $QFS
log_must user_run $QUSER1 $MKFILE 50m $QFILE
#log_must user_run $QUSER1 $MKFILE 50m $QFILE
log_must user_run $QUSER1 $DD if=/dev/urandom of=$QFILE bs=1M count=50

$SYNC

Expand Down
6 changes: 5 additions & 1 deletion ZFS-Test_Suite/tests/functional/userquota/groupspace_002_pos
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib


function cleanup
{
if datasetexists $snapfs; then
Expand All @@ -69,7 +72,8 @@ log_assert "Check the zfs groupspace used and quota"

log_must $ZFS set groupquota@$QGROUP=500m $QFS
mkmount_writable $QFS
log_must user_run $QUSER1 $MKFILE 100m $QFILE
#log_must user_run $QUSER1 $MKFILE 100m $QFILE
log_must user_run $QUSER1 $DD if=/dev/urandom of=$QFILE bs=1M count=100

$SYNC

Expand Down
10 changes: 10 additions & 0 deletions ZFS-Test_Suite/tests/functional/userquota/setup
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
#fi

#log_must clean_user_group
if [ $(id -u) != 0 ]; then
echo "You Must run as root"
exit 1
fi

if [ $# != 1 ]
then
echo "USAGE: ./setup disk"
exit 1;
fi

log_must add_group $QGROUP
echo " add_group done "
Expand Down
4 changes: 2 additions & 2 deletions ZFS-Test_Suite/tests/functional/userquota/userquota.cfg
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export UQUOTA_SIZE=1000000
export GQUOTA_SIZE=4000000

export QFS=$TESTPOOL/$TESTFS
export QFILE=$TESTDIR/qf.$$
export OFILE=$TESTDIR/of.$$
export QFILE=$TESTDIR/qfile.$$
export OFILE=$TESTDIR/ofile.$$

export SNAP_QUOTA=100m
export TEST_QUOTA=88888
Expand Down
6 changes: 5 additions & 1 deletion ZFS-Test_Suite/tests/functional/userquota/userquota_002_pos
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib


verify_runnable "global"

function cleanup
Expand All @@ -73,7 +76,8 @@ log_assert \

typeset pool_vdev=/var/tmp/pool_dev.$$

log_must $MKFILE 500m $pool_vdev
#log_must $MKFILE 500m $pool_vdev
log_must $DD if=/dev/urandom of=$pool_vdev bs=1M count=500

if poolexists $TESTPOOL1; then
$ZPOOL destroy $TESTPOOL1
Expand Down
3 changes: 3 additions & 0 deletions ZFS-Test_Suite/tests/functional/userquota/userquota_003_pos
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#
###############################################################################


. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

Expand Down
5 changes: 5 additions & 0 deletions ZFS-Test_Suite/tests/functional/userquota/userquota_006_pos
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@
#
###############################################################################


. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

###############################################################################

function cleanup
{
if datasetexists $snap_fs; then
Expand Down
7 changes: 6 additions & 1 deletion ZFS-Test_Suite/tests/functional/userquota/userquota_007_pos
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

###############################################################################


function cleanup
{
log_must cleanup_quota
Expand All @@ -74,7 +79,7 @@ log_must $ZFS get groupquota@$QGROUP $QFS

log_note "write some data to the $QFS"
mkmount_writable $QFS
log_must user_run $QUSER1 $MKFILE 100m $QFILE
log_must user_run $QUSER1 $DD if=/dev/urandom of=$QFILE bs=1M count=100
$SYNC

log_note "set user|group quota at a smaller size than it current usage"
Expand Down
5 changes: 5 additions & 0 deletions ZFS-Test_Suite/tests/functional/userquota/userquota_008_pos
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@
#
###############################################################################


. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

###############################################################################

function cleanup
{
log_must cleanup_quota
Expand Down
4 changes: 4 additions & 0 deletions ZFS-Test_Suite/tests/functional/userquota/userquota_009_pos
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

###############################################################################

function cleanup
{
if datasetexists $snap_fs; then
Expand Down
21 changes: 18 additions & 3 deletions ZFS-Test_Suite/tests/functional/userquota/userquota_011_pos
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@
# __stc_assertion_end
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

###############################################################################

function cleanup
{
for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do
Expand All @@ -73,10 +76,11 @@ log_assert \
"the userquota and groupquota can't change during zfs actions"

cleanup

####Create a pool, and create fs with preset user,group quota
log_must $ZFS create -o userquota@$QUSER1=$UQUOTA_SIZE \
-o groupquota@$QGROUP=$GQUOTA_SIZE $TESTPOOL/fs

####Check set user|group quota via zfs snapshot|clone|list -o
log_must $ZFS snapshot $TESTPOOL/fs@snap
log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
$TESTPOOL >/dev/null 2>&1"
Expand All @@ -99,6 +103,7 @@ log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE"
log_must eval "$ZFS list -o userquota@$QUSER1,groupquota@$QGROUP \
$TESTPOOL/fs-clone >/dev/null 2>&1"

#### Check the user|group quota can not change during zfs rename|upgrade|promote
log_note "zfs promote can not change the previously set user|group quota"
log_must $ZFS promote $TESTPOOL/fs-clone

Expand All @@ -109,14 +114,23 @@ log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-clone "$UQUOTA_SIZE"
log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-clone "$GQUOTA_SIZE"

log_note "zfs send receive can not change the previously set user|group quota"
log_must $ZFS send $TESTPOOL/fs-clone@snap | $ZFS receive $TESTPOOL/fs-rev
#log_must $ZFS send $TESTPOOL/fs-clone@snap | $ZFS receive $TESTPOOL/fs-rev


log_must eval "$ZFS send $TESTPOOL/fs-clone@snap | $ZFS receive $TESTPOOL/fs-rev"

#$tmpfile=/tmp/tmp$$
#log_must $ZFS send $TESTPOOL/fs-clone@snap > $tmpfile
#log_must $ZFS receive $TESTPOOL/fs-rev < $tmpfile
#rm -rf $tmpfile

log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
$TESTPOOL >/dev/null 2>&1"

log_must check_quota "userquota@$QUSER1" $TESTPOOL/fs-rev "$UQUOTA_SIZE"
log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rev "$GQUOTA_SIZE"


log_note "zfs rename can not change the previously set user|group quota"
log_must $ZFS rename $TESTPOOL/fs-rev $TESTPOOL/fs-rename

Expand All @@ -137,3 +151,4 @@ log_must check_quota "groupquota@$QGROUP" $TESTPOOL/fs-rename "$GQUOTA_SIZE"

log_pass \
"the userquota and groupquota can't change during zfs actions"

6 changes: 5 additions & 1 deletion ZFS-Test_Suite/tests/functional/userquota/userquota_012_neg
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@
# __stc_assertion_end
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

###############################################################################


function cleanup
{
cleanup_quota
Expand Down
9 changes: 5 additions & 4 deletions ZFS-Test_Suite/tests/functional/userquota/userquota_common.kshlib
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ function user_run

shift

# eval \$RUNWATTR -u \$user -g \$group \"$@\" > /dev/null 2>&1
eval \$RUNWATTR -u \$user -g \$group \"$@\" > /dev/null 2>&1
# echo "$@"
command=$@
# echo "user = $user group = $group"
$SU $user -c "$command" #> /dev/null 2>&1
ls -la /tank/zfs
#echo "user = $user group = $group r=$RUNWATTR"
log_must $SU $user -c "$command" #> /dev/null 2>&1
#ls -lsha /tank/zfs
echo "dd done"
echo " user_run error status : $?"
return $?
Expand All @@ -129,6 +129,7 @@ function check_quota
if (( $value != $expected )); then
return 1
fi
return 0
}

#
Expand Down
7 changes: 6 additions & 1 deletion ZFS-Test_Suite/tests/functional/userquota/userspace_001_pos
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@
#
###############################################################################

. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib


function cleanup
{
if datasetexists $snap_fs; then
Expand Down Expand Up @@ -82,14 +85,16 @@ typeset snap_fs=$QFS@snap

log_must $ZFS set userquota@$QUSER1=100m $QFS
mkmount_writable $QFS
log_must user_run $QUSER1 $MKFILE 50m $QFILE
#log_must user_run $QUSER1 $MKFILE 50m $QFILE
log_must user_run $QUSER1 $DD if=/dev/urandom of=$QFILE bs=1M count=50
$SYNC

log_must $ZFS snapshot $snap_fs

for param in "${params[@]}"; do
log_must eval "$ZFS userspace $param $QFS >/dev/null 2>&1"
log_must eval "$ZFS userspace $param $snap_fs >/dev/null 2>&1"

done

log_pass "zfs userspace with all possible parameters pass as expect"
Expand Down
8 changes: 6 additions & 2 deletions ZFS-Test_Suite/tests/functional/userquota/userspace_002_pos
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#
###############################################################################


. $STF_SUITE/commands.cfg
. $STF_SUITE/include/default_common_varible.kshlib
. $STF_SUITE/include/libtest.kshlib
. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib

Expand All @@ -72,7 +75,8 @@ log_must $ZFS set userquota@$QUSER1=100m $QFS

mkmount_writable $QFS

log_must user_run $QUSER1 $MKFILE 50m $QFILE
#log_must user_run $QUSER1 $MKFILE 50m $QFILE
log_must user_run $QUSER1 $DD if=/dev/zero of=$QFILE bs=1M count=50
$SYNC

typeset snapfs=$QFS@snap
Expand All @@ -82,10 +86,10 @@ log_must $ZFS snapshot $snapfs
log_must eval "$ZFS userspace $QFS >/dev/null 2>&1"
log_must eval "$ZFS userspace $snapfs >/dev/null 2>&1"


for fs in "$QFS" "$snapfs"; do
log_note "check the quota size in zfs userspace $fs"
log_must eval "$ZFS userspace $fs | $GREP $QUSER1 | $GREP 100M"

log_note "check the user used size in zfs userspace $fs"
log_must eval "$ZFS userspace $fs | $GREP $QUSER1 | $GREP 50.0M"
done
Expand Down

0 comments on commit 32d1463

Please sign in to comment.