]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard_v2: Added coverage tracking to module code
authorRicardo Dias <rdias@suse.com>
Thu, 8 Feb 2018 08:21:31 +0000 (08:21 +0000)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:06 +0000 (13:07 +0000)
This will allow to collect code coverage information when the module
is running within the ceph-mgr daemon.

Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/dashboard_v2/.coveragerc
src/pybind/mgr/dashboard_v2/module.py

index 3832b81dbe00bcbb87ea38ba65c64cd1861ceb7f..29a63192c3f836587bdc82ce4c3671d16d9c4c81 100644 (file)
@@ -3,4 +3,5 @@ omit = tests/*
        */python*/*
        ceph_module_mock.py
        __init__.py
+       */mgr_module.py
 
index 5643e1bb3282c15200cc5c6c36e0f2572c2fac18..37cd99323a40d46c299efe0ec907f364fa289bb1 100644 (file)
@@ -14,6 +14,12 @@ except ImportError:
 import cherrypy
 from mgr_module import MgrModule
 
+if 'COVERAGE_ENABLED' in os.environ:
+    import coverage
+    _cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__)))
+    _cov.start()
+
+# pylint: disable=wrong-import-position
 from .controllers.auth import Auth
 from .tools import load_controllers, json_error_page, SessionExpireAtBrowserCloseTool, \
                    NotificationQueue
@@ -105,6 +111,8 @@ class Module(MgrModule):
         cherrypy.tree.mount(Module.StaticRoot(), '/', config=config)
 
     def serve(self):
+        if 'COVERAGE_ENABLED' in os.environ:
+            _cov.start()
         self.configure_cherrypy()
 
         cherrypy.engine.start()
@@ -112,6 +120,9 @@ class Module(MgrModule):
         logger.info('Waiting for engine...')
         self.log.info('Waiting for engine...')
         cherrypy.engine.block()
+        if 'COVERAGE_ENABLED' in os.environ:
+            _cov.stop()
+            _cov.save()
         logger.info('Engine done')
 
     def shutdown(self):