mgr/dashboard_v2: mocking of rados and rbd modules

Signed-off-by: Ricardo Dias <rdias@suse.com>
This commit is contained in:
Ricardo Dias 2018-02-02 15:33:44 +00:00
parent 41205565c6
commit c803df1335
No known key found for this signature in database
GPG Key ID: 74390C579BD37B68
7 changed files with 56 additions and 3 deletions

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

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

View File

@ -36,3 +36,6 @@ class BaseMgrModule(object):
def _ceph_log(self, *args):
pass
def _ceph_get_context(self):
return None

View File

@ -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

View File

@ -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

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