avocado: Add remote log to tests

Whenever we use remoter.Remote(), our wrapper to fabric
inside tests, we end up losing information that could
be used for debugging purposes. Let's introduce an
remote related log to the avocado test results dir
(remote.log), that will be populated if
remoter.Remote() is used.

With this patch, tests that use remoter.Remote()
(avocado-virt) will have better debugging information
available.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 a6743812
......@@ -68,9 +68,14 @@ class TestRunner(object):
def interrupt_handler(signum, frame):
e_msg = "Test %s interrupted by user" % instance
raise exceptions.TestInterruptedError(e_msg)
sys.stdout = output.LoggingFile(logger=logging.getLogger('avocado.test.stdout'))
sys.stderr = output.LoggingFile(logger=logging.getLogger('avocado.test.stderr'))
logger_list_stdout = [logging.getLogger('avocado.test.stdout'),
logging.getLogger('avocado.test'),
logging.getLogger('paramiko')]
logger_list_stderr = [logging.getLogger('avocado.test.stderr'),
logging.getLogger('avocado.test'),
logging.getLogger('paramiko')]
sys.stdout = output.LoggingFile(logger=logger_list_stdout)
sys.stderr = output.LoggingFile(logger=logger_list_stderr)
try:
instance = self.job.test_loader.load_test(test_factory)
......
......@@ -117,6 +117,7 @@ class Test(unittest.TestCase):
self.logdir = utils_path.init_dir(base_logdir, tagged_name)
genio.set_log_file_dir(self.logdir)
self.logfile = os.path.join(self.logdir, 'debug.log')
self._ssh_logfile = os.path.join(self.logdir, 'remote.log')
self.stdout_file = os.path.join(self.logdir, 'stdout')
self.stderr_file = os.path.join(self.logdir, 'stderr')
......@@ -260,12 +261,16 @@ class Test(unittest.TestCase):
self.stdout_file)
self.stderr_file_handler = self._register_log_file_handler(self.stderr_log, stream_formatter,
self.stderr_file)
self._ssh_fh = self._register_log_file_handler(logging.getLogger('paramiko'),
formatter,
self._ssh_logfile)
def _stop_logging(self):
"""
Stop the logging activity of the test by cleaning the logger handlers.
"""
self.log.removeHandler(self.file_handler)
logging.getLogger('paramiko').removeHandler(self._ssh_fh)
def get_tagged_name(self, logdir):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册