]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/ceph_test_case: only construct needed parts
authorJohn Spray <john.spray@redhat.com>
Sun, 6 Nov 2016 10:59:08 +0000 (10:59 +0000)
committerJohn Spray <john.spray@redhat.com>
Sun, 6 Nov 2016 14:20:19 +0000 (14:20 +0000)
Don't construct Filesystem and MDSCluster if there
are no MDSs in the system, don't construct MgrCluster
if there are no mgrs in the system.

Signed-off-by: John Spray <john.spray@redhat.com>
tasks/ceph_test_case.py
tasks/cephfs_test_runner.py
tasks/vstart_runner.py

index d9eefe46d1faf68390bcd22d2e45c0669218549f..068f63b76e2a0347ccff54fccf45c8a757020c39 100644 (file)
@@ -18,6 +18,7 @@ class CephTestCase(unittest.TestCase):
     # Environment references
     mounts = None
     fs = None
+    ceph_cluster = None
     mds_cluster = None
     mgr_cluster = None
     ctx = None
@@ -32,7 +33,7 @@ class CephTestCase(unittest.TestCase):
         :param expected_pattern: a string that you expect to see in the log output
         """
 
-        ceph_manager = self.fs.mon_manager
+        ceph_manager = self.ceph_cluster.mon_manager
 
         class ContextManager(object):
             def match(self):
@@ -73,7 +74,7 @@ class CephTestCase(unittest.TestCase):
         Wait until 'ceph health' contains messages matching the pattern
         """
         def seen_health_warning():
-            health = self.fs.mon_manager.get_mon_health()
+            health = self.ceph_cluster.mon_manager.get_mon_health()
             summary_strings = [s['summary'] for s in health['summary']]
             if len(summary_strings) == 0:
                 log.debug("Not expected number of summary strings ({0})".format(summary_strings))
@@ -93,7 +94,7 @@ class CephTestCase(unittest.TestCase):
         Wait until `ceph health` returns no messages
         """
         def is_clear():
-            health = self.fs.mon_manager.get_mon_health()
+            health = self.ceph_cluster.mon_manager.get_mon_health()
             return len(health['summary']) == 0
 
         self.wait_until_true(is_clear, timeout)
index c0e1acd123c720dfe2c90d2f153b84723c82b719..d57e85d306f61d117a59b2650177701df633caba 100644 (file)
@@ -4,7 +4,8 @@ import os
 import unittest
 from unittest import suite, loader, case
 from teuthology.task import interactive
-from tasks.cephfs.filesystem import Filesystem, MDSCluster
+from teuthology import misc
+from tasks.cephfs.filesystem import Filesystem, MDSCluster, CephCluster
 from tasks.mgr.mgr_test_case import MgrCluster
 
 log = logging.getLogger(__name__)
@@ -115,12 +116,23 @@ def task(ctx, config):
            fail_on_skip: false
 
     """
-    fs = Filesystem(ctx)
-    mds_cluster = MDSCluster(ctx)
-    mgr_cluster = MgrCluster(ctx)
+
+    ceph_cluster = CephCluster(ctx)
+
+    if len(list(misc.all_roles_of_type(ctx.cluster, 'mds'))):
+        mds_cluster = MDSCluster(ctx)
+        fs = Filesystem(ctx)
+    else:
+        mds_cluster = None
+        fs = None
+
+    if len(list(misc.all_roles_of_type(ctx.cluster, 'mgr'))):
+        mgr_cluster = MgrCluster(ctx)
+    else:
+        mgr_cluster = None
 
     # Mount objects, sorted by ID
-    if (hasattr(ctx, 'mounts')):
+    if hasattr(ctx, 'mounts'):
         mounts = [v for k, v in sorted(ctx.mounts.items(), lambda a, b: cmp(a[0], b[0]))]
     else:
         # The test configuration has a filesystem but no fuse/kclient mounts
@@ -130,6 +142,7 @@ def task(ctx, config):
         "ctx": ctx,
         "mounts": mounts,
         "fs": fs,
+        "ceph_cluster": ceph_cluster,
         "mds_cluster": mds_cluster,
         "mgr_cluster": mgr_cluster,
     })
index 8bfab70b53b002a9cc3a9dfcf0df4e7548bcf7a6..53cf50a795cfa9b3d8b0070cf3025a9c0a702d43 100644 (file)
@@ -819,6 +819,7 @@ def exec_test():
             if os.path.exists(mount.mountpoint):
                 os.rmdir(mount.mountpoint)
     filesystem = LocalFilesystem(ctx)
+    ceph_cluster = LocalCephCluster(ctx)
     mds_cluster = LocalMDSCluster(ctx)
     mgr_cluster = LocalMgrCluster(ctx)
 
@@ -844,6 +845,7 @@ def exec_test():
     decorating_loader = DecoratingLoader({
         "ctx": ctx,
         "mounts": mounts,
+        "ceph_cluster": ceph_cluster,
         "fs": filesystem,
         "mds_cluster": mds_cluster,
         "mgr_cluster": mgr_cluster,