From: Christopher Hoffman Date: Fri, 6 Oct 2023 21:43:34 +0000 (+0000) Subject: qa: Add test coverage for vxattr behavior X-Git-Tag: v19.2.3~447^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=071fe81511b31de01dd8f36e9f0ee305b3b0ec77;p=ceph.git qa: Add test coverage for vxattr behavior Add tests to validate default and remove xattr behaviors. Signed-off-by: Christopher Hoffman (cherry picked from commit 697c2fc877e0ad7af79cd38daeb441ee4ffef6d0) --- diff --git a/qa/tasks/cephfs/test_subvolume.py b/qa/tasks/cephfs/test_subvolume.py index 6987d060cbf6..f67b33da9bad 100644 --- a/qa/tasks/cephfs/test_subvolume.py +++ b/qa/tasks/cephfs/test_subvolume.py @@ -133,6 +133,33 @@ class TestSubvolume(CephFSTestCase): self.mount_a.run_shell(['ln', 'group/subvol2/file1', 'group/subvol3/file1']) + def test_subvolume_setfattr_empty_value(self): + """ + To verify that an empty value fails on subvolume xattr + """ + + # create subvol + self.mount_a.run_shell(['mkdir', 'group/subvol4']) + + try: + self.mount_a.setfattr('group/subvol4', 'ceph.dir.subvolume', '') + except CommandFailedError: + pass + else: + self.fail("run_shell should raise CommandFailedError") + + def test_subvolume_rmattr(self): + """ + To verify that rmattr can be used to reset subvolume xattr + """ + + # create subvol + self.mount_a.run_shell(['mkdir', 'group/subvol4']) + self.mount_a.setfattr('group/subvol4', 'ceph.dir.subvolume', '1') + + # clear subvolume flag + self.mount_a.removexattr('group/subvol4', 'ceph.dir.subvolume') + def test_subvolume_create_subvolume_inside_subvolume(self): """ To verify that subvolume can't be created inside a subvolume diff --git a/qa/workunits/fs/misc/general_vxattrs.sh b/qa/workunits/fs/misc/general_vxattrs.sh new file mode 100755 index 000000000000..e7d467db616a --- /dev/null +++ b/qa/workunits/fs/misc/general_vxattrs.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# test setfattr remove, and check values of vxattr +# after remove for vxattr, where possible. + +set -ex + +mkdir -p dir + +#ceph.dir.pin test, def val -1, reset val -1 +getfattr -n ceph.dir.pin dir | grep 'ceph.dir.pin="-1"' +setfattr -n ceph.dir.pin dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -n ceph.dir.pin -v 1 dir +getfattr -n ceph.dir.pin dir | grep 'ceph.dir.pin="1"' +setfattr -x ceph.dir.pin dir +getfattr -n ceph.dir.pin dir | grep 'ceph.dir.pin="-1"' + +#TODO: Once test machines support getfattr for vxattr, uncomment getfattr below +#see: https://lists.ceph.io/hyperkitty/list/ceph-users@ceph.io/thread/EZL3POLMQLMMNBPAJ2QQ2BAKH44VUNJU/#JJNRRYLUKUAUN5HIL5A7Q4N63OCLWQXF +#for further detail + +#ceph.dir.pin.distributed, def val 0, reset val 0 +#getfattr -n ceph.dir.pin.distributed dir | grep 'ceph.dir.pin.distributed="0"' +setfattr -n ceph.dir.pin.distributed dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -n ceph.dir.pin.distributed -v 1 dir +#getfattr -n ceph.dir.pin.distributed dir | grep 'ceph.dir.pin.distributed="1"' +setfattr -x ceph.dir.pin.distributed dir +#getfattr -n ceph.dir.pin.distributed dir | grep 'ceph.dir.pin.distributed="0"' + +#ceph.dir.pin.random def val 0, reset val 0 +#getfattr -n ceph.dir.pin.random dir | grep 'ceph.dir.pin.random="0"' +setfattr -n ceph.dir.pin.random dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -n ceph.dir.pin.random -v 0.01 dir +#getfattr -n ceph.dir.pin.random dir | grep 'ceph.dir.pin.random="0.01"' +setfattr -x ceph.dir.pin.random dir +#getfattr -n ceph.dir.pin.random dir | grep 'ceph.dir.pin.random="0"' + +#ceph.quota, def value 0, reset val 0 +setfattr -n ceph.quota.max_bytes dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -n ceph.quota.max_bytes -v 100000000 dir +#getfattr -n ceph.quota.max_bytes dir | grep 'ceph.quota.max_bytes="100000000"' +setfattr -x ceph.quota.max_bytes dir +setfattr -n ceph.quota.max_files dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -n ceph.quota.max_files -v 10000 dir +#getfattr -n ceph.quota.max_files dir | grep 'ceph.quota.max_files="10000"' +setfattr -x ceph.quota.max_files dir + +rmdir dir + +echo OK + diff --git a/qa/workunits/fs/misc/layout_vxattrs.sh b/qa/workunits/fs/misc/layout_vxattrs.sh index 81133627347b..e87e9aa87d07 100755 --- a/qa/workunits/fs/misc/layout_vxattrs.sh +++ b/qa/workunits/fs/misc/layout_vxattrs.sh @@ -105,6 +105,23 @@ getfattr -n ceph.file.layout.stripe_count dir/file | grep -q 8 getfattr -n ceph.file.layout.object_size dir/file | grep -q 10485760 getfattr -n ceph.file.layout.pool_namespace dir/file | grep -q dirns +#Per https://docs.ceph.com/en/latest/cephfs/file-layouts/#clearing-layouts, pool_namespace +#can be individually removed, while other layout xattrs must be cleared together. +setfattr -x ceph.dir.layout.pool dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -x ceph.dir.layout.pool_id dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -x ceph.dir.layout.pool_name dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -x ceph.dir.layout.stripe_unit dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -x ceph.dir.layout.stripe_count dir 2>&1 | grep "setfattr: dir: Invalid argument" +setfattr -x ceph.dir.layout.object_size dir 2>&1 | grep "setfattr: dir: Invalid argument" + +setfattr -x ceph.file.layout.pool dir/file 2>&1 | grep "setfattr: dir/file: Invalid argument" +setfattr -x ceph.file.layout.pool_id dir/file 2>&1 | grep "setfattr: dir/file: Invalid argument" +setfattr -x ceph.file.layout.pool_name dir/file 2>&1 | grep "setfattr: dir/file: Invalid argument" +setfattr -x ceph.file.layout.stripe_unit dir/file 2>&1 | grep "setfattr: dir/file: Invalid argument" +setfattr -x ceph.file.layout.stripe_count dir/file 2>&1 | grep "setfattr: dir/file: Invalid argument" +setfattr -x ceph.file.layout.object_size dir/file 2>&1 | grep "setfattr: dir/file: Invalid argument" +setfattr -x ceph.file.layout.pool_namespace dir/file + setfattr -x ceph.dir.layout.pool_namespace dir getfattr -n ceph.dir.layout dir | grep -q -v pool_namespace=dirns