From ae852adabb70f43d6d349dd4ab56dc3116e10aed Mon Sep 17 00:00:00 2001 From: Santhosh Edukulla Date: Thu, 24 Oct 2013 00:13:01 +0530 Subject: [PATCH] CLOUDSTACK-4885: basic timing profiler for tests This will add time taken in seconds along with start and end timestamp logging facility for test cases.Currently this is not available for console logs Signed-off-by: Santhosh Edukulla --- tools/marvin/marvin/marvinPlugin.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index aded17cca55..3b282e448db 100644 --- a/tools/marvin/marvin/marvinPlugin.py +++ b/tools/marvin/marvin/marvinPlugin.py @@ -22,6 +22,7 @@ import nose.core from marvin.cloudstackTestCase import cloudstackTestCase from marvin import deployDataCenter from nose.plugins.base import Plugin +import time class MarvinPlugin(Plugin): @@ -121,10 +122,28 @@ class MarvinPlugin(Plugin): self.config = config def beforeTest(self, test): - testname = test.__str__().split()[0] - self.testclient.identifier = '-'.join([self.identifier, testname]) + self.testName = test.__str__().split()[0] + self.testclient.identifier = '-'.join([self.identifier, self.testName]) self.logger.name = test.__str__() + def startTest(self, test): + """ + Currently used to record start time for tests + """ + self.startTime = time.time() + + def stopTest(self, test): + """ + Currently used to record end time for tests + """ + endTime = time.time() + if self.startTime is not None: + totTime = int(endTime - self.startTime) + self.logger.debug( + "****TestCaseName: %s; Time Taken: %s Seconds; \ + StartTime: %s; EndTime: %s****" + % (self.testName, str(totTime), self.startTime, endTime)) + def _injectClients(self, test): self.debug_stream. \ setFormatter(logging.