Change in vdsm[master]: coverage: Enable coverage using config value

nsoffer at redhat.com nsoffer at redhat.com
Mon Aug 24 14:58:17 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: coverage: Enable coverage using config value
......................................................................

coverage: Enable coverage using config value

Previously code coverage (used for developing QE tests) was enabled if
the coverage module was installed on the machine, importing the whole
coverage package, and possibly modifying the environment even when
coverage is now wanted.

This patch enables coverage using the configuration similar to the way
we enable profiling or manhole.

Change-Id: Ib67effd542e769a4a4a962007b8cc37296704bbe
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/vdsm
2 files changed, 17 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/45261/1

diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 8f2e519..6474dcc 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -372,6 +372,9 @@
         ('manhole_enable', 'false',
             'Enable manhole debugging service (requires manhole package).'),
 
+        ('coverage_enable', 'false',
+            'Enable coverage reporting (requires coverage package).'),
+
     ]),
 
     # Section: [gluster]
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 0648562..5130ad0 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -131,14 +131,7 @@
         # plugin and we would like to print that out.
         pass
 
-    # Used to enable code coverage. On production machines
-    # "coverage" should not exists and COVERAGE_PROCESS_START should not be
-    # set.
-    try:
-        import coverage
-        coverage.process_startup()
-    except ImportError:
-        pass
+    start_coverage()
 
     log = logging.getLogger('vds')
     try:
@@ -207,6 +200,19 @@
                     patch_fork=False, sigmask=None, redirect_stderr=False)
 
 
+def start_coverage():
+    """
+    Used to check code coverage of QE automation tests.
+
+    The collect coverage data, set devel:coverage_enable to true, and set
+    COVERAGE_PROCESS_START to the path fo coverage configuration file.
+    """
+    if not config.getboolean("devel", "coverage_enable"):
+        return
+    import coverage
+    coverage.process_startup()
+
+
 def __assertLogPermission():
     if not os.access(constants.P_VDSM_LOG, os.W_OK):
         syslog.syslog("vdsm log directory is not accessible")


-- 
To view, visit https://gerrit.ovirt.org/45261
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib67effd542e769a4a4a962007b8cc37296704bbe
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list