From: Kiefer Chang Date: Wed, 18 Mar 2020 12:03:59 +0000 (+0800) Subject: mgr/test_orchestrator: fix service filtering when using dummy data X-Git-Tag: v15.2.0~15^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F34023%2Fhead;p=ceph.git mgr/test_orchestrator: fix service filtering when using dummy data Signed-off-by: Kiefer Chang --- diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 10fa8482e6ba..db751cb84dd7 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -197,17 +197,23 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): if self._services: # Dummy data services = self._services + # Can't deduce service type from dummy data (no daemons). + # Assume service_type is service_name. + if service_type is not None: + services = list(filter(lambda s: s.service_name == service_type, services)) else: # Deduce services from daemons running on localhost all_daemons = self._get_ceph_daemons() services = [] for daemon_type, daemons in itertools.groupby(all_daemons, key=lambda d: d.daemon_type): + if service_type is not None and service_type != daemon_type: + continue daemon_size = len(list(daemons)) services.append(orchestrator.ServiceDescription( service_name=daemon_type, size=daemon_size, running=daemon_size)) def _filter_func(svc): - if service_type is not None and service_type != svc.service_name: + if service_name is not None and service_name != svc.service_name: return False return True