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>
This commit is contained in:
Santhosh Edukulla 2013-10-24 00:13:01 +05:30 committed by Girish Shilamkar
parent b9547b07c0
commit ae852adabb
1 changed files with 21 additions and 2 deletions

View File

@ -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.