CLOUDSTACK-5413: Fixed bug CLOUDSTACK-5413

This commit is contained in:
Santhosh Edukulla 2013-12-09 19:45:22 +05:30 committed by Girish Shilamkar
parent 5cbda8b64a
commit 6b70a6db94
8 changed files with 27 additions and 43 deletions

View File

@ -106,17 +106,11 @@
"db": "cloud",
"port": 3306,
"user": "cloud"
},
"logger": [
},
"logger":
{
"name": "TestClient",
"file": "testclient.log"
},
{
"name": "TestCase",
"file": "testcase.log"
}
],
"LogFolderPath": "/tmp/"
},
"globalConfig": [
{
"name": "storage.cleanup.interval",

View File

@ -103,16 +103,10 @@
"port": 3306,
"user": "cloud"
},
"logger": [
"logger":
{
"name": "TestClient",
"file": "/tmp/testclient.log"
"LogFolderPath": "/tmp/"
},
{
"name": "TestCase",
"file": "/tmp/testcase.log"
}
],
"globalConfig": [
{
"name": "storage.cleanup.interval",

View File

@ -91,16 +91,10 @@
]
}
],
"logger": [
"logger":
{
"name": "TestClient",
"file": "/tmp/testclient.log"
},
{
"name": "TestCase",
"file": "/tmp/testcase.log"
}
],
"LogFolderPath": "/tmp/"
},
"mgtSvr": [
{
"mgtSvrIp": "127.0.0.1",

View File

@ -46,4 +46,4 @@ NO = "no"
YES = "yes"
FAILED = "FAILED"
UNKNOWN_ERROR = "Unknown Error"
EXCEPTION = "Exception"
EXCEPTION = "EXCEPTION"

View File

@ -137,16 +137,10 @@
"port": 3306,
"user": "cloud"
},
"logger": [
"logger":
{
"name": "TestClient",
"file": "/tmp/testclient.log"
"LogFolderPath": "/tmp/"
},
{
"name": "TestCase",
"file": "/tmp/testcase.log"
}
],
"globalConfig": [
{
"name": "network.gc.wait",

View File

@ -129,7 +129,7 @@ class MarvinInit:
"exceptions.txt"
tc_run_log = self.logFolderPath + "/runinfo.txt"
self.__tcRunDebugFile = open(self.logFolderPath +
"/tcresults.txt", "w")
"/results.txt", "w")
log_obj = MarvinLog("CSLog")
self.__tcRunLogger = log_obj.setLogHandler(tc_run_log)

View File

@ -19,6 +19,7 @@
'''
import logging
import sys
import time
from marvin.codes import (NO,
YES
)
@ -29,7 +30,7 @@ class MarvinLog:
@Desc : provides interface for logging to marvin
@Input : logger_name : name for logger
'''
logFormat = "%(asctime)s - %(levelname)s - %(name)s - %(message)s"
logFormat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
_instance = None
def __new__(cls, logger_name):
@ -49,7 +50,7 @@ class MarvinLog:
def setLogHandler(self, log_file_path, log_format=None,
log_level=logging.DEBUG):
'''
@Desc:
@Desc: Adds the given Log handler to the current logger
@Input: log_file_path: Log File Path as where to store the logs
log_format : Format of log messages to be dumped
log_level : Determines the level of logging for this logger
@ -60,10 +61,10 @@ class MarvinLog:
else:
stream = logging.StreamHandler(stream=sys.stdout)
if log_format is None:
if log_format is not None:
stream.setFormatter(log_format)
else:
stream.setFormatter(cls.logFormat)
stream.setFormatter(self.__class__.logFormat)
stream.setLevel(log_level)
self.logger.addHandler(stream)
except Exception, e:

View File

@ -48,6 +48,7 @@ class MarvinPlugin(Plugin):
self.conf = None
self.debugStream = sys.stdout
self.testRunner = None
self.testResult = SUCCESS
self.startTime = None
self.testName = None
self.tcRunLogger = None
@ -122,7 +123,10 @@ class MarvinPlugin(Plugin):
def startTest(self, test):
"""
Currently used to record start time for tests
Dump Start Msg of TestCase to Log
"""
self.tcRunLogger.debug("::::::::::::STARTED : TC: " +
str(self.testName) + " :::::::::::")
self.startTime = time.time()
def getErrorInfo(self, err):
@ -141,6 +145,7 @@ class MarvinPlugin(Plugin):
err_msg = self.getErrorInfo(err)
self.tcRunLogger.fatal("%s: %s: %s" %
(EXCEPTION, self.testName, err_msg))
self.testResult = EXCEPTION
def handleFailure(self, test, err):
'''
@ -149,6 +154,7 @@ class MarvinPlugin(Plugin):
err_msg = self.getErrorInfo(err)
self.tcRunLogger.fatal("%s: %s: %s" %
(FAILED, self.testName, err_msg))
self.testResult = FAILED
def startMarvin(self):
'''
@ -186,10 +192,11 @@ class MarvinPlugin(Plugin):
totTime = int(endTime - self.startTime)
self.tcRunLogger.debug("TestCaseName: %s; Time Taken: "
"%s Seconds; "
"StartTime: %s; EndTime: %s"
"StartTime: %s; EndTime: %s; Result: %s"
% (self.testName, str(totTime),
str(time.ctime(self.startTime)),
str(time.ctime(endTime))))
str(time.ctime(endTime)),
self.testResult))
def _injectClients(self, test):
setattr(test, "debug", self.tcRunLogger.debug)