]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs/nfs: Add tests for updating fs exports 40307/head
authorVarsha Rao <varao@redhat.com>
Mon, 8 Feb 2021 09:18:55 +0000 (14:48 +0530)
committerVarsha Rao <varao@redhat.com>
Mon, 22 Mar 2021 12:30:46 +0000 (18:00 +0530)
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit 0928858db015c11989266fc1e1f935661081f7a3)

qa/tasks/cephfs/test_nfs.py

index ca2b86a017f3307522ba6a0d1d3ef5895f9268cf..30d9d6df47b655c64b1c71b7b37baa2921bb8b24 100644 (file)
@@ -215,11 +215,17 @@ class TestNFS(MgrTestCase):
         self.sample_export['fsal']['user_id'] = self.cluster_id + '4'
         self.assertDictEqual(self.sample_export, nfs_output[3])
 
+    def _get_export(self):
+        '''
+        Returns export block in json format
+        '''
+        return json.loads(self._nfs_cmd('export', 'get', self.cluster_id, self.pseudo_path))
+
     def _test_get_export(self):
         '''
         Test fetching of created export.
         '''
-        nfs_output = json.loads(self._nfs_cmd('export', 'get', self.cluster_id, self.pseudo_path))
+        nfs_output = self._get_export()
         self.assertDictEqual(self.sample_export, nfs_output)
 
     def _check_export_obj_deleted(self, conf_obj=False):
@@ -264,6 +270,17 @@ class TestNFS(MgrTestCase):
         finally:
             self.ctx.cluster.run(args=['sudo', 'umount', '/mnt'])
 
+    def _write_to_read_only_export(self, pseudo_path, port, ip):
+        '''
+        Check if write to read only export fails
+        '''
+        try:
+            self._test_mnt(pseudo_path, port, ip)
+        except CommandFailedError as e:
+            # Write to cephfs export should fail for test to pass
+            if e.exitstatus != errno.EPERM:
+                raise
+
     def test_create_and_delete_cluster(self):
         '''
         Test successful creation and deletion of the nfs cluster.
@@ -430,12 +447,7 @@ class TestNFS(MgrTestCase):
         self._test_create_cluster()
         self._create_export(export_id='1', create_fs=True, extra_cmd=[self.pseudo_path, '--readonly'])
         port, ip = self._get_port_ip_info()
-        try:
-            self._test_mnt(self.pseudo_path, port, ip)
-        except CommandFailedError as e:
-            # Write to cephfs export should fail for test to pass
-            if e.exitstatus != errno.EPERM:
-                raise
+        self._write_to_read_only_export(self.pseudo_path, port, ip)
         self._test_delete_cluster()
 
     def test_cluster_info(self):
@@ -534,3 +546,53 @@ class TestNFS(MgrTestCase):
             # Command should fail for test to pass
             if e.exitstatus != errno.ENOENT:
                 raise
+
+    def test_update_export(self):
+        '''
+        Test update of exports
+        '''
+        self._create_default_export()
+        port, ip = self._get_port_ip_info()
+        self._test_mnt(self.pseudo_path, port, ip)
+        export_block = self._get_export()
+        new_pseudo_path = '/testing'
+        export_block['pseudo'] = new_pseudo_path
+        export_block['access_type'] = 'RO'
+        self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'export', 'update', '-i', '-'],
+                stdin=json.dumps(export_block))
+        self._check_nfs_cluster_status('running', 'NFS Ganesha cluster restart failed')
+        self._write_to_read_only_export(new_pseudo_path, port, ip)
+        self._test_delete_cluster()
+
+    def test_update_export_with_invalid_values(self):
+        '''
+        Test update of export with invalid values
+        '''
+        self._create_default_export()
+        export_block = self._get_export()
+
+        def update_with_invalid_values(key, value, fsal=False):
+            export_block_new = dict(export_block)
+            if fsal:
+                export_block_new['fsal'] = dict(export_block['fsal'])
+                export_block_new['fsal'][key] = value
+            else:
+                export_block_new[key] = value
+            try:
+                self.ctx.cluster.run(args=['sudo', 'ceph', 'nfs', 'export', 'update', '-i', '-'],
+                        stdin=json.dumps(export_block_new))
+            except CommandFailedError:
+                pass
+
+        update_with_invalid_values('export_id', 9)
+        update_with_invalid_values('cluster_id', 'testing_new')
+        update_with_invalid_values('pseudo', 'test_relpath')
+        update_with_invalid_values('access_type', 'W')
+        update_with_invalid_values('squash', 'no_squash')
+        update_with_invalid_values('security_label', 'invalid')
+        update_with_invalid_values('protocols', [2])
+        update_with_invalid_values('transports', ['UD'])
+        update_with_invalid_values('name', 'RGW', True)
+        update_with_invalid_values('user_id', 'testing_export', True)
+        update_with_invalid_values('fs_name', 'b', True)
+        self._test_delete_cluster()