提交 d37189b5 编写于 作者: R Rudá Moura

Implement --sysinfo=on|off feature.

Implement runner command line option `--sysinfo` to turn on or off
any reports created and related to the execution of sysinfo, like
profilers, command lines utilities and other hardware logs. Default: on.

Example: avocado run --sysinfo=off passtest

There is a new configuration options inside [sysinfo.collect]
named "enabled" which will turn the feature on and off too.
It accepts a boolean value and the default is to enable sysinfo.

The command line option overwrites the configuration value.
Signed-off-by: NRudá Moura <rmoura@redhat.com>
上级 d855776f
......@@ -29,6 +29,7 @@ from avocado import test
from avocado import runner
from avocado import loader
from avocado import runtime
from avocado import sysinfo
from avocado.core import data_dir
from avocado.core import exit_codes
from avocado.core import exceptions
......@@ -37,6 +38,7 @@ from avocado.core import output
from avocado.plugins import jsonresult
from avocado.plugins import xunit
from avocado.utils import archive
from avocado.utils import path
try:
......@@ -104,6 +106,11 @@ class Job(object):
self.status = "RUNNING"
self.result_proxy = result.TestResultProxy()
self.view = output.View(app_args=self.args)
self.sysinfo = None
if hasattr(self.args, 'sysinfo'):
if self.args.sysinfo == 'on':
sysinfo_dir = path.init_dir(self.logdir, 'sysinfo')
self.sysinfo = sysinfo.SysInfo(basedir=sysinfo_dir)
def _make_test_loader(self):
if hasattr(self.args, 'test_loader'):
......
......@@ -86,6 +86,8 @@ class ReportModel(object):
sysinfo_contents = sysinfo_file.read()
except OSError, details:
sysinfo_contents = "Error reading %s: %s" % (sysinfo_path, details)
except IOError, details:
sysinfo_contents = os.uname()[1]
return sysinfo_contents
def hostname(self):
......@@ -122,10 +124,13 @@ class ReportModel(object):
return test_info
def sysinfo(self):
sysinfo_list = []
base_path = os.path.join(self._results_dir(relative_links=False), 'sysinfo', 'pre')
sysinfo_files = os.listdir(base_path)
try:
sysinfo_files = os.listdir(base_path)
except OSError:
return sysinfo_list
sysinfo_files.sort()
sysinfo_list = []
s_id = 1
for s_f in sysinfo_files:
sysinfo_dict = {}
......
......@@ -18,6 +18,7 @@ Base Test Runner Plugins.
import sys
from avocado.settings import settings
from avocado.core import exit_codes
from avocado.plugins import plugin
from avocado.core import output
......@@ -60,6 +61,16 @@ class TestRunner(plugin.Plugin):
'server. You should not use this option '
'unless you know exactly what you\'re doing'))
sysinfo_default = settings.get_value('sysinfo.collect',
'enabled',
key_type='bool',
default=True)
sysinfo_default = 'on' if sysinfo_default is True else 'off'
self.parser.add_argument('--sysinfo', choices=('on', 'off'), default=sysinfo_default,
help=('Enable or disable system information '
'(hardware details, profilers, etc.). '
'Current: %(default)s'))
out = self.parser.add_argument_group('output related arguments')
out.add_argument('-s', '--silent', action='store_true', default=False,
......
......@@ -26,7 +26,6 @@ import sys
import time
from avocado import runtime
from avocado import sysinfo
from avocado.core import exceptions
from avocado.core import output
from avocado.core import status
......@@ -52,8 +51,6 @@ class TestRunner(object):
"""
self.job = job
self.result = test_result
sysinfo_dir = path.init_dir(self.job.logdir, 'sysinfo')
self.sysinfo = sysinfo.SysInfo(basedir=sysinfo_dir)
def run_test(self, test_factory, queue):
"""
......@@ -122,7 +119,8 @@ class TestRunner(object):
:return: a list of test failures.
"""
failures = []
self.sysinfo.start_job_hook()
if self.job.sysinfo is not None:
self.job.sysinfo.start_job_hook()
self.result.start_tests()
q = queues.SimpleQueue()
test_suite = self.job.test_loader.discover(params_list, q)
......@@ -233,5 +231,6 @@ class TestRunner(object):
failures.append(test_state['name'])
runtime.CURRENT_TEST = None
self.result.end_tests()
self.sysinfo.end_job_hook()
if self.job.sysinfo is not None:
self.job.sysinfo.end_job_hook()
return failures
......@@ -5,4 +5,5 @@ data_dir = /usr/share/avocado/data
logs_dir = ~/avocado/job-results
[sysinfo.collect]
enabled = True
installed_packages = False
......@@ -141,6 +141,11 @@ stdout. Even if you specify things like --show-job-log in the CLI, --silent
will have precedence and you will not get application stdout. Note that --silent
does not affect on disk job logs, those continue to be generated normally.
SILENCING SYSINFO REPORT
========================
You may specify --sysinfo=off and avocado will not collect profilers,
hardware details and other system information, inside the job result directory.
LISTING TESTS
=============
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册