From 476bd93e43497ad3e81017d81d6c60c21050a814 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Wed, 31 Jul 2013 15:18:04 +0530 Subject: [PATCH] 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 (cherry picked from commit c84a2d8801b7898dbfee18e17950cb9fca7d36e7) --- tools/marvin/marvin/marvinPlugin.py | 20 ++++---------------- tools/marvin/marvin/remoteSSHClient.py | 4 ++-- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index 29491094db0..f7b0664856c 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) diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 1dd1ef1a815..764ba2eb95f 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)