]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard_v2: mocking of rados and rbd modules
authorRicardo Dias <rdias@suse.com>
Fri, 2 Feb 2018 15:33:44 +0000 (15:33 +0000)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:05 +0000 (13:07 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/dashboard_v2/.pylintrc
src/pybind/mgr/dashboard_v2/__init__.py
src/pybind/mgr/dashboard_v2/ceph_module_mock.py [deleted file]
src/pybind/mgr/dashboard_v2/cephmock/__init__.py [new file with mode: 0644]
src/pybind/mgr/dashboard_v2/cephmock/ceph_module_mock.py [new file with mode: 0644]
src/pybind/mgr/dashboard_v2/cephmock/rados_mock.py [new file with mode: 0644]
src/pybind/mgr/dashboard_v2/cephmock/rbd_mock.py [new file with mode: 0644]
src/pybind/mgr/dashboard_v2/tox.ini

index f43d157e452da7d2d45dffd3f4464050ab20cd29..ab5d1f8a7777f48d009b58e104731191ee859dd9 100644 (file)
@@ -3,7 +3,7 @@
 # A comma-separated list of package or module names from where C extensions may
 # be loaded. Extensions are loading into the active Python interpreter and may
 # run arbitrary code
-extension-pkg-whitelist=
+extension-pkg-whitelist=rados,rbd
 
 # Add files or directories to the blacklist. They should be base names, not
 # paths.
index 5102e244e22e1ebc27166fdb14505f1e6d8ec57d..51e53764ee80104775c8277886375d6a1ef63e1a 100644 (file)
@@ -26,8 +26,10 @@ else:
     import logging
     import sys
     # pylint: disable=W0403
-    from . import ceph_module_mock
+    from .cephmock import ceph_module_mock, rados_mock, rbd_mock
     sys.modules['ceph_module'] = ceph_module_mock
+    sys.modules['rados'] = rados_mock
+    sys.modules['rbd'] = rbd_mock
     logging.basicConfig(level=logging.WARNING)
     logger = logging.getLogger(__name__)
     logging.root.handlers[0].setLevel(logging.WARNING)
diff --git a/src/pybind/mgr/dashboard_v2/ceph_module_mock.py b/src/pybind/mgr/dashboard_v2/ceph_module_mock.py
deleted file mode 100644 (file)
index 254b1d9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# -*- coding: utf-8 -*-
-
-
-class BasePyOSDMap(object):
-    pass
-
-
-class BasePyOSDMapIncremental(object):
-    pass
-
-
-class BasePyCRUSH(object):
-    pass
-
-
-class BaseMgrStandbyModule(object):
-    pass
-
-
-class BaseMgrModule(object):
-    # pylint: disable=W0613
-    def __init__(self, py_modules_ptr, this_ptr):
-        self.config_key_map = {}
-
-    def _ceph_get_version(self):
-        return 'ceph-13.0.0'
-
-    def _ceph_get_mgr_id(self):
-        return 'x'
-
-    def _ceph_set_config(self, key, value):
-        self.config_key_map[key] = value
-
-    def _ceph_get_config(self, key):
-        return self.config_key_map.get(key, None)
-
-    def _ceph_log(self, *args):
-        pass
diff --git a/src/pybind/mgr/dashboard_v2/cephmock/__init__.py b/src/pybind/mgr/dashboard_v2/cephmock/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/pybind/mgr/dashboard_v2/cephmock/ceph_module_mock.py b/src/pybind/mgr/dashboard_v2/cephmock/ceph_module_mock.py
new file mode 100644 (file)
index 0000000..edb3c34
--- /dev/null
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+
+class BasePyOSDMap(object):
+    pass
+
+
+class BasePyOSDMapIncremental(object):
+    pass
+
+
+class BasePyCRUSH(object):
+    pass
+
+
+class BaseMgrStandbyModule(object):
+    pass
+
+
+class BaseMgrModule(object):
+    # pylint: disable=W0613
+    def __init__(self, py_modules_ptr, this_ptr):
+        self.config_key_map = {}
+
+    def _ceph_get_version(self):
+        return 'ceph-13.0.0'
+
+    def _ceph_get_mgr_id(self):
+        return 'x'
+
+    def _ceph_set_config(self, key, value):
+        self.config_key_map[key] = value
+
+    def _ceph_get_config(self, key):
+        return self.config_key_map.get(key, None)
+
+    def _ceph_log(self, *args):
+        pass
+
+    def _ceph_get_context(self):
+        return None
diff --git a/src/pybind/mgr/dashboard_v2/cephmock/rados_mock.py b/src/pybind/mgr/dashboard_v2/cephmock/rados_mock.py
new file mode 100644 (file)
index 0000000..3e51f40
--- /dev/null
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+
+
+class Rados(object):
+    def __init__(self, *args, **kwargs):
+        pass
+
+    def connect(self):
+        pass
+
+    def open_ioctx(self, pool_name):
+        pass
diff --git a/src/pybind/mgr/dashboard_v2/cephmock/rbd_mock.py b/src/pybind/mgr/dashboard_v2/cephmock/rbd_mock.py
new file mode 100644 (file)
index 0000000..3b433ed
--- /dev/null
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+
+
+RBD_FEATURE_LAYERING = "RBD_FEATURE_LAYERING"
+RBD_FEATURE_STRIPINGV2 = "RBD_FEATURE_STRIPINGV2"
+RBD_FEATURE_EXCLUSIVE_LOCK = "RBD_FEATURE_EXCLUSIVE_LOCK"
+RBD_FEATURE_OBJECT_MAP = "RBD_FEATURE_OBJECT_MAP"
+RBD_FEATURE_FAST_DIFF = "RBD_FEATURE_FAST_DIFF"
+RBD_FEATURE_DEEP_FLATTEN = "RBD_FEATURE_DEEP_FLATTEN"
+RBD_FEATURE_JOURNALING = "RBD_FEATURE_JOURNALING"
+RBD_FEATURE_DATA_POOL = "RBD_FEATURE_DATA_POOL"
+RBD_FEATURE_OPERATIONS = "RBD_FEATURE_OPERATIONS"
+
+
+class RBD(object):
+    def __init__(self, *args, **kwargs):
+        pass
+
+    def list(self, ioctx):
+        pass
+
+
+class Image(object):
+    def __init__(self, *args, **kwargs):
+        pass
+
+    def stat(self):
+        pass
+
+    def features(self):
+        pass
index 7afc92647a762caadede0fd43e141fce182ffdc0..6fcfcdacef732d25f72bb9e2435fef0544c15ae6 100644 (file)
@@ -8,6 +8,8 @@ setenv=
     UNITTEST=true
     WEBTEST_INTERACTIVE=false
     COVERAGE_FILE= .coverage.{envname}
+    PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3:{toxinidir}/../../../../build/lib/cython_modules/lib.2
+    LD_LIBRARY_PATH = {toxinidir}/../../../../build/lib
 commands=
     {envbindir}/py.test --cov=. --cov-report= --junitxml=junit.{envname}.xml tests/
 
@@ -28,7 +30,10 @@ commands =
     coverage xml
 
 [testenv:lint]
+setenv =
+    PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3:{toxinidir}/../../../../build/lib/cython_modules/lib.2
+    LD_LIBRARY_PATH = {toxinidir}/../../../../build/lib
 deps=-r{toxinidir}/requirements.txt
 commands=
-    pylint --rcfile=.pylintrc --jobs=5 . module.py tools.py ceph_module_mock.py controllers tests
+    pylint --rcfile=.pylintrc --jobs=5 . module.py tools.py controllers tests cephmock
     pycodestyle --max-line-length=100 --exclude=python2.7,.tox,venv,frontend .