Skip to content

Commit ae852ad

Browse files
Santhosh EdukullaGirish Shilamkar
authored andcommitted
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 <Santhosh.Edukulla@citrix.com>
1 parent b9547b0 commit ae852ad

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

‎tools/marvin/marvin/marvinPlugin.py‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from marvin.cloudstackTestCase import cloudstackTestCase
2323
from marvin import deployDataCenter
2424
from nose.plugins.base import Plugin
25+
import time
2526

2627

2728
class MarvinPlugin(Plugin):
@@ -121,10 +122,28 @@ def setConfig(self, config):
121122
self.config = config
122123

123124
def beforeTest(self, test):
124-
testname = test.__str__().split()[0]
125-
self.testclient.identifier = '-'.join([self.identifier, testname])
125+
self.testName = test.__str__().split()[0]
126+
self.testclient.identifier = '-'.join([self.identifier, self.testName])
126127
self.logger.name = test.__str__()
127128

129+
def startTest(self, test):
130+
"""
131+
Currently used to record start time for tests
132+
"""
133+
self.startTime = time.time()
134+
135+
def stopTest(self, test):
136+
"""
137+
Currently used to record end time for tests
138+
"""
139+
endTime = time.time()
140+
if self.startTime is not None:
141+
totTime = int(endTime - self.startTime)
142+
self.logger.debug(
143+
"****TestCaseName: %s; Time Taken: %s Seconds; \
144+
StartTime: %s; EndTime: %s****"
145+
% (self.testName, str(totTime), self.startTime, endTime))
146+
128147
def _injectClients(self, test):
129148
self.debug_stream. \
130149
setFormatter(logging.

0 commit comments

Comments
 (0)