xfs/106: rewrite to make it a reliable regression test

xfs/106 is testing basic functions of xfs_quota command, but
there're three problems prevent people from running it as a reliable
regression test (i.e. it's not in 'auto' group):

- It tests unavailable commands in current xfs_quota, e.g. "warn"
- Lack of test coverage of important commands, e.g. "disable,
  enable, off and remove" commands
- Test output doesn't match golden image

So rewrite this case to test as many xfs_quota sub-commands and
options as possible and add it to 'auto' group, except:

- some "-v" options
- all "-a" options, because it's hard to get deterministic output
- default quota, this should be already covered by other tests
- project command options, I will write another case to test it
- report command -l option, which is a new option and will cause
  failure when testing with xfsprogs prior to 3.1 version.
- quot command -c option, which may output different histogram in
  different systems or hosts.
- warn command, which is not currently implemented.
- print, df, free, help, quit and path commands.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Zorro Lang
2016-07-22 18:24:06 +08:00
committed by Eryu Guan
parent 6721ab08bd
commit b18191a1d0
3 changed files with 682 additions and 485 deletions
+225 -142
View File
@@ -31,208 +31,291 @@ echo "QA output created by $seq"
here=`pwd` here=`pwd`
tmp=/tmp/$$ tmp=/tmp/$$
status=1 # failure is the default! 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 # get standard environment, filters and checks
. ./common/rc . ./common/rc
. ./common/filter . ./common/filter
. ./common/quota . ./common/quota
_supported_fs xfs # remove previous $seqres.full before test
_supported_os Linux #IRIX rm -f $seqres.full
_require_scratch
_require_xfs_quota
# real QA test starts here # real QA test starts here
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs _supported_fs xfs
cat $tmp.mkfs >$seqres.full _supported_os Linux
. $tmp.mkfs _require_scratch
_require_xfs_quota
_require_user
_require_group
# setup a default run _scratch_mkfs_xfs >>$seqres.full 2>&1
if [ -z "$MOUNT_OPTIONS" ]; then
export MOUNT_OPTIONS="-o pquota,sync"
else
export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
fi
_qmount uqid=`id -u fsgqa`
_require_prjquota $SCRATCH_DEV gqid=`id -g fsgqa`
pqid=10
cat >$tmp.projects <<EOF
$pqid:$SCRATCH_MNT
EOF
# initial populate cat >$tmp.projid <<EOF
target=$SCRATCH_MNT/target root:0
$FSSTRESS_PROG -z -s 57069 -m 8 -n 1000 -p 4 \ fsgqa:$pqid
-f allocsp=1 \ EOF
-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 \ create_files()
-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
_qmount
filter_xfs_quota()
{ {
perl -ne " local bs=$1
s,$SCRATCH_MNT,[SCR_MNT],; local inum=$2
s,$SCRATCH_DEV,[SCR_DEV],;
s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/; echo "Using type=$type id=$id" >> $seqres.full
s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
print;" 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/* 2>/dev/null
rm -rf $tmp.quot 2>/dev/null
rm -rf $tmp.quota 2>/dev/null
}
filter_quot()
{
_filter_quota | grep -v "root \|\#0 " \
| sed -e '/#[0-9]*/s/#[0-9]*/#ID/g'
}
filter_report()
{
_filter_quota | grep -v "^root \|^\#0 " \
| sed -e '/^#[0-9]*/s/^#[0-9]*/#ID/g'
}
filter_quota()
{
_filter_quota | sed -e "/Disk quotas for/s/([0-9]*)/(ID)/g" \
-e "/Disk quotas for/s/#[0-9]*/#ID/g"
}
filter_state()
{
_filter_quota | sed -e "s/Inode: #[0-9]* (0 blocks, 0 extents)/Inode: #[INO] (0 blocks, 0 extents)/g" \
-e "s/Inode: #[0-9]* ([0-9]* blocks, [0-9]* extents)/Inode: #[INO] (X blocks, Y extents)/g" \
-e "/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/s/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]//g"
} }
test_quot() test_quot()
{ {
echo "checking quot command (type=$type)" # not deterministic on blks local opt="$*"
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 $opt -bi" $SCRATCH_MNT | filter_quot
} }
test_report() test_report()
{ {
local opt="$*"
echo "checking report command (type=$type)" echo "checking report command (type=$type)"
xfs_quota -x -c "report -h -$type -U 256" $SCRATCH_MNT $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "report -$type $opt -bi" \
$SCRATCH_MNT | filter_report
} }
test_limit1() test_quota()
{ {
echo "checking limit command, pass 1 (type=$type)" local opt="$*"
xfs_quota -x -c "limit -$type bsoft=100m bhard=100m ihard=2 $id" \
$SCRATCH_MNT echo "checking quota command (type=$type)"
xfs_quota -x -c "limit -$type isoft=1 rtbsoft=100m rtbhard=110m $id"\ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
$SCRATCH_MNT -c "quota -$type $opt -bi $id" \
sleep 2 # let the timer day transition happen $SCRATCH_MNT | filter_quota
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
} }
test_limit2() test_limit()
{ {
# push limits up high, so that timers are cleared, etc. (for later) local bs=$1
echo "checking limit command, pass2 (type=$type)" local bh=$2
xfs_quota -x -c "limit -$type bsoft=300m bhard=400m ihard=8800 $id" \ local is=$3
$SCRATCH_MNT local ih=$4
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
}
test_warn() echo "checking limit command (type=$type, bsoft=$bs, bhard=$bh, isoft=$is, ihard=$ih)"
{ $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
echo "checking warn command (type=$type)" -c "limit -$type bsoft=$bs bhard=$bh fsgqa" \
xfs_quota -x -c "warn -$type -b 4 $id" $SCRATCH_MNT -c "limit -$type isoft=$is ihard=$ih fsgqa" \
xfs_quota -x -c "warn -$type -i 3 $id" $SCRATCH_MNT $SCRATCH_MNT
#xfs_quota -x -c "warn -$type -r 2 $id" $SCRATCH_MNT
xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT # let the timer day transition happen
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT sleep 2
#xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
} }
test_timer() test_timer()
{ {
echo "checking timer command (type=$type)" echo "checking timer command (type=$type)"
xfs_quota -x -c "timer -$type -b 3days" $SCRATCH_MNT # set 3days+1h for time won't become 2days soon
xfs_quota -x -c "timer -$type -i 2days" $SCRATCH_MNT $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
#xfs_quota -x -c "timer -$type -r 1day" $SCRATCH_MNT -c "timer -$type -bi 73h" \
$SCRATCH_MNT | _filter_scratch
}
test_disable()
{
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_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 remove command (type=$type)"
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "remove -$type -v" \
$SCRATCH_MNT | _filter_scratch
} }
test_state() test_state()
{ {
echo "checking state command (type=$type)" echo "checking state command (type=$type)"
xfs_quota -x -c "state -$type" $SCRATCH_MNT $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
# not yet working properly? -c "state -$type" $SCRATCH_MNT | filter_state
#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
} }
test_backup() test_dump()
{ {
echo "checking dump command (type=$type)" echo "checking dump command (type=$type)"
rm -f $tmp.backup rm -f $tmp.backup 2>>/dev/null
xfs_quota -x -c "dump -$type -f $tmp.backup -U 256" $SCRATCH_MNT $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
cat $tmp.backup -c "dump -$type -f $tmp.backup" \
$SCRATCH_MNT | _filter_scratch
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_restore()
{
echo "checking restore command (type=$type)" echo "checking restore command (type=$type)"
xfs_quota -x -c "restore -$type -f $tmp.backup" $SCRATCH_MNT $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT -c "restore -$type -f $tmp.backup" \
rm -f $tmp.backup $SCRATCH_MNT | _filter_scratch
} }
test_xfs_quota() test_xfs_quota()
{ {
test_quot ; echo # init quota
test_report ; echo echo "init quota limit and timer, and dump it"
test_timer ; echo echo "create_files 1024k 15"; create_files 1024k 15
test_limit1 ; echo echo "quota remount"; _qmount
test_warn ; echo echo ; test_quot
test_limit2 ; echo echo ; test_timer
test_backup ; echo echo ; test_limit 512k 2048k 10 20
test_state ; echo echo ; test_dump
echo ; echo
# report options test
echo "report options test"
echo ; test_report
echo "-N option"; test_report -N
echo "-L -U options"; test_report -L $id -U $id
echo "-t option"; test_report -t
echo "-n option"; test_report -n
echo "-h option"; test_report -h
# quot options test
echo "quot options test"
echo ; test_quot
echo "-f option"; test_quot -f $tmp.quot
cat $tmp.quot | filter_quot
echo "-n option"; test_quot -n
# quota options test
echo ; test_quota
echo "-f option"; test_quota -f $tmp.quota
cat $tmp.quota | filter_quota
echo "-N option"; test_quota -N
echo "-n option"; test_quota -n
echo "-h option"; test_quota -h
# disable/enable test
echo "disable quota"
echo ; test_disable
echo ; test_report -N
echo "expect a remove error at here"; test_remove
echo ; test_enable
echo ; test_report -N
# off and remove test
echo "off and remove test"
echo ; test_limit 100m 100m 100 100
echo ; test_quota -N
echo ; test_off
echo ; test_state
echo ; test_remove
echo ; test_report -N
echo "quota remount"; _qmount
echo ; test_report -N
# restore test
echo "restore quota"
echo ; test_restore
echo ; test_report -N
echo ; test_state
echo "cleanup files"; clean_files
} }
# real QA test starts here echo "----------------------- uquota,sync ---------------------------"
export MOUNT_OPTIONS="-ouquota,sync" _qmount_option "uquota,sync"
_qmount _qmount
type=u type=u
id=$uid id=$uqid
test_xfs_quota | filter_xfs_quota test_xfs_quota
export MOUNT_OPTIONS="-ogquota,sync" echo "----------------------- gquota,sync ---------------------------"
_qmount_option "gquota,sync"
_qmount _qmount
type=g type=g
id=$gid id=$gqid
test_xfs_quota | filter_xfs_quota test_xfs_quota
export MOUNT_OPTIONS="-opquota,sync" echo "----------------------- pquota,sync ---------------------------"
# Need to clean the group quota before test project quota, because
# V4 xfs doesn't support separate project inode. So mkfs at here.
_scratch_unmount
_scratch_mkfs_xfs >>$seqres.full 2>&1
_qmount_option "pquota,sync"
_qmount _qmount
type=p type=p
id=$prid id=$pqid
test_xfs_quota | filter_xfs_quota _require_prjquota $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "project -s $id" \
$SCRATCH_MNT > /dev/null
test_xfs_quota
_scratch_unmount _scratch_unmount
# success, all done
status=0 status=0
exit exit
+456 -342
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -103,7 +103,7 @@
103 metadata dir ioctl auto quick 103 metadata dir ioctl auto quick
104 growfs ioctl prealloc auto stress 104 growfs ioctl prealloc auto stress
105 fuzzers 105 fuzzers
106 quota 106 auto quick quota
107 quota 107 quota
108 quota auto quick 108 quota auto quick
109 metadata auto 109 metadata auto