]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: Add tests for nfs
authorVarsha Rao <varao@redhat.com>
Thu, 30 Apr 2020 10:10:52 +0000 (15:40 +0530)
committerVarsha Rao <varao@redhat.com>
Fri, 29 May 2020 09:17:32 +0000 (14:47 +0530)
Signed-off-by: Varsha Rao <varao@redhat.com>
qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml [new file with mode: 0644]
qa/tasks/cephfs/test_nfs.py [new file with mode: 0644]

diff --git a/qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml b/qa/suites/rados/cephadm/workunits/task/test_orch_cli.yaml
new file mode 100644 (file)
index 0000000..d57b3e4
--- /dev/null
@@ -0,0 +1,17 @@
+roles:
+- - host.a
+  - osd.0
+  - osd.1
+  - osd.2
+  - mon.a
+  - mgr.a
+  - client.0
+tasks:
+- install:
+- cephadm:
+- cephadm.shell:
+    host.a:
+      - ceph orch apply mds 1
+- cephfs_test_runner:
+    modules:
+      - tasks.cephfs.test_nfs
diff --git a/qa/tasks/cephfs/test_nfs.py b/qa/tasks/cephfs/test_nfs.py
new file mode 100644 (file)
index 0000000..fdf184b
--- /dev/null
@@ -0,0 +1,83 @@
+import os
+import json
+import time
+import errno
+import logging
+from io import BytesIO
+
+from tasks.mgr.mgr_test_case import MgrTestCase
+from teuthology.exceptions import CommandFailedError
+
+log = logging.getLogger(__name__)
+
+
+class TestNFS(MgrTestCase):
+    def _nfs_cmd(self, *args):
+        return self.mgr_cluster.mon_manager.raw_cluster_cmd("nfs", *args)
+
+    def _orch_cmd(self, *args):
+        return self.mgr_cluster.mon_manager.raw_cluster_cmd("orch", *args)
+
+    def _sys_cmd(self, cmd):
+        cmd[0:0] = ['sudo']
+        ret = self.ctx.cluster.run(args=cmd, check_status=False, stdout=BytesIO(), stderr=BytesIO())
+        stdout = ret[0].stdout
+        if stdout:
+            # It's RemoteProcess defined in teuthology/orchestra/run.py
+            return stdout.getvalue()
+
+    def setUp(self):
+        super(TestNFS, self).setUp()
+        self._load_module("cephadm")
+        self._orch_cmd("set", "backend", "cephadm")
+
+        self.cluster_id = "test"
+        self.export_type = "cephfs"
+        self.pseudo_path = "/cephfs"
+        self.expected_name = 'nfs.ganesha-test'
+
+    def _check_port_status(self):
+        log.info("NETSTAT")
+        self._sys_cmd(['netstat', '-tnlp'])
+
+    def _check_nfs_server_status(self):
+        res = self._sys_cmd(['systemctl', 'status', 'nfs-server'])
+        if isinstance(res, bytes) and b'Active: active' in res:
+            self._disable_nfs()
+
+    def _disable_nfs(self):
+        log.info("Disabling NFS")
+        self._sys_cmd(['systemctl', 'disable', 'nfs-server', '--now'])
+
+    def _check_nfs_status(self):
+        return self._orch_cmd('ls', 'nfs')
+
+    def _check_idempotency(self, *args):
+        for _ in range(2):
+            self._nfs_cmd(*args)
+
+    def test_create_cluster(self):
+        self._check_nfs_server_status()
+        self._nfs_cmd("cluster", "create", self.export_type, self.cluster_id)
+        time.sleep(8)
+        orch_output = self._check_nfs_status()
+        expected_status = '1/1'
+        try:
+            if self.expected_name not in orch_output or expected_status not in orch_output:
+                raise CommandFailedError("NFS Ganesha cluster could not be deployed")
+        except (TypeError, CommandFailedError):
+            raise
+
+    def test_create_cluster_idempotent(self):
+        self._check_nfs_server_status()
+        self._check_idempotency("cluster", "create", self.export_type, self.cluster_id)
+
+    def test_delete_cluster(self):
+        self.test_create_cluster()
+        self._nfs_cmd("cluster", "delete", self.cluster_id)
+        time.sleep(8)
+        orch_output = self._check_nfs_status()
+        self.assertEqual("No services reported\n", orch_output)
+
+    def test_delete_cluster_idempotent(self):
+        self._check_idempotency("cluster", "delete", self.cluster_id)