diff --git a/qa/tasks/cephfs/caps_helper.py b/qa/tasks/cephfs/caps_helper.py index addd2da89e4..eddac3d609c 100644 --- a/qa/tasks/cephfs/caps_helper.py +++ b/qa/tasks/cephfs/caps_helper.py @@ -204,11 +204,14 @@ class MdsCapTester: """ # CephFS mount where read/write test will be conducted. self.mount = mount + # Set new file creation path + self.new_file = os_path_join(self.mount.hostfs_mntpt, path.lstrip('/'), 'new_file') # Path where out test file located. self.path = self._gen_test_file_path(path) # Data that out test file will contain. self.data = self._gen_test_file_data() + self.mount.write_file(self.path, self.data) log.info(f'Test file has been created on FS ' f'"{self.mount.cephfs_name}" at path "{self.path}" with the ' @@ -242,7 +245,8 @@ class MdsCapTester: self.path = {self.path} cephfs_name = {self.mount.cephfs_name} cephfs_mntpt = {self.mount.cephfs_mntpt} - hostfs_mntpt = {self.mount.hostfs_mntpt}''') + hostfs_mntpt = {self.mount.hostfs_mntpt} + self.new_file_path = {self.new_file}''') def run_mds_cap_tests(self, perm, mntpt=None): """ @@ -260,11 +264,13 @@ class MdsCapTester: # cephfs dir serving as root for current mnt: /dir1/dir2 # therefore, final path: /mnt/cephfs_x/testdir self.path = self.path.replace(mntpt, '') + self.new_file = self.new_file.replace(mntpt, '') self.conduct_pos_test_for_read_caps() if perm == 'rw': self.conduct_pos_test_for_write_caps() + self.conduct_pos_test_for_new_file_creation() elif perm == 'r': self.conduct_neg_test_for_write_caps() else: @@ -302,6 +308,12 @@ class MdsCapTester: log.info('absence of write perm was tested successfully: ' f'failed to be write data to file {self.path}.') + def conduct_pos_test_for_new_file_creation(self, sudo_write=False): + log.info(f'test write perm: try creating a new "{self.new_file}"') + self.mount.create_file(self.new_file) + log.info(f'write perm was tested successfully: new file "{self.new_file}" ' + 'created successfully') + class CapTester(MonCapTester, MdsCapTester): ''' diff --git a/qa/tasks/cephfs/test_admin.py b/qa/tasks/cephfs/test_admin.py index b4efdfc57c9..7bfb1c5faa2 100644 --- a/qa/tasks/cephfs/test_admin.py +++ b/qa/tasks/cephfs/test_admin.py @@ -1818,6 +1818,28 @@ class TestFsAuthorize(CephFSTestCase): self._remount(keyring) self.captester.run_mds_cap_tests(PERM) + def test_fs_read_and_single_path_rw(self): + """ + Tests the file creation using 'touch' cmd on a specific path + which has 'rw' caps and 'r' caps on the rest of the fs. + + The mds auth caps with 'rw' caps on a specific path and 'r' caps + on the rest of the fs has an issue. The file creation using 'touch' + cmd on the fuse client used to fail while doing setattr. + Please see https://tracker.ceph.com/issues/67212 + + The new file creation test using 'touch' cmd is added to + 'MdsCapTester.run_mds_cap_tests' which eventually gets + called by '_remount_and_run_tests' + """ + FS_AUTH_CAPS = (('/', 'r'), ('/dir2', 'rw')) + self.mount_a.run_shell('mkdir -p ./dir2') + self.captesters = (CapTester(self.mount_a, '/'), + CapTester(self.mount_a, '/dir2')) + keyring = self.fs.authorize(self.client_id, FS_AUTH_CAPS) + + self._remount_and_run_tests(FS_AUTH_CAPS, keyring) + def test_multiple_path_r(self): PERM = 'r' FS_AUTH_CAPS = (('/dir1/dir12', PERM), ('/dir2/dir22', PERM))