From: alfonsomthd Date: Fri, 8 Mar 2019 16:35:34 +0000 (+0100) Subject: mgr/dashboard: enable coverage for API tests X-Git-Tag: v14.2.0~60^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F26851%2Fhead;p=ceph.git mgr/dashboard: enable coverage for API tests * Fixed: install in system the 'coverage' version set in requirements.txt as dashboard/module.py uses system version. * Updated 'coverage' to latest stable version. * Added teuthology missing dependency: backports.ssl-match-hostname * More precise coverage measurement through CherryPy Bus API. * Coverage report shown when no ceph-mgr running (cleanup_teuthology). Fixes: https://tracker.ceph.com/issues/36176 Signed-off-by: Alfonso Martínez --- diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 9a6f3748324b..6be074d2a49a 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -63,8 +63,12 @@ if cherrypy is not None: if 'COVERAGE_ENABLED' in os.environ: import coverage - _cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__))) - _cov.start() + __cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)), + data_suffix=True) + + cherrypy.engine.subscribe('start', __cov.start) + cherrypy.engine.subscribe('after_request', __cov.save) + cherrypy.engine.subscribe('stop', __cov.stop) # pylint: disable=wrong-import-position from . import logger, mgr @@ -305,9 +309,6 @@ class Module(MgrModule, CherryPyConfig): return os.path.join(current_dir, 'frontend/dist') def serve(self): - if 'COVERAGE_ENABLED' in os.environ: - _cov.start() - AuthManager.initialize() load_sso_db() @@ -346,9 +347,6 @@ class Module(MgrModule, CherryPyConfig): self.shutdown_event.clear() NotificationQueue.stop() cherrypy.engine.stop() - if 'COVERAGE_ENABLED' in os.environ: - _cov.stop() - _cov.save() logger.info('Engine stopped') def shutdown(self): diff --git a/src/pybind/mgr/dashboard/requirements.txt b/src/pybind/mgr/dashboard/requirements.txt index 3bc951781269..caa1db80e96f 100644 --- a/src/pybind/mgr/dashboard/requirements.txt +++ b/src/pybind/mgr/dashboard/requirements.txt @@ -4,7 +4,7 @@ bcrypt==3.1.4 cheroot==6.0.0 CherryPy==13.1.0 configparser==3.5.0 -coverage==4.4.2 +coverage==4.5.2 enum34==1.1.6 funcsigs==1.0.2 isort==4.2.15 diff --git a/src/pybind/mgr/dashboard/run-backend-api-tests.sh b/src/pybind/mgr/dashboard/run-backend-api-tests.sh index 630adac9e0a4..9a3a47fe7638 100755 --- a/src/pybind/mgr/dashboard/run-backend-api-tests.sh +++ b/src/pybind/mgr/dashboard/run-backend-api-tests.sh @@ -33,6 +33,7 @@ setup_teuthology() { read -r -d '' TEUTHOLOGY_PY_REQS <