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 <john.spray@redhat.com>
This commit is contained in:
John Spray 2016-11-06 10:59:08 +00:00
parent 42a59fc1b6
commit fa3098e0b7
3 changed files with 24 additions and 8 deletions

View 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)

View 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,
})

View 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,