]> 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>
Wed, 11 Sep 2024 09:15:58 +0000 (14:45 +0530)
Fixes: https://tracker.ceph.com/issues/67212
Signed-off-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit 983f893fb938b097682c10f3120460bfb2094bfd)

qa/tasks/cephfs/caps_helper.py
qa/tasks/cephfs/test_admin.py

index c17063e78b31ed798ca1d65df9e7686c926bcaaf..7a684aca191517b8c8695ea5591d18b3d91b8ce1 100644 (file)
@@ -227,11 +227,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 '
@@ -265,7 +268,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):
         """
@@ -283,11 +287,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:
@@ -325,6 +331,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 34dc59ab2a230754a07fbd2ebd665859fa1d2d5d..a587b41c764f8e9609e510516e2598a379d31c4b 100644 (file)
@@ -1553,6 +1553,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))