gating: introduce user_quota and group_quota tests in c10s
Resolves: RHEL-70716 Signed-off-by: Boyang Xue <bxue@redhat.com>
This commit is contained in:
parent
12e281cccf
commit
a659dafc2a
@ -1,7 +1,5 @@
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- rhel-10
|
||||
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
||||
|
||||
|
||||
9
plan.fmf
Normal file
9
plan.fmf
Normal file
@ -0,0 +1,9 @@
|
||||
summary: quota gating test
|
||||
execute:
|
||||
how: tmt
|
||||
discover:
|
||||
how: fmf
|
||||
test: [
|
||||
"user_quota",
|
||||
"group_quota",
|
||||
]
|
||||
@ -1,15 +0,0 @@
|
||||
summary: quota gating test
|
||||
discover:
|
||||
how: fmf
|
||||
url: https://gitlab.cee.redhat.com/kernel-qe/kernel.git
|
||||
test: [
|
||||
"filesystems/ext4/group_quota",
|
||||
"filesystems/ext4/user_quota",
|
||||
]
|
||||
environment:
|
||||
FSTYP: ext4
|
||||
TEST_GROUP: quota
|
||||
AVC_ERROR: +no_avc_check
|
||||
execute:
|
||||
how: tmt
|
||||
|
||||
81
tests/group_quota/Makefile
Normal file
81
tests/group_quota/Makefile
Normal file
@ -0,0 +1,81 @@
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Author: Igor ZHANG <yugzhang@redhat.com>
|
||||
|
||||
# The toplevel namespace within which the test lives.
|
||||
TOPLEVEL_NAMESPACE=kernel
|
||||
|
||||
# The name of the package under test:
|
||||
PACKAGE_NAME=filesystems
|
||||
|
||||
# The path of the test below the package:
|
||||
RELATIVE_PATH=ext4/group_quota
|
||||
|
||||
# Version of the Test. Used with make tag.
|
||||
export TESTVERSION=1.0
|
||||
|
||||
# The combined namespace of the test.
|
||||
export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
|
||||
|
||||
# A phony target is one that is not really the name of a file.
|
||||
# It is just a name for some commands to be executed when you
|
||||
# make an explicit request. There are two reasons to use a
|
||||
# phony target: to avoid a conflict with a file of the same
|
||||
# name, and to improve performance.
|
||||
.PHONY: all install download clean
|
||||
|
||||
# executables to be built should be added here, they will be generated on the system under test.
|
||||
BUILT_FILES=
|
||||
|
||||
# data files, .c files, scripts anything needed to either compile the test and/or run it.
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ *.rpm $(BUILT_FILES)
|
||||
|
||||
# You may need to add other targets e.g. to build executables from source code
|
||||
# Add them here:
|
||||
|
||||
|
||||
# Include Common Makefile
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
# Generate the testinfo.desc here:
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
# Change to the test owner's name
|
||||
@echo "Owner: Igor ZHANG <yugzhang@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Test ext4 group quota.">> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
# add any other packages for which your test ought to run here
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: policycoreutils-python" >> $(METADATA)
|
||||
@echo "Requires: quota" >> $(METADATA)
|
||||
@echo "Requires: e4fsprogs" >> $(METADATA)
|
||||
# add any other requirements for the script to run here
|
||||
|
||||
# You may need other fields here; see the documentation
|
||||
rhts-lint $(METADATA)
|
||||
3
tests/group_quota/PURPOSE
Normal file
3
tests/group_quota/PURPOSE
Normal file
@ -0,0 +1,3 @@
|
||||
PURPOSE of /tests/kernel/filesystems/ext4/group_quota
|
||||
Description: Test ext4 group quota
|
||||
Author: Igor Zhang <yugzhang@redhat.com>
|
||||
13
tests/group_quota/main.fmf
Normal file
13
tests/group_quota/main.fmf
Normal file
@ -0,0 +1,13 @@
|
||||
summary: fs-qe case:/kernel/filesystems/ext4/group_quota
|
||||
description: Test ext4 group quota.
|
||||
contact: Boyang Xue <bxue@redhat.com>
|
||||
component: kernel
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- quota
|
||||
- beakerlib
|
||||
duration: 5m
|
||||
id: 80457492-fa1b-49fd-a34c-6e74923f3bfc
|
||||
link:
|
||||
- implements: https://polarion.engineering.redhat.com/polarion/#/project/RHELKERNEL/workitem?id=KERNEL-292144
|
||||
14
tests/group_quota/metadata
Normal file
14
tests/group_quota/metadata
Normal file
@ -0,0 +1,14 @@
|
||||
[General]
|
||||
description=Test ext4 group quota.
|
||||
name=/kernel/filesystems/ext4/group_quota
|
||||
owner=Igor ZHANG <yugzhang@redhat.com>
|
||||
license=GPLv2
|
||||
|
||||
[restraint]
|
||||
entry_point=./runtest.sh
|
||||
max_time=5m
|
||||
dependencies=quota;e4fsprogs;
|
||||
TestVersion=1.0
|
||||
Requires=kernel
|
||||
Path=/filesystems/ext4/group_quota
|
||||
RunFor=kernel
|
||||
262
tests/group_quota/runtest.sh
Executable file
262
tests/group_quota/runtest.sh
Executable file
@ -0,0 +1,262 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Author: Igor ZHANG <yugzhang@redhat.com>
|
||||
|
||||
OUTPUTDIR=/tmp
|
||||
if test ! -d $OUTPUTDIR; then
|
||||
echo "creating $OUTPUTDIR"
|
||||
mkdir -p $OUTPUTDIR
|
||||
fi
|
||||
OUTPUTFILE=`mktemp $OUTPUTDIR/tmp.XXXXXX`
|
||||
|
||||
result=PASS
|
||||
score=0
|
||||
lo_dev=`losetup -f`
|
||||
fs_img=/mnt/testarea/fs_img
|
||||
mnt_point=/mnt/testarea/mnt_point
|
||||
|
||||
err_quit() {
|
||||
rstrnt-report-result "group_quota" "FAIL" $1
|
||||
exit 1
|
||||
#rhts-abort -t recipe || exit 1
|
||||
}
|
||||
|
||||
setup() {
|
||||
mkdir -p /mnt/testarea
|
||||
dd if=/dev/null of=$fs_img bs=1G seek=5
|
||||
losetup $lo_dev $fs_img
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: setup loop device" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
mkfs.ext4 $lo_dev
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: make ext4" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
mkdir -p $mnt_point
|
||||
mount -o grpquota $lo_dev $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: mount ext4 with grpquota" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
chmod 777 $mnt_point && chmod o+t $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: chmod ext4's root" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
groupadd test
|
||||
useradd -g test test1
|
||||
useradd -g test test2
|
||||
|
||||
# bug??
|
||||
if [ -f $mnt_point/aquota.group.new ]; then
|
||||
echo "- error: aquota.group.new is there before quotacheck" | tee -a $OUTPUTFILE
|
||||
fi
|
||||
# Workaround selinux quota issue, see bug 703871 comment 11 and comment 16
|
||||
chcon --reference=/var $mnt_point
|
||||
quotacheck -gvd $mnt_point
|
||||
if [ -f $mnt_point/aquota.group.new ]; then
|
||||
echo "- error: aquota.group.new is there after quotacheck" | tee -a $OUTPUTFILE
|
||||
mv $mnt_point/aquota.group.new $mnt_point/aquota.group.broken
|
||||
fi
|
||||
quotacheck -gvd -a
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: quotacheck ext4" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
setquota -g test 200000 300000 2000 3000 $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: setquota for group 'test'" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
li=($(quota -gv test|grep "$lo_dev"|awk '{print $3,$4,$6,$7}'))
|
||||
if [ ${li[0]} -ne 200000 -o ${li[1]} -ne 300000 -o ${li[2]} -ne 2000 -o ${li[3]} -ne 3000 ]; then
|
||||
echo "- error: setquota not right" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
quotaon -gv $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: quotaon ext4" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_test() {
|
||||
# blocks/soft test
|
||||
su - test1 -c "dd if=/dev/zero of=$mnt_point/test1_200m bs=1024 count=200000"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $2,$5}'))
|
||||
if [ ${t[0]} -ne 200000 -o ${t[1]} -ne 1 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
su - test2 -c "dd if=/dev/zero of=$mnt_point/test2_1k bs=1024 count=1"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $2,$5,$6}'))
|
||||
if [ ${t[0]} != "200004*" -o ${t[1]} != "7days" -o ${t[2]} -ne 2 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
|
||||
rm -f /mnt/testarea/mnt_point/{test1_200m,test2_1k}
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $2,$5}'))
|
||||
if [ ${t[0]} -ne 0 -o ${t[1]} -ne 0 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
# blocks/hard test
|
||||
su - test1 -c "dd if=/dev/zero of=$mnt_point/test1_300m bs=1024 count=300000"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $2,$5,$6}'))
|
||||
if [ ${t[0]} != "300000*" -o ${t[1]} != "7days" -o ${t[2]} -ne 1 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
su - test2 -c "dd if=/dev/zero of=$mnt_point/test2_1k bs=1024 count=1"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $2,$5,$6}'))
|
||||
if [ ${t[0]} != "300000*" -o ${t[1]} != "7days" -o ${t[2]} -ne 2 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
rm -f /mnt/testarea/mnt_point/{test1_300m,test2_1k}
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $2,$5}'))
|
||||
if [ ${t[0]} -ne 0 -o ${t[1]} -ne 0 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
# inodes/soft test
|
||||
su - test1 -c "n=1; while [[ \$n -le 2000 ]]; do touch $mnt_point/\$n; let n++; done"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $5,$8}'))
|
||||
if [ ${t[0]} != "2000*" -o ${t[1]} != "7days" ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
su - test2 -c "touch $mnt_point/test2"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $5}'))
|
||||
if [ ${t[0]} != "2001*" ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
|
||||
rm -f /mnt/testarea/mnt_point/{[1-9]*,test2} > /dev/null
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $5}'))
|
||||
if [ ${t[0]} -ne 0 ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
# inodes/hard test
|
||||
su - test1 -c "n=1; while [[ \$n -le 3000 ]]; do touch $mnt_point/\$n; let n++; done"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $5,$8}'))
|
||||
if [ ${t[0]} != "3000*" -o ${t[1]} != "7days" ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
|
||||
su - test2 -c "touch $mnt_point/test2"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $5,$8}'))
|
||||
if [ ${t[0]} != "3000*" -o ${t[1]} != "7days" ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
rm -f /mnt/testarea/mnt_point/{[1-9]*,test2} > /dev/null
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -vg test|grep "$lo_dev"|awk '{print $5}'))
|
||||
if [ ${t[0]} -ne 0 ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
userdel -r test1
|
||||
userdel -r test2
|
||||
groupdel test
|
||||
|
||||
umount $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: umount ext4" | tee -a $OUTPUTFILE
|
||||
fi
|
||||
rm -rf $mnt_point > /dev/null
|
||||
losetup -d $lo_dev
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: detach loop device" | tee -a $OUTPUTFILE
|
||||
fi
|
||||
rm -rf $fs_img > /dev/null
|
||||
}
|
||||
|
||||
# selinux setup to disable RHTS AVC warning.
|
||||
setup
|
||||
do_test
|
||||
cleanup
|
||||
|
||||
echo "Silence is gloden" | tee -a $OUTPUTFILE
|
||||
rstrnt-report-result "group_quota" $result $score
|
||||
80
tests/user_quota/Makefile
Normal file
80
tests/user_quota/Makefile
Normal file
@ -0,0 +1,80 @@
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Author: Igor ZHANG <yugzhang@redhat.com>
|
||||
|
||||
# The toplevel namespace within which the test lives.
|
||||
TOPLEVEL_NAMESPACE=kernel
|
||||
|
||||
# The name of the package under test:
|
||||
PACKAGE_NAME=filesystems
|
||||
|
||||
# The path of the test below the package:
|
||||
RELATIVE_PATH=ext4/user_quota
|
||||
|
||||
# Version of the Test. Used with make tag.
|
||||
export TESTVERSION=1.0
|
||||
|
||||
# The combined namespace of the test.
|
||||
export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
|
||||
|
||||
# A phony target is one that is not really the name of a file.
|
||||
# It is just a name for some commands to be executed when you
|
||||
# make an explicit request. There are two reasons to use a
|
||||
# phony target: to avoid a conflict with a file of the same
|
||||
# name, and to improve performance.
|
||||
.PHONY: all install download clean
|
||||
|
||||
# executables to be built should be added here, they will be generated on the system under test.
|
||||
BUILT_FILES=
|
||||
|
||||
# data files, .c files, scripts anything needed to either compile the test and/or run it.
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ *.rpm $(BUILT_FILES)
|
||||
|
||||
# You may need to add other targets e.g. to build executables from source code
|
||||
# Add them here:
|
||||
|
||||
|
||||
# Include Common Makefile
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
# Generate the testinfo.desc here:
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
# Change to the test owner's name
|
||||
@echo "Owner: Igor ZHANG <yugzhang@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Test ext4 user quota.">> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
# add any other packages for which your test ought to run here
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: quota" >> $(METADATA)
|
||||
@echo "Requires: e4fsprogs" >> $(METADATA)
|
||||
# add any other requirements for the script to run here
|
||||
|
||||
# You may need other fields here; see the documentation
|
||||
rhts-lint $(METADATA)
|
||||
3
tests/user_quota/PURPOSE
Normal file
3
tests/user_quota/PURPOSE
Normal file
@ -0,0 +1,3 @@
|
||||
PURPOSE of /tests/kernel/filesystems/ext4/user_quota
|
||||
Description: Test ext4 user quota
|
||||
Author: Igor Zhang <yugzhang@redhat.com>
|
||||
13
tests/user_quota/main.fmf
Normal file
13
tests/user_quota/main.fmf
Normal file
@ -0,0 +1,13 @@
|
||||
summary: fs-qe case:/kernel/filesystems/ext4/user_quota
|
||||
description: Test ext4 user quota.
|
||||
contact: Boyang Xue <bxue@redhat.com>
|
||||
component: kernel
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- quota
|
||||
- beakerlib
|
||||
duration: 5m
|
||||
id: f5e7e10e-454c-4c32-9562-b3d0eae5fe17
|
||||
link:
|
||||
- implements: https://polarion.engineering.redhat.com/polarion/#/project/RHELKERNEL/workitem?id=KERNEL-292145
|
||||
14
tests/user_quota/metadata
Normal file
14
tests/user_quota/metadata
Normal file
@ -0,0 +1,14 @@
|
||||
[General]
|
||||
description=Test ext4 user quota.
|
||||
name=/kernel/filesystems/ext4/user_quota
|
||||
owner=Igor ZHANG <yugzhang@redhat.com>
|
||||
license=GPLv2
|
||||
|
||||
[restraint]
|
||||
entry_point=./runtest.sh
|
||||
max_time=5m
|
||||
dependencies=quota;e4fsprogs;
|
||||
TestVersion=1.0
|
||||
Requires=kernel
|
||||
Path=/filesystems/ext4/user_quota
|
||||
RunFor=kernel
|
||||
235
tests/user_quota/runtest.sh
Executable file
235
tests/user_quota/runtest.sh
Executable file
@ -0,0 +1,235 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Author: Igor ZHANG <yugzhang@redhat.com>
|
||||
|
||||
# Create tmp directory
|
||||
OUTPUTDIR=/tmp
|
||||
if test ! -d $OUTPUTDIR; then
|
||||
echo "creating $OUTPUTDIR"
|
||||
mkdir -p $OUTPUTDIR
|
||||
fi
|
||||
OUTPUTFILE=`mktemp $OUTPUTDIR/tmp.XXXXXX`
|
||||
|
||||
result=PASS
|
||||
score=0
|
||||
lo_dev=`losetup -f`
|
||||
fs_img=/mnt/testarea/fs_img
|
||||
mnt_point=/mnt/testarea/mnt_point
|
||||
|
||||
err_quit() {
|
||||
rstrnt-report-result "user_quota" "FAIL" $1
|
||||
exit 1
|
||||
#rhts-abort -t recipe || exit 1
|
||||
}
|
||||
|
||||
setup() {
|
||||
mkdir -p /mnt/testarea
|
||||
dd if=/dev/null of=$fs_img bs=1G seek=5
|
||||
losetup $lo_dev $fs_img
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: setup loop device" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
mkfs.ext4 $lo_dev
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: make ext4" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
mkdir $mnt_point
|
||||
mount -o usrquota $lo_dev $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: mount ext4 with usrquota" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
chmod 777 $mnt_point && chmod o+t $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: chmod ext4's root" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
useradd test
|
||||
# Workaround selinux quota issue, see bug 703871 comment 11 and comment 16
|
||||
chcon --reference=/var $mnt_point
|
||||
quotacheck -u $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: quotacheck ext4" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
setquota -u test 200000 300000 2000 3000 $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: setquota for group 'test'" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
li=($(quota -uv test|grep "$lo_dev"|awk '{print $3,$4,$6,$7}'))
|
||||
if [ ${li[0]} -ne 200000 -o ${li[1]} -ne 300000 -o ${li[2]} -ne 2000 -o ${li[3]} -ne 3000 ]; then
|
||||
echo "- error: setquota not right" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
quotaon -uv $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: quotaon ext4" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_test() {
|
||||
# blocks/soft test
|
||||
su - test -c "dd if=/dev/zero of=$mnt_point/test_200m bs=1024 count=200000"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $2,$5}'))
|
||||
if [ ${t[0]} -ne 200000 -o ${t[1]} -ne 1 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
rm -f $mnt_point/test_200m
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $2,$5}'))
|
||||
if [ ${t[0]} -ne 0 -o ${t[1]} -ne 0 ]; then
|
||||
echo "- fail: blocks/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
# blocks/hard test
|
||||
su - test -c "dd if=/dev/zero of=$mnt_point/test_300m bs=1024 count=300000"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $2,$5,$6}'))
|
||||
if [ ${t[0]} != "300000*" -o ${t[1]} != "7days" -o ${t[2]} -ne 1 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
su - test -c "dd if=/dev/zero of=$mnt_point/test_1k bs=1024 count=1"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $2,$5,$6}'))
|
||||
if [ ${t[0]} != "300000*" -o ${t[1]} != "7days" -o ${t[2]} -ne 2 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
rm -f $mnt_point/{test_300m,test_1k}
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $2,$5}'))
|
||||
if [ ${t[0]} -ne 0 -o ${t[1]} -ne 0 ]; then
|
||||
echo "- fail: blocks/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
# inodes/soft test
|
||||
su - test -c "n=1; while [[ \$n -le 2000 ]]; do touch $mnt_point/\$n; let n++; done"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $5,$8}'))
|
||||
if [ ${t[0]} != "2000*" -o ${t[1]} != "7days" ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
su - test -c "touch $mnt_point/test"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $5}'))
|
||||
if [ ${t[0]} != "2001*" ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
|
||||
rm -f $mnt_point/{[1-9]*,test} > /dev/null
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $5}'))
|
||||
if [ ${t[0]} -ne 0 ]; then
|
||||
echo "- fail: inodes/soft test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
# inodes/hard test
|
||||
su - test -c "n=1; while [[ \$n -le 3000 ]]; do touch $mnt_point/\$n; let n++; done"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $5,$8}'))
|
||||
if [ ${t[0]} != "3000*" -o ${t[1]} != "7days" ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
|
||||
su - test -c "touch $mnt_point/test"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $5,$8}'))
|
||||
if [ ${t[0]} != "3000*" -o ${t[1]} != "7days" ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
|
||||
rm -f $mnt_point/{[1-9]*,test} > /dev/null
|
||||
# workaround slow quota reaction against deletion on i386/s390x with RHEL6
|
||||
# refer to https://bugzilla.redhat.com/show_bug.cgi?id=1403139#c9
|
||||
sleep 3s
|
||||
t=($(quota -uv test|grep "$lo_dev"|awk '{print $5}'))
|
||||
if [ ${t[0]} -ne 0 ]; then
|
||||
echo "- fail: inodes/hard test" | tee -a $OUTPUTFILE
|
||||
err_quit 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
userdel -r test
|
||||
umount $mnt_point
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: umount ext4" | tee -a $OUTPUTFILE
|
||||
fi
|
||||
rm -rf $mnt_point > /dev/null
|
||||
losetup -d $lo_dev
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "- error: detach loop device" | tee -a $OUTPUTFILE
|
||||
fi
|
||||
rm -rf $fs_img > /dev/null
|
||||
}
|
||||
|
||||
setup
|
||||
do_test
|
||||
cleanup
|
||||
|
||||
echo "Silence is gloden" | tee -a $OUTPUTFILE
|
||||
rstrnt-report-result "user_quota" $result $score
|
||||
Loading…
Reference in New Issue
Block a user