Skip to contentSkip to conversation

xfs/106: rewrite this case for it can be used again

PATCH New Zorro Lang 1 participant 1 message Apr 20, 2016

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 xfs/106: rewrite this case for it can be used again

xfs/106 try to do some basic xfs_quota functionality test, but due to it's too old, there're 3 problems:
1. Some quota commands can't be used, but this case try to use it. e.g. "warn" command.
2. Some quota commands can be used now, but this case doesn't test them, because they can't work previously. e.g. "disable, enable, off and remove" comands
3. Some expected output in 106.out file become incorrect now.

I rewrite this case for above 3 reasons.

---

Hi,

This case always run failed, so I try to rewrite it. I removed $FSSTRESS_PROG test, because it make the output too unpredictable, and I think it's not so important for this test(If I'm wrong, please tell me, I will try to bring it back).

I removed "warn" command test, because this feature is not currently implemented.

I added more other commands basic test.

Due to xfs/299 has done "past the hard block/inode limit" test, when quota enforced or no enforced. So I doesn't test it in this case.

One more problem, looks like the dump command can't dump timer. I set timer to 3 days. Then after dump and restore, the grace time become to 7 days. Is it expected?

Thanks
Zorro

 tests/xfs/106     | 311 ++++++++++++++++--------------
 tests/xfs/106.out | 552 +++++++++++++++++++++---------------------------------
 2 files changed, 377 insertions(+), 486 deletions(-)
tests/xfs/106 +167 -144
index 74658a6..c693f2e 100755
@@ -31,208 +31,231 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1	# failure is the default!
-trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
 
 # get standard environment, filters and checks
 . ./common/rc
 . ./common/filter
 . ./common/quota
 
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
 _supported_fs xfs
-_supported_os Linux #IRIX
+_supported_os Linux
 _require_scratch
 _require_xfs_quota
+_require_user
+_require_group
 
-# real QA test starts here
-_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
-cat $tmp.mkfs >$seqres.full
-. $tmp.mkfs
+_scratch_mkfs_xfs >$seqres.full 2>&1
 
-# setup a default run
-if [ -z "$MOUNT_OPTIONS" ]; then
-	export MOUNT_OPTIONS="-o pquota,sync"
-else
-	export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
-fi
+uqid=`id -u fsgqa`
+gqid=`id -g fsgqa`
+pqid=10
+cat >$tmp.projects <<EOF
+$pqid:$SCRATCH_MNT
+EOF
 
-_qmount
-_require_prjquota $SCRATCH_DEV
+cat >$tmp.projid <<EOF
+root:0
+fsgqa:$pqid
+EOF
 
-# initial populate
-target=$SCRATCH_MNT/target
-$FSSTRESS_PROG -z -s 57069 -m 8 -n 1000 -p 4 \
--f allocsp=1 \
--f chown=3 \
--f creat=4 \
--f dwrite=4 \
--f fallocate=1 \
--f fdatasync=1 \
--f fiemap=1 \
--f freesp=1 \
--f fsync=1 \
--f link=1 \
--f mkdir=2 \
--f mknod=2 \
--f punch=1 \
--f rename=2 \
--f resvsp=1 \
--f rmdir=1 \
--f setxattr=1 \
--f symlink=2 \
--f sync=1 \
--f truncate=2 \
--f unlink=1 \
--f unresvsp=1 \
--f write=4 \
--d $target
-
-$FSSTRESS_PROG -z -s 57069 -m 8 -n 1000 -p 4 \
--f chown=500 \
--f setxattr=500 \
--d $target
-
-# also use space, to be able to go over/under limits easily
-uid=255
-gid=254
-prid=253
-rm -f $SCRATCH_MNT/resv
-$XFS_IO_PROG -fc "resvsp 0 200m" -c "chproj $prid" $SCRATCH_MNT/resv
-chown $uid $SCRATCH_MNT/resv
-chgrp $gid $SCRATCH_MNT/resv
+create_files()
+{
+    local bs=$1
+    local inum=$2
 
-_qmount
+    echo "Using type=$type id=$id" >> $seqres.full
+
+    for ((i=0; i<$((inum-1)); i++))
+    do
+	_file_as_id $SCRATCH_MNT/inode$i $id $type 1024 0
+    done
+
+    _file_as_id $SCRATCH_MNT/block $id $type $bs 1
+}
+
+clean_files()
+{
+    rm -rf $SCRATCH_MNT/*
+}
+
+filter_quot()
+{
+    _filter_quota | grep -vw root
+}
+
+filter_report()
+{
+    _filter_quota | grep -vw root
+}
 
-filter_xfs_quota()
+filter_state()
 {
-	perl -ne "
-s,$SCRATCH_MNT,[SCR_MNT],;
-s,$SCRATCH_DEV,[SCR_DEV],;
-s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
-s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
-	print;"
+    _filter_quota | sed \
+	-e "s/Inode: #[0-9]* (0 blocks, 0 extents)/Inode: #[INO] (0 blocks, 0 extents)/g" \
+	-e "s/Inode: #[1-9]* ([1-9]* blocks, [0-9]* extents)/Inode: #[INO] (X blocks, Y extents)/g"
 }
 
 test_quot()
 {
-	echo "checking quot command (type=$type)"  # not deterministic on blks
-	xfs_quota -x -c "quot -n -$type" $SCRATCH_MNT >>$seqres.full 2>&1
+    echo "checking quot command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "quot -$type -bi" $SCRATCH_MNT | filter_quot
 }
 
 test_report()
 {
-	echo "checking report command (type=$type)"
-	xfs_quota -x -c "report -h -$type -U 256" $SCRATCH_MNT
+    echo "checking report command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "report -$type -biN" $SCRATCH_MNT | filter_report
 }
 
-test_limit1()
+test_limit()
 {
-	echo "checking limit command, pass 1 (type=$type)"
-	xfs_quota -x -c "limit -$type bsoft=100m bhard=100m ihard=2 $id" \
-		$SCRATCH_MNT
-	xfs_quota -x -c "limit -$type isoft=1 rtbsoft=100m rtbhard=110m $id"\
-		$SCRATCH_MNT
-	sleep 2		# let the timer day transition happen
-	xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
-	#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
+    local bs=$1
+    local bh=$2
+    local is=$3
+    local ih=$4
+
+    echo "checking limit command (type=$type, bsoft=$bs, bhard=$bh, isoft=$is, ihard=$ih)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "limit -$type bsoft=$bs bhard=$bh fsgqa" \
+	-c "limit -$type isoft=$is ihard=$ih fsgqa" \
+	$SCRATCH_MNT
+
+    # let the timer day transition happen
+    sleep 2
 }
 
-test_limit2()
+test_quota()
 {
-	# push limits up high, so that timers are cleared, etc. (for later)
-	echo "checking limit command, pass2 (type=$type)"
-	xfs_quota -x -c "limit -$type bsoft=300m bhard=400m ihard=8800 $id" \
-		$SCRATCH_MNT
-	xfs_quota -x -c "limit -$type isoft=8000 rtbsoft=310m rtbhard=410m $id"\
-		$SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
-	#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
+    echo "checking quota command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "quota -$type -bivN $id" $SCRATCH_MNT | filter_quot
 }
 
-test_warn()
+test_timer()
 {
-	echo "checking warn command (type=$type)"
-	xfs_quota -x -c "warn -$type -b 4 $id" $SCRATCH_MNT
-	xfs_quota -x -c "warn -$type -i 3 $id" $SCRATCH_MNT
-	#xfs_quota -x -c "warn -$type -r 2 $id" $SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
-	#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
+    local t=$1
+
+    echo "checking timer command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "timer -$type -bi $t" $SCRATCH_MNT | _filter_scratch
 }
 
-test_timer()
+test_disable()
 {
-	echo "checking timer command (type=$type)"
-	xfs_quota -x -c "timer -$type -b 3days" $SCRATCH_MNT
-	xfs_quota -x -c "timer -$type -i 2days" $SCRATCH_MNT
-	#xfs_quota -x -c "timer -$type -r 1day" $SCRATCH_MNT
+    echo "checking disable command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "disable -$type -v" $SCRATCH_MNT | filter_state
 }
 
-test_state()
+test_enable()
+{
+    echo "checking enable command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "enable -$type -v" $SCRATCH_MNT | filter_state
+}
+
+test_off()
+{
+    echo "checking off command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "off -$type -v" $SCRATCH_MNT | _filter_scratch
+}
+
+test_remove()
 {
-	echo "checking state command (type=$type)"
-	xfs_quota -x -c "state -$type" $SCRATCH_MNT
-	# not yet working properly?
-	#echo "checking disable command (type=$type)"
-	#xfs_quota -x -c "disable -$type -v" $SCRATCH_MNT
-	#echo "checking enable command (type=$type)"
-	#xfs_quota -x -c "enable -$type -v" $SCRATCH_MNT
-	#echo "checking off command (type=$type)"
-	#xfs_quota -x -c "off -$type -v" $SCRATCH_MNT
-	#echo "checking remove command (type=$type)"
-	#xfs_quota -x -c "remove -$type -v" $SCRATCH_MNT
+    echo "checking remove command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "remove -$type -v" $SCRATCH_MNT | _filter_scratch
 }
 
-test_backup()
+test_state()
 {
-	echo "checking dump command (type=$type)"
-	rm -f $tmp.backup
-	xfs_quota -x -c "dump -$type -f $tmp.backup -U 256" $SCRATCH_MNT
-	cat $tmp.backup
+    echo "checking state command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "state -$type" $SCRATCH_MNT | filter_state
+}
 
-	echo "changing limits (type=$type)"
-	xfs_quota -x -c "limit -$type isoft=1000 ihard=1100 $id" $SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
+test_dump()
+{
+    echo "checking dump command (type=$type)"
+    rm -f $tmp.backup 2>>/dev/null
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "dump -$type -f $tmp.backup" $SCRATCH_MNT | _filter_scratch
+}
 
-	echo "checking restore command (type=$type)"
-	xfs_quota -x -c "restore -$type -f $tmp.backup" $SCRATCH_MNT
-	xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
-	rm -f $tmp.backup
+test_restore()
+{
+    echo "checking restore command (type=$type)"
+    $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
+	-c "restore -$type -f $tmp.backup" $SCRATCH_MNT | _filter_scratch
 }
 
 test_xfs_quota()
 {
-	test_quot	; echo
-	test_report	; echo
-	test_timer	; echo
-	test_limit1	; echo
-	test_warn	; echo
-	test_limit2	; echo
-	test_backup	; echo
-	test_state	; echo
-	echo		; echo
+    echo "create_files 1024k 15"; create_files 1024k 15
+    echo "quota remount"; _qmount
+    echo ; test_quot
+    echo ; test_timer 3days
+    echo ; test_limit 512k 2048k 10 20
+    echo ; test_quota
+    echo ; test_dump
+
+    echo ; test_disable
+    echo ; test_report
+    echo "expect a remove error at here"; test_remove
+    echo ; test_enable
+    echo ; test_report
+
+    echo ; test_limit 100m 100m 100 100
+    echo ; test_quota
+    echo ; test_off
+    echo ; test_state
+    echo ; test_remove
+    echo ; test_report
+
+    echo "quota remount"; _qmount
+    echo ; test_report
+    echo ; test_restore
+    echo ; test_report
+    echo ; test_state
+    echo "cleanup files"; clean_files
 }
 
-# real QA test starts here
-export MOUNT_OPTIONS="-ouquota,sync"
+echo "----------------------- uquota,sync ---------------------------"
+_qmount_option "uquota,sync"
 _qmount
 type=u
-id=$uid
-test_xfs_quota | filter_xfs_quota
+id=$uqid
+test_xfs_quota
 
-export MOUNT_OPTIONS="-ogquota,sync"
+echo "----------------------- gquota,sync ---------------------------"
+_qmount_option "gquota,sync"
 _qmount
 type=g
-id=$gid
-test_xfs_quota | filter_xfs_quota
+id=$gqid
+test_xfs_quota
 
-export MOUNT_OPTIONS="-opquota,sync"
+echo "----------------------- pquota,sync ---------------------------"
+_qmount_option "pquota,sync"
 _qmount
 type=p
-id=$prid
-test_xfs_quota | filter_xfs_quota
+id=$pqid
+_require_prjquota $SCRATCH_DEV
+test_xfs_quota
 
-_scratch_unmount
+# success, all done
 status=0
 exit
tests/xfs/106.out +210 -342

589 lines not on this page · raw message

Signature · 1 line
2.5.5