mirror of https://github.com/apache/cloudstack.git
Cleanup the marvin logger
It is useful to have the same logger used in the marvinplugin into the testcase. The testcase can then append its name to the logger making the logs specify exactly which test is executing when the logs are generated Signed-off-by: Prasanna Santhanam <tsp@apache.org> (cherry picked from commit c84a2d8801b7898dbfee18e17950cb9fca7d36e7)
This commit is contained in:
parent
3d9fc3dbc0
commit
476bd93e43
|
|
@ -25,11 +25,6 @@ from nose.plugins.base import Plugin
|
|||
from functools import partial
|
||||
|
||||
|
||||
def testCaseLogger(message, logger=None):
|
||||
if logger is not None:
|
||||
logger.debug(message)
|
||||
|
||||
|
||||
class MarvinPlugin(Plugin):
|
||||
"""
|
||||
Custom plugin for the cloudstackTestCases to be run using nose
|
||||
|
|
@ -69,10 +64,6 @@ class MarvinPlugin(Plugin):
|
|||
self.setClient(deploy.testClient)
|
||||
self.setConfig(deploy.getCfg())
|
||||
|
||||
cfg = nose.config.Config()
|
||||
cfg.logStream = self.result_stream
|
||||
cfg.debugLog = self.debug_stream
|
||||
|
||||
self.testrunner = nose.core.TextTestRunner(stream=self.result_stream,
|
||||
descriptions=True,
|
||||
verbosity=2, config=config)
|
||||
|
|
@ -133,21 +124,18 @@ class MarvinPlugin(Plugin):
|
|||
def beforeTest(self, test):
|
||||
testname = test.__str__().split()[0]
|
||||
self.testclient.identifier = '-'.join([self.identifier, testname])
|
||||
self.logger.name = test.__str__()
|
||||
|
||||
def _injectClients(self, test):
|
||||
testcaselogger = logging.getLogger("testclient.testcase.%s" %
|
||||
test.__name__)
|
||||
self.debug_stream. \
|
||||
setFormatter(logging.
|
||||
Formatter("%(asctime)s - %(levelname)s - %(name)s" +
|
||||
" - %(message)s"))
|
||||
|
||||
testcaselogger.addHandler(self.debug_stream)
|
||||
testcaselogger.setLevel(logging.DEBUG)
|
||||
|
||||
setattr(test, "debug", self.logger.debug)
|
||||
setattr(test, "info", self.logger.info)
|
||||
setattr(test, "warn", self.logger.warning)
|
||||
setattr(test, "testClient", self.testclient)
|
||||
setattr(test, "config", self.config)
|
||||
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
|
||||
if self.testclient.identifier is None:
|
||||
self.testclient.identifier = self.identifier
|
||||
setattr(test, "clstestclient", self.testclient)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from contextlib import closing
|
|||
|
||||
|
||||
class remoteSSHClient(object):
|
||||
def __init__(self, host, port, user, passwd, retries=10, delay=5,
|
||||
def __init__(self, host, port, user, passwd, retries=5, delay=30,
|
||||
log_lvl=logging.INFO, keyPairFileLocation=None):
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
|
@ -69,7 +69,7 @@ class remoteSSHClient(object):
|
|||
+ "login to %s on port %s" %
|
||||
(str(host), port))
|
||||
else:
|
||||
return
|
||||
return self.ssh
|
||||
|
||||
def execute(self, command):
|
||||
stdin, stdout, stderr = self.ssh.exec_command(command)
|
||||
|
|
|
|||
Loading…
Reference in New Issue