]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: Add mds caps test for testing fs read and a path rw
authorKotresh HR <khiremat@redhat.com>
Sun, 28 Jul 2024 18:43:27 +0000 (00:13 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 30 Jul 2024 17:48:22 +0000 (23:18 +0530)
Fixes: https://tracker.ceph.com/issues/67212
Signed-off-by: Kotresh HR <khiremat@redhat.com>
qa/tasks/cephfs/caps_helper.py
qa/tasks/cephfs/test_admin.py

index addd2da89e43f8fbf0573c1e8b31ef4c8238f245..eddac3d609c63a311417726a67769d2084b33ab2 100644 (file)
@@ -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):
     '''
index b4efdfc57c9a44f530414a878a248e592fc94334..7bfb1c5faa2419418e6c41176d5d10512974a5a5 100644 (file)
@@ -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))