From: Sebastian Wagner Date: Tue, 23 Feb 2021 15:05:22 +0000 (+0100) Subject: qa/tasks: some type annotations X-Git-Tag: v16.2.0~106^2~50 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6e2bf7f92a3476aa299cdcba749151bd4a3fabb2;p=ceph.git qa/tasks: some type annotations Mostly for making my IDE aware of things Signed-off-by: Sebastian Wagner (cherry picked from commit 340281fe76dc1d9170815f68a0553c50fb0b157f) --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 9d9e735091e6..b84d564debd5 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -1299,7 +1299,7 @@ class CephManager: """ def __init__(self, controller, ctx=None, config=None, logger=None, - cluster='ceph', cephadm=False): + cluster='ceph', cephadm=False) -> None: self.lock = threading.RLock() self.ctx = ctx self.config = config @@ -1358,7 +1358,7 @@ class CephManager: kwargs['args'] = prefix + list(kwargs['args']) return self.controller.run(**kwargs) - def raw_cluster_cmd(self, *args, **kwargs): + def raw_cluster_cmd(self, *args, **kwargs) -> str: """ Start ceph on a raw cluster. Return count """ diff --git a/qa/tasks/ceph_test_case.py b/qa/tasks/ceph_test_case.py index 23cf4839f63f..0f207c6409bd 100644 --- a/qa/tasks/ceph_test_case.py +++ b/qa/tasks/ceph_test_case.py @@ -1,9 +1,13 @@ +from typing import Optional, TYPE_CHECKING import unittest import time import logging from teuthology.orchestra.run import CommandFailedError +if TYPE_CHECKING: + from tasks.mgr.mgr_test_case import MgrCluster + log = logging.getLogger(__name__) class TestTimeoutError(RuntimeError): @@ -23,7 +27,7 @@ class CephTestCase(unittest.TestCase): backup_fs = None ceph_cluster = None mds_cluster = None - mgr_cluster = None + mgr_cluster: Optional['MgrCluster'] = None ctx = None mon_manager = None diff --git a/qa/tasks/cephadm_cases/test_cli.py b/qa/tasks/cephadm_cases/test_cli.py index ecd0124bd548..118cf0c387f2 100644 --- a/qa/tasks/cephadm_cases/test_cli.py +++ b/qa/tasks/cephadm_cases/test_cli.py @@ -6,10 +6,11 @@ log = logging.getLogger(__name__) class TestCephadmCLI(MgrTestCase): - def _cmd(self, *args): + def _cmd(self, *args) -> str: + assert self.mgr_cluster is not None return self.mgr_cluster.mon_manager.raw_cluster_cmd(*args) - def _orch_cmd(self, *args): + def _orch_cmd(self, *args) -> str: return self._cmd("orch", *args) def setUp(self): diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 226eb02d1922..ea71a999d006 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -214,7 +214,7 @@ class CephCluster(object): (result,) = self._ctx.cluster.only(first_mon).remotes.keys() return result - def __init__(self, ctx): + def __init__(self, ctx) -> None: self._ctx = ctx self.mon_manager = ceph_manager.CephManager(self.admin_remote, ctx=ctx, logger=log.getChild('ceph_manager')) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 8c7cd32cf56e..9053da99a7ae 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -994,7 +994,7 @@ class LocalCephManager(CephManager): kwargs['args'] = [os.path.join(BIN_PREFIX,'ceph')]+list(kwargs['args']) return self.controller.run(**kwargs) - def raw_cluster_cmd(self, *args, **kwargs): + def raw_cluster_cmd(self, *args, **kwargs) -> str: """ args like ["osd", "dump"} return stdout string