From: Sebastian Wagner Date: Mon, 6 Jan 2020 13:29:40 +0000 (+0100) Subject: pybind/mgr: Add test_orchestrator to mypy X-Git-Tag: v15.1.0~273^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bed4a6cc1aa1066f801c778598bc084fdd5ef67d;p=ceph-ci.git pybind/mgr: Add test_orchestrator to mypy Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 9e52eefc4b5..d1c29578573 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -6,7 +6,7 @@ import threading import functools from subprocess import check_output, CalledProcessError try: - from typing import Callable, List + from typing import Callable, List, Tuple except ImportError: pass # type checking @@ -168,19 +168,23 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): return self._services out = map(str, check_output(['ps', 'aux']).splitlines()) - types = [service_type] if service_type else ("mds", "osd", "mon", "rgw", "mgr") + types = (service_type, ) if service_type else ("mds", "osd", "mon", "rgw", "mgr") + assert isinstance(types, tuple) processes = [p for p in out if any([('ceph-' + t in p) for t in types])] result = [] for p in processes: sd = orchestrator.ServiceDescription() sd.nodename = 'localhost' - sd.service_instance = re.search('ceph-[^ ]+', p).group() + res = re.search('ceph-[^ ]+', p) + assert res + sd.service_instance = res.group() result.append(sd) return result def create_osds(self, drive_group): + # type: (orchestrator.DriveGroupSpec) -> TestCompletion def run(all_hosts): drive_group.validate(orchestrator.InventoryNode.get_host_names(all_hosts)) return self.get_hosts().then(run).then( @@ -208,6 +212,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): @deferred_write("Adding NFS service") def add_nfs(self, spec): + # type: (orchestrator.NFSServiceSpec) -> None assert isinstance(spec.pool, str) @deferred_write("remove_nfs") @@ -261,11 +266,15 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): @deferred_write("update_mgrs") def update_mgrs(self, spec): + # type: (orchestrator.StatefulServiceSpec) -> None + assert not spec.placement.hosts or len(spec.placement.hosts) == spec.placement.count assert all([isinstance(h, str) for h in spec.placement.hosts]) @deferred_write("update_mons") def update_mons(self, spec): + # type: (orchestrator.StatefulServiceSpec) -> None + assert not spec.placement.hosts or len(spec.placement.hosts) == spec.placement.count assert all([isinstance(h[0], str) for h in spec.placement.hosts]) assert all([isinstance(h[1], str) or h[1] is None for h in spec.placement.hosts]) diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 2de75e2e90c..8d7207ad4a8 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -12,4 +12,10 @@ basepython = python3 deps = -r requirements.txt mypy -commands = mypy --config-file=../../mypy.ini orchestrator.py cephadm/module.py rook/module.py ansible/module.py orchestrator_cli/module.py \ No newline at end of file +commands = mypy --config-file=../../mypy.ini \ + ansible/module.py \ + cephadm/module.py \ + orchestrator.py \ + orchestrator_cli/module.py \ + rook/module.py \ + test_orchestrator/module.py