From fa3098e0b70d081e1761079c68a90972b16ce829 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 6 Nov 2016 10:59:08 +0000 Subject: [PATCH] tasks/ceph_test_case: only construct needed parts 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 --- tasks/ceph_test_case.py | 7 ++++--- tasks/cephfs_test_runner.py | 23 ++++++++++++++++++----- tasks/vstart_runner.py | 2 ++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tasks/ceph_test_case.py b/tasks/ceph_test_case.py index d9eefe46d1faf..068f63b76e2a0 100644 --- a/tasks/ceph_test_case.py +++ b/tasks/ceph_test_case.py @@ -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) diff --git a/tasks/cephfs_test_runner.py b/tasks/cephfs_test_runner.py index c0e1acd123c72..d57e85d306f61 100644 --- a/tasks/cephfs_test_runner.py +++ b/tasks/cephfs_test_runner.py @@ -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, }) diff --git a/tasks/vstart_runner.py b/tasks/vstart_runner.py index 8bfab70b53b00..53cf50a795cfa 100644 --- a/tasks/vstart_runner.py +++ b/tasks/vstart_runner.py @@ -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, -- 2.39.5