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 <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/805d087d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/805d087d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/805d087d Branch: refs/heads/4.2 Commit: 805d087d8761299a2df5a6fc01da30c1dc42a368 Parents: 798c507 Author: Prasanna Santhanam <[email protected]> Authored: Wed Jul 31 15:18:04 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Wed Jul 31 17:21:01 2013 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/marvinPlugin.py | 20 ++++---------------- tools/marvin/marvin/remoteSSHClient.py | 4 ++-- 2 files changed, 6 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/805d087d/tools/marvin/marvin/marvinPlugin.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index 2949109..f7b0664 100644 --- a/tools/marvin/marvin/marvinPlugin.py +++ b/tools/marvin/marvin/marvinPlugin.py @@ -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) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/805d087d/tools/marvin/marvin/remoteSSHClient.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 1dd1ef1..764ba2e 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -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)
