fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Initial CephFS tests
@ 2019-04-05 14:53 Luis Henriques
  2019-04-05 14:53 ` [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota Luis Henriques
  2019-04-05 14:53 ` [PATCH v2 2/2] ceph: test basic ceph.quota.max_bytes quota Luis Henriques
  0 siblings, 2 replies; 5+ messages in thread
From: Luis Henriques @ 2019-04-05 14:53 UTC (permalink / raw)
  To: fstests; +Cc: Yan, Zheng, Dave Chinner, ceph-devel, Luis Henriques

Hi all,

This is the first attempt to (finally!) add CephFS specific tests to
fstests.  Hopefully, more will follow once an initial set is accepted -- I
do have a few more that could easily be added, and I'm sure that in the
future more CephFS-specific tests can continue to be developed.  This test
suite has already proved to be quite useful in finding bugs in this
filesystem; adding specific tests for it is just the next logic step.

For now, just two simple tests to do some basic checks on quotas features.

Cheers,
--
Luis

Changes since v1 (RFC):

 Both tests refactored:
 - use 'workdir' instead of 'testdir' and initialize it to $seq
 - don't remove $workdir on cleanup()
 - use output to validate test results instead of _fail

Luis Henriques (2):
  ceph: test basic ceph.quota.max_files quota
  ceph: test basic ceph.quota.max_bytes quota

 tests/ceph/001      |  86 ++++++++++++++++++++++++++++++
 tests/ceph/001.out  |   9 ++++
 tests/ceph/002      | 125 ++++++++++++++++++++++++++++++++++++++++++++
 tests/ceph/002.out  |  64 +++++++++++++++++++++++
 tests/ceph/Makefile |  20 +++++++
 tests/ceph/group    |   2 +
 6 files changed, 306 insertions(+)
 create mode 100755 tests/ceph/001
 create mode 100644 tests/ceph/001.out
 create mode 100755 tests/ceph/002
 create mode 100644 tests/ceph/002.out
 create mode 100644 tests/ceph/Makefile
 create mode 100644 tests/ceph/group

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota
  2019-04-05 14:53 [PATCH v2 0/2] Initial CephFS tests Luis Henriques
@ 2019-04-05 14:53 ` Luis Henriques
  2019-04-06 12:45   ` Eryu Guan
  2019-04-05 14:53 ` [PATCH v2 2/2] ceph: test basic ceph.quota.max_bytes quota Luis Henriques
  1 sibling, 1 reply; 5+ messages in thread
From: Luis Henriques @ 2019-04-05 14:53 UTC (permalink / raw)
  To: fstests; +Cc: Yan, Zheng, Dave Chinner, ceph-devel, Luis Henriques

Simple set of checks for CephFS max_files directory quota implementation.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
 tests/ceph/001      | 86 +++++++++++++++++++++++++++++++++++++++++++++
 tests/ceph/001.out  |  9 +++++
 tests/ceph/Makefile | 20 +++++++++++
 tests/ceph/group    |  1 +
 4 files changed, 116 insertions(+)
 create mode 100755 tests/ceph/001
 create mode 100644 tests/ceph/001.out
 create mode 100644 tests/ceph/Makefile
 create mode 100644 tests/ceph/group

diff --git a/tests/ceph/001 b/tests/ceph/001
new file mode 100755
index 000000000000..770e952cd8dc
--- /dev/null
+++ b/tests/ceph/001
@@ -0,0 +1,86 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test No. 001
+#
+# Test basic ceph.quota.max_files quota features.
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+workdir=$TEST_DIR/$seq
+
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ceph
+
+_require_attrs
+
+set_quota()
+{
+	val=$1
+	dir=$2
+	$SETFATTR_PROG -n ceph.quota.max_files -v $val $dir >/dev/null 2>&1
+}
+get_quota()
+{
+	dir=$1
+	$GETFATTR_PROG -n ceph.quota.max_files $dir 2> /dev/null
+}
+
+rm -rf $workdir
+mkdir $workdir
+
+# test setting quota
+set_quota 10 $workdir
+get_quota $workdir
+
+# set quota to largest acceptable value (0x7FFFFFFFFFFFFFFF)
+set_quota 9223372036854775807 $workdir
+get_quota $workdir
+
+# test resetting quota
+set_quota 0 $workdir
+get_quota $workdir
+
+# set quota to invalid values (0x8000000000000000 and -1)
+set_quota 9223372036854775808 $workdir
+get_quota $workdir
+
+set_quota -1 $workdir
+get_quota $workdir
+
+set_quota 5 $workdir
+mkdir $workdir/0
+touch $workdir/0/1
+touch $workdir/0/2
+touch $workdir/3
+
+touch $workdir/4 2>&1 | _filter_test_dir # should fail
+mkdir $workdir/5 2>&1 | _filter_test_dir # should fail
+
+set_quota 0 $workdir
+touch $workdir/4 # shouldn't fail
+mkdir $workdir/5 # shouldn't fail
+
+# success, all done
+status=0
+exit
diff --git a/tests/ceph/001.out b/tests/ceph/001.out
new file mode 100644
index 000000000000..6ddb007dce22
--- /dev/null
+++ b/tests/ceph/001.out
@@ -0,0 +1,9 @@
+QA output created by 001
+# file: mnt/test/001
+ceph.quota.max_files="10"
+
+# file: mnt/test/001
+ceph.quota.max_files="9223372036854775807"
+
+touch: cannot touch 'TEST_DIR/001/4': Disk quota exceeded
+mkdir: cannot create directory 'TEST_DIR/001/5': Disk quota exceeded
diff --git a/tests/ceph/Makefile b/tests/ceph/Makefile
new file mode 100644
index 000000000000..f93862af4f31
--- /dev/null
+++ b/tests/ceph/Makefile
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+
+TOPDIR = ../..
+include $(TOPDIR)/include/builddefs
+
+CEPHFS_DIR = cephfs
+TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(CEPHFS_DIR)
+
+include $(BUILDRULES)
+
+install:
+	$(INSTALL) -m 755 -d $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
+	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
+
+# Nothing.
+install-dev install-lib:
diff --git a/tests/ceph/group b/tests/ceph/group
new file mode 100644
index 000000000000..e389bc6ec7ee
--- /dev/null
+++ b/tests/ceph/group
@@ -0,0 +1 @@
+001 auto quick quota

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] ceph: test basic ceph.quota.max_bytes quota
  2019-04-05 14:53 [PATCH v2 0/2] Initial CephFS tests Luis Henriques
  2019-04-05 14:53 ` [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota Luis Henriques
@ 2019-04-05 14:53 ` Luis Henriques
  1 sibling, 0 replies; 5+ messages in thread
From: Luis Henriques @ 2019-04-05 14:53 UTC (permalink / raw)
  To: fstests; +Cc: Yan, Zheng, Dave Chinner, ceph-devel, Luis Henriques

Simple set of checks for CephFS max_bytes directory quota implementation.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
 tests/ceph/002     | 125 +++++++++++++++++++++++++++++++++++++++++++++
 tests/ceph/002.out |  64 +++++++++++++++++++++++
 tests/ceph/group   |   1 +
 3 files changed, 190 insertions(+)
 create mode 100755 tests/ceph/002
 create mode 100644 tests/ceph/002.out

diff --git a/tests/ceph/002 b/tests/ceph/002
new file mode 100755
index 000000000000..6f71ba567bb5
--- /dev/null
+++ b/tests/ceph/002
@@ -0,0 +1,125 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test No. 002
+#
+# This tests basic ceph.quota.max_bytes quota features.
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+workdir=$TEST_DIR/$seq
+
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ceph
+
+_require_attrs
+
+set_quota()
+{
+	val=$1
+	dir=$2
+	$SETFATTR_PROG -n ceph.quota.max_bytes -v $val $dir >/dev/null 2>&1
+}
+
+get_quota()
+{
+	dir=$1
+	$GETFATTR_PROG -n ceph.quota.max_bytes $dir 2> /dev/null
+}
+
+# function to write a file.  We use a loop because quotas in CephFS is a
+# "best-effort" implementation, i.e. a write may actually be allowed even if the
+# quota is being exceeded.  Using a loop reduces the chances of this to happen:
+# the usage of fsync (-W in xfs_io) and the open/close of the file will make
+# sure the file size is be updated in the MDSs.
+#
+# NOTE: 'size' parameter is in M
+write_file()
+{
+	file=$1
+	size=$2 # size in M
+	for (( i = 1; i < $size; i++ )); do
+		$XFS_IO_PROG -f -c "pwrite -W $((i * 1048576)) 1m" \
+			     $file | _filter_xfs_io
+	done
+}
+
+rm -rf $workdir
+mkdir $workdir
+
+# test setting quota
+set_quota 1000000 $workdir
+get_quota $workdir
+
+# set quota to largest acceptable value (0x7FFFFFFFFFFFFFFF)
+set_quota 9223372036854775807 $workdir
+get_quota $workdir
+
+# test resetting quota
+set_quota 0 $workdir
+get_quota $workdir
+
+# set quota to invalid values (0x8000000000000000 and -1)
+set_quota 9223372036854775808 $workdir
+get_quota $workdir
+
+set_quota -1 $workdir
+get_quota $workdir
+
+bigfile="$workdir/bigfile"
+
+# set quota to 10M
+set_quota $((10 * 1048576)) $workdir
+
+# write 9M file
+write_file $bigfile 9
+stat -c %s $bigfile
+rm $bigfile
+
+# try to write 11M file
+write_file $bigfile 11 # 11M
+stat -c %s $bigfile
+rm $bigfile
+
+# write 5 x 2M files
+for (( j = 1; j < 6; j++ )); do
+	smallfile="$workdir/smallfile_$j"
+	write_file $smallfile 2 # 2M
+	stat -c %s $smallfile
+done
+
+# try to write another 2M file, should fail
+smallfile="$workdir/smallfile_fail"
+write_file $smallfile 2
+stat -c %s $smallfile
+
+# reset quota
+set_quota 0 $workdir
+
+# write 2M file
+write_file $smallfile 2
+stat -c %s $smallfile
+
+# success, all done
+status=0
+exit
diff --git a/tests/ceph/002.out b/tests/ceph/002.out
new file mode 100644
index 000000000000..e9c597cf10a4
--- /dev/null
+++ b/tests/ceph/002.out
@@ -0,0 +1,64 @@
+QA output created by 002
+# file: mnt/test/002
+ceph.quota.max_bytes="1000000"
+
+# file: mnt/test/002
+ceph.quota.max_bytes="9223372036854775807"
+
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 2097152
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 3145728
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 4194304
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 5242880
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 6291456
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 7340032
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 8388608
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+9437184
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 2097152
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 3145728
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 4194304
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 5242880
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 6291456
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 7340032
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 8388608
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1048576/1048576 bytes at offset 9437184
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+pwrite: Disk quota exceeded
+10485760
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+2097152
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+2097152
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+2097152
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+2097152
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+2097152
+pwrite: Disk quota exceeded
+0
+wrote 1048576/1048576 bytes at offset 1048576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+2097152
diff --git a/tests/ceph/group b/tests/ceph/group
index e389bc6ec7ee..02da95169c67 100644
--- a/tests/ceph/group
+++ b/tests/ceph/group
@@ -1 +1,2 @@
 001 auto quick quota
+002 auto quick quota

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota
  2019-04-05 14:53 ` [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota Luis Henriques
@ 2019-04-06 12:45   ` Eryu Guan
  2019-04-08  9:16     ` Luis Henriques
  0 siblings, 1 reply; 5+ messages in thread
From: Eryu Guan @ 2019-04-06 12:45 UTC (permalink / raw)
  To: Luis Henriques; +Cc: fstests, Yan, Zheng, Dave Chinner, ceph-devel

On Fri, Apr 05, 2019 at 03:53:04PM +0100, Luis Henriques wrote:
> Simple set of checks for CephFS max_files directory quota implementation.
> 
> Signed-off-by: Luis Henriques <lhenriques@suse.com>

Just some quick/random comments inline, because I don't have a ceph env
to actually test the patches..

> ---
>  tests/ceph/001      | 86 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/ceph/001.out  |  9 +++++
>  tests/ceph/Makefile | 20 +++++++++++
>  tests/ceph/group    |  1 +
>  4 files changed, 116 insertions(+)
>  create mode 100755 tests/ceph/001
>  create mode 100644 tests/ceph/001.out
>  create mode 100644 tests/ceph/Makefile
>  create mode 100644 tests/ceph/group
> 
> diff --git a/tests/ceph/001 b/tests/ceph/001
> new file mode 100755
> index 000000000000..770e952cd8dc
> --- /dev/null
> +++ b/tests/ceph/001
> @@ -0,0 +1,86 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
> +#
> +# FS QA Test No. 001
> +#
> +# Test basic ceph.quota.max_files quota features.
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +workdir=$TEST_DIR/$seq
> +
> +tmp=/tmp/$$
> +status=1    # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -rf $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/attr
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs ceph
> +
> +_require_attrs
> +
> +set_quota()
> +{
> +	val=$1
> +	dir=$2

Declare function local variables as 'local'.

> +	$SETFATTR_PROG -n ceph.quota.max_files -v $val $dir >/dev/null 2>&1

I think it's better to dump the outputs from $SETFATTR_PROG to
$seqres.full, so we have debug logs when something went wrong. e.g.

	$SETFATTR_PROG -n ceph.quota.max_files -v $val $dir >>$seqres.full 2>&1

Also, remove $seqres.full file before test.

> +}
> +get_quota()
> +{
> +	dir=$1
> +	$GETFATTR_PROG -n ceph.quota.max_files $dir 2> /dev/null

We have a wrapper function around $GETFATTR_PROG called _getfattr(),
which is used to deal with different output formats from different
versions of getfattr tool, use the helper if possible.

And you need to filter $TEST_DIR here as well. And if you don't want the
"Removing leading '/' from absolute path names" messages, you could use
the "--absolute-names" option of getfattr, e.g.

	_getfattr -n ceph.quota.max_files --absolute-names $dir | _filter_test_dir

Thanks,
Eryu

> +}
> +
> +rm -rf $workdir
> +mkdir $workdir
> +
> +# test setting quota
> +set_quota 10 $workdir
> +get_quota $workdir
> +
> +# set quota to largest acceptable value (0x7FFFFFFFFFFFFFFF)
> +set_quota 9223372036854775807 $workdir
> +get_quota $workdir
> +
> +# test resetting quota
> +set_quota 0 $workdir
> +get_quota $workdir
> +
> +# set quota to invalid values (0x8000000000000000 and -1)
> +set_quota 9223372036854775808 $workdir
> +get_quota $workdir
> +
> +set_quota -1 $workdir
> +get_quota $workdir
> +
> +set_quota 5 $workdir
> +mkdir $workdir/0
> +touch $workdir/0/1
> +touch $workdir/0/2
> +touch $workdir/3
> +
> +touch $workdir/4 2>&1 | _filter_test_dir # should fail
> +mkdir $workdir/5 2>&1 | _filter_test_dir # should fail
> +
> +set_quota 0 $workdir
> +touch $workdir/4 # shouldn't fail
> +mkdir $workdir/5 # shouldn't fail
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/ceph/001.out b/tests/ceph/001.out
> new file mode 100644
> index 000000000000..6ddb007dce22
> --- /dev/null
> +++ b/tests/ceph/001.out
> @@ -0,0 +1,9 @@
> +QA output created by 001
> +# file: mnt/test/001
> +ceph.quota.max_files="10"
> +
> +# file: mnt/test/001
> +ceph.quota.max_files="9223372036854775807"
> +
> +touch: cannot touch 'TEST_DIR/001/4': Disk quota exceeded
> +mkdir: cannot create directory 'TEST_DIR/001/5': Disk quota exceeded
> diff --git a/tests/ceph/Makefile b/tests/ceph/Makefile
> new file mode 100644
> index 000000000000..f93862af4f31
> --- /dev/null
> +++ b/tests/ceph/Makefile
> @@ -0,0 +1,20 @@
> +#
> +# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
> +#
> +
> +TOPDIR = ../..
> +include $(TOPDIR)/include/builddefs
> +
> +CEPHFS_DIR = cephfs
> +TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(CEPHFS_DIR)
> +
> +include $(BUILDRULES)
> +
> +install:
> +	$(INSTALL) -m 755 -d $(TARGET_DIR)
> +	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
> +	$(INSTALL) -m 644 group $(TARGET_DIR)
> +	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
> +
> +# Nothing.
> +install-dev install-lib:
> diff --git a/tests/ceph/group b/tests/ceph/group
> new file mode 100644
> index 000000000000..e389bc6ec7ee
> --- /dev/null
> +++ b/tests/ceph/group
> @@ -0,0 +1 @@
> +001 auto quick quota

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota
  2019-04-06 12:45   ` Eryu Guan
@ 2019-04-08  9:16     ` Luis Henriques
  0 siblings, 0 replies; 5+ messages in thread
From: Luis Henriques @ 2019-04-08  9:16 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, Yan, Zheng, Dave Chinner, ceph-devel

Eryu Guan <guaneryu@gmail.com> writes:

> On Fri, Apr 05, 2019 at 03:53:04PM +0100, Luis Henriques wrote:
>> Simple set of checks for CephFS max_files directory quota implementation.
>> 
>> Signed-off-by: Luis Henriques <lhenriques@suse.com>
>
> Just some quick/random comments inline, because I don't have a ceph env
> to actually test the patches..
>

Thanks a lot for your comments, Eryu.  They all make sense, I'll send
out a new revision of these tests shortly.

Cheers,
-- 
Luis


>> --- tests/ceph/001 | 86 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/ceph/001.out | 9 +++++ tests/ceph/Makefile | 20 +++++++++++
>> tests/ceph/group | 1 + 4 files changed, 116 insertions(+) create mode
>> 100755 tests/ceph/001 create mode 100644 tests/ceph/001.out create
>> mode 100644 tests/ceph/Makefile create mode 100644 tests/ceph/group
>> 
>> diff --git a/tests/ceph/001 b/tests/ceph/001
>> new file mode 100755
>> index 000000000000..770e952cd8dc
>> --- /dev/null
>> +++ b/tests/ceph/001
>> @@ -0,0 +1,86 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
>> +#
>> +# FS QA Test No. 001
>> +#
>> +# Test basic ceph.quota.max_files quota features.
>> +#
>> +
>> +seq=`basename $0`
>> +seqres=$RESULT_DIR/$seq
>> +echo "QA output created by $seq"
>> +
>> +workdir=$TEST_DIR/$seq
>> +
>> +tmp=/tmp/$$
>> +status=1    # failure is the default!
>> +trap "_cleanup; exit \$status" 0 1 2 3 15
>> +
>> +_cleanup()
>> +{
>> +	cd /
>> +	rm -rf $tmp.*
>> +}
>> +
>> +# get standard environment, filters and checks
>> +. ./common/rc
>> +. ./common/filter
>> +. ./common/attr
>> +
>> +# real QA test starts here
>> +_supported_os Linux
>> +_supported_fs ceph
>> +
>> +_require_attrs
>> +
>> +set_quota()
>> +{
>> +	val=$1
>> +	dir=$2
>
> Declare function local variables as 'local'.
>
>> +	$SETFATTR_PROG -n ceph.quota.max_files -v $val $dir >/dev/null 2>&1
>
> I think it's better to dump the outputs from $SETFATTR_PROG to
> $seqres.full, so we have debug logs when something went wrong. e.g.
>
> 	$SETFATTR_PROG -n ceph.quota.max_files -v $val $dir >>$seqres.full 2>&1
>
> Also, remove $seqres.full file before test.
>
>> +}
>> +get_quota()
>> +{
>> +	dir=$1
>> +	$GETFATTR_PROG -n ceph.quota.max_files $dir 2> /dev/null
>
> We have a wrapper function around $GETFATTR_PROG called _getfattr(),
> which is used to deal with different output formats from different
> versions of getfattr tool, use the helper if possible.
>
> And you need to filter $TEST_DIR here as well. And if you don't want the
> "Removing leading '/' from absolute path names" messages, you could use
> the "--absolute-names" option of getfattr, e.g.
>
> 	_getfattr -n ceph.quota.max_files --absolute-names $dir | _filter_test_dir
>
> Thanks,
> Eryu
>
>> +}
>> +
>> +rm -rf $workdir
>> +mkdir $workdir
>> +
>> +# test setting quota
>> +set_quota 10 $workdir
>> +get_quota $workdir
>> +
>> +# set quota to largest acceptable value (0x7FFFFFFFFFFFFFFF)
>> +set_quota 9223372036854775807 $workdir
>> +get_quota $workdir
>> +
>> +# test resetting quota
>> +set_quota 0 $workdir
>> +get_quota $workdir
>> +
>> +# set quota to invalid values (0x8000000000000000 and -1)
>> +set_quota 9223372036854775808 $workdir
>> +get_quota $workdir
>> +
>> +set_quota -1 $workdir
>> +get_quota $workdir
>> +
>> +set_quota 5 $workdir
>> +mkdir $workdir/0
>> +touch $workdir/0/1
>> +touch $workdir/0/2
>> +touch $workdir/3
>> +
>> +touch $workdir/4 2>&1 | _filter_test_dir # should fail
>> +mkdir $workdir/5 2>&1 | _filter_test_dir # should fail
>> +
>> +set_quota 0 $workdir
>> +touch $workdir/4 # shouldn't fail
>> +mkdir $workdir/5 # shouldn't fail
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/ceph/001.out b/tests/ceph/001.out
>> new file mode 100644
>> index 000000000000..6ddb007dce22
>> --- /dev/null
>> +++ b/tests/ceph/001.out
>> @@ -0,0 +1,9 @@
>> +QA output created by 001
>> +# file: mnt/test/001
>> +ceph.quota.max_files="10"
>> +
>> +# file: mnt/test/001
>> +ceph.quota.max_files="9223372036854775807"
>> +
>> +touch: cannot touch 'TEST_DIR/001/4': Disk quota exceeded
>> +mkdir: cannot create directory 'TEST_DIR/001/5': Disk quota exceeded
>> diff --git a/tests/ceph/Makefile b/tests/ceph/Makefile
>> new file mode 100644
>> index 000000000000..f93862af4f31
>> --- /dev/null
>> +++ b/tests/ceph/Makefile
>> @@ -0,0 +1,20 @@
>> +#
>> +# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
>> +#
>> +
>> +TOPDIR = ../..
>> +include $(TOPDIR)/include/builddefs
>> +
>> +CEPHFS_DIR = cephfs
>> +TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(CEPHFS_DIR)
>> +
>> +include $(BUILDRULES)
>> +
>> +install:
>> +	$(INSTALL) -m 755 -d $(TARGET_DIR)
>> +	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
>> +	$(INSTALL) -m 644 group $(TARGET_DIR)
>> +	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
>> +
>> +# Nothing.
>> +install-dev install-lib:
>> diff --git a/tests/ceph/group b/tests/ceph/group
>> new file mode 100644
>> index 000000000000..e389bc6ec7ee
>> --- /dev/null
>> +++ b/tests/ceph/group
>> @@ -0,0 +1 @@
>> +001 auto quick quota
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-08  9:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-05 14:53 [PATCH v2 0/2] Initial CephFS tests Luis Henriques
2019-04-05 14:53 ` [PATCH v2 1/2] ceph: test basic ceph.quota.max_files quota Luis Henriques
2019-04-06 12:45   ` Eryu Guan
2019-04-08  9:16     ` Luis Henriques
2019-04-05 14:53 ` [PATCH v2 2/2] ceph: test basic ceph.quota.max_bytes quota Luis Henriques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).