From 9e53cbbe18e7aa292ed585958f18eda516e2bb84 Mon Sep 17 00:00:00 2001 From: Mitsuhiko Yamazaki Date: Tue, 12 Feb 2013 17:50:06 +0900 Subject: Standardize the coverage initializations. Now when we measure coverage repeatedly, the coverage data of nova-api is accumulated but the ones of other nova services are reset each time. This is due to create new "coverage" class each time "_start_coverage_telnet" method is executed. This patch limits creating "coverage" class the first time the method is executed. Fixes bug 1122720 Change-Id: Ia900c96113bee65362ccb7c4c1975535d814d835 --- nova/api/openstack/compute/contrib/coverage_ext.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nova/api/openstack/compute/contrib/coverage_ext.py b/nova/api/openstack/compute/contrib/coverage_ext.py index 6edf9244f..56e174cf6 100644 --- a/nova/api/openstack/compute/contrib/coverage_ext.py +++ b/nova/api/openstack/compute/contrib/coverage_ext.py @@ -109,14 +109,13 @@ class CoverageController(object): return ports def _start_coverage_telnet(self, tn, service): + data_file = os.path.join(self.data_path, + '.nova-coverage.%s' % str(service)) tn.write('import sys\n') tn.write('from coverage import coverage\n') - if self.combine: - data_file = os.path.join(self.data_path, - '.nova-coverage.%s' % str(service)) - tn.write("coverInst = coverage(data_file='%s')\n)" % data_file) - else: - tn.write('coverInst = coverage()\n') + tn.write("coverInst = coverage(data_file='%s') " + "if 'coverInst' not in locals() " + "else coverInst\n" % data_file) tn.write('coverInst.skipModules = sys.modules.keys()\n') tn.write("coverInst.start()\n") tn.write("print 'finished'\n") -- cgit