avocado.plugins: Fix HTML report links for remote/vm tests

Modify the VM test info in order to correct paths of
test directories. This will fix a long standing bug with
regards to broken HTML report links.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 95331db7
......@@ -113,10 +113,11 @@ class ReportModel(object):
for t in test_info:
t['logdir'] = os.path.join(self._results_dir(
relative_links=self.relative_links),
'test-results', t['url'])
'test-results', t['logdir'])
t['logfile'] = os.path.join(self._results_dir(
relative_links=self.relative_links),
'test-results', t['url'], 'debug.log')
'test-results', t['logdir'],
'debug.log')
t['logfile_basename'] = os.path.basename(t['logfile'])
t['time'] = "%.2f" % t['time']
t['time_start'] = time.strftime("%Y-%m-%d %H:%M:%S",
......@@ -204,6 +205,8 @@ class HTMLTestResult(TestResult):
'status': state['status'],
'fail_reason': state['fail_reason'],
'whiteboard': state['whiteboard'],
'logdir': state['logdir'],
'logfile': state['logfile']
}
self.json['tests'].append(t)
......
......@@ -50,15 +50,27 @@ class RemoteTestRunner(TestRunner):
if result.exit_status == 127:
raise exceptions.JobError('Remote machine does not have avocado '
'installed')
json_result = None
for json_output in result.stdout.splitlines():
# We expect dictionary:
if json_output.startswith('{') and json_output.endswith('}'):
try:
return json.loads(json_output)
json_result = json.loads(json_output)
except ValueError:
pass
raise ValueError("Could not parse JSON from avocado remote output:"
"\n%s" % result.stdout)
if json_result is None:
raise ValueError("Could not parse JSON from avocado remote output:"
"\n%s" % result.stdout)
for t_dict in json_result['tests']:
logdir = os.path.dirname(self.result.stream.debuglog)
logdir = os.path.join(logdir, 'test-results')
logdir = os.path.join(logdir, os.path.relpath(t_dict['url'], '/'))
t_dict['logdir'] = logdir
t_dict['logfile'] = os.path.join(logdir, 'debug.log')
return json_result
def run_suite(self, test_suite):
"""
......@@ -79,7 +91,11 @@ class RemoteTestRunner(TestRunner):
time=tst['time'],
start=tst['start'],
end=tst['end'],
status=tst['status'])
status=tst['status'],
logdir=tst['logdir'],
logfile=tst['logfile'],
fail_reason=tst['fail_reason']
)
state = test.get_state()
self.result.start_test(state)
self.result.check_test(state)
......
......@@ -612,7 +612,8 @@ class RemoteTest(object):
Mimics :class:`avocado.test.Test` for remote tests.
"""
def __init__(self, name, status, time, start, end):
def __init__(self, name, status, time, start, end, fail_reason, logdir,
logfile):
note = "Not supported yet"
self.name = name
self.tagged_name = name
......@@ -623,9 +624,11 @@ class RemoteTest(object):
self.fail_class = note
self.traceback = note
self.text_output = note
self.fail_reason = note
self.fail_reason = fail_reason
self.whiteboard = ''
self.job_unique_id = ''
self.logdir = logdir
self.logfile = logfile
def get_state(self):
"""
......
#!/usr/bin/env python
import unittest
import os
from flexmock import flexmock, flexmock_teardown
from avocado.plugins import remote
cwd = os.getcwd()
JSON_RESULTS = ('Something other than json\n'
'{"tests": [{"test": "sleeptest.1", "url": "sleeptest", '
'"fail_reason": "None", '
'"status": "PASS", "time": 1.23, "start": 0, "end": 1.23}],'
'"debuglog": "/home/user/avocado/logs/run-2014-05-26-15.45.'
'37/debug.log", "errors": 0, "skip": 0, "time": 1.4, '
'"logdir": "/local/path/test-results%s/sleeptest", '
'"logdir": "/local/path/test-results%s/sleeptest", '
'"start": 0, "end": 1.4, "pass": 1, "failures": 0, "total": '
'1}\nAdditional stuff other than json')
'1}\nAdditional stuff other than json' % (cwd, cwd))
class RemoteTestRunnerTest(unittest.TestCase):
......@@ -42,7 +47,10 @@ class RemoteTestRunnerTest(unittest.TestCase):
'text_output': 'Not supported yet', 'time_end': 1.23,
'tagged_name': u'sleeptest.1', 'time_elapsed': 1.23,
'fail_class': 'Not supported yet', 'job_unique_id': '',
'fail_reason': 'Not supported yet'}
'fail_reason': 'None',
'logdir': '/local/path/test-results%s/sleeptest' % cwd,
'logfile': '/local/path/test-results%s/sleeptest/debug.log' %
cwd}
Results.should_receive('start_test').once().with_args(args).ordered()
Results.should_receive('check_test').once().with_args(args).ordered()
(Remote.should_receive('receive_files')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册