Skip to content

Commit

Permalink
server.test: Fix pylint complaint
Browse files Browse the repository at this point in the history
During pylint checking, we've found:

************* Module server.test
E0202:159:_sysinfo_logger.before_hook: An attribute inherited from
_sysinfo_logger hide this method
E0202:169:_sysinfo_logger.before_iteration_hook: An attribute inherited
from _sysinfo_logger hide this method
E0202:185:_sysinfo_logger.after_iteration_hook: An attribute inherited
from _sysinfo_logger hide this method
E0202:200:_sysinfo_logger.after_hook: An attribute inherited from
_sysinfo_logger hide this method

In fact, the way the class _sysinfo_logger was disabling
before/after iteration hooks was by setting attributes set
to None to hide the iteration hooks methods. We could do
the same in a cleaner way by setting an attribute that
can switch on/off the execution of the code present in
these hook methods. So implement this and fix the pylint
complaints.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
  • Loading branch information
lmr committed Oct 3, 2012
1 parent 0c2abd3 commit b3f72b4
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions server/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def __init__(self, job):
self.host = None
self.autotest = None
self.outputdir = None
self.disable_hooks = False

if len(job.machines) != 1:
# disable logging on multi-machine tests
self.before_hook = self.after_hook = None
self.before_iteration_hook = self.after_iteration_hook = None
self.disable_hooks = True


def _install(self):
Expand Down Expand Up @@ -157,53 +157,57 @@ def _pull_sysinfo_keyval(self, host, outputdir, mytest):
@log.log_and_ignore_errors("pre-test server sysinfo error:")
@install_autotest_and_run
def before_hook(self, mytest, host, at, outputdir):
# run the pre-test sysinfo script
at.run(_sysinfo_before_test_script % outputdir,
results_dir=self.job.resultdir)
if not self.disable_hooks:
# run the pre-test sysinfo script
at.run(_sysinfo_before_test_script % outputdir,
results_dir=self.job.resultdir)

self._pull_pickle(host, outputdir)
self._pull_pickle(host, outputdir)


@log.log_and_ignore_errors("pre-test iteration server sysinfo error:")
@install_autotest_and_run
def before_iteration_hook(self, mytest, host, at, outputdir):
# this function is called after before_hook() se we have sysinfo state
# to push to the server
self._push_pickle(host, outputdir);
# run the pre-test iteration sysinfo script
at.run(_sysinfo_iteration_script %
(outputdir, 'log_before_each_iteration', mytest.iteration,
'before'),
results_dir=self.job.resultdir)
if not self.disable_hooks:
# this function is called after before_hook() se we have sysinfo state
# to push to the server
self._push_pickle(host, outputdir);
# run the pre-test iteration sysinfo script
at.run(_sysinfo_iteration_script %
(outputdir, 'log_before_each_iteration', mytest.iteration,
'before'),
results_dir=self.job.resultdir)

# get the new sysinfo state from the client
self._pull_pickle(host, outputdir)
# get the new sysinfo state from the client
self._pull_pickle(host, outputdir)


@log.log_and_ignore_errors("post-test iteration server sysinfo error:")
@install_autotest_and_run
def after_iteration_hook(self, mytest, host, at, outputdir):
# push latest sysinfo state to the client
self._push_pickle(host, outputdir);
# run the post-test iteration sysinfo script
at.run(_sysinfo_iteration_script %
(outputdir, 'log_after_each_iteration', mytest.iteration,
'after'),
results_dir=self.job.resultdir)
if not self.disable_hooks:
# push latest sysinfo state to the client
self._push_pickle(host, outputdir);
# run the post-test iteration sysinfo script
at.run(_sysinfo_iteration_script %
(outputdir, 'log_after_each_iteration', mytest.iteration,
'after'),
results_dir=self.job.resultdir)

# get the new sysinfo state from the client
self._pull_pickle(host, outputdir)
# get the new sysinfo state from the client
self._pull_pickle(host, outputdir)


@log.log_and_ignore_errors("post-test server sysinfo error:")
@install_autotest_and_run
def after_hook(self, mytest, host, at, outputdir):
self._push_pickle(host, outputdir);
# run the post-test sysinfo script
at.run(_sysinfo_after_test_script % outputdir,
results_dir=self.job.resultdir)
if not self.disable_hooks:
self._push_pickle(host, outputdir);
# run the post-test sysinfo script
at.run(_sysinfo_after_test_script % outputdir,
results_dir=self.job.resultdir)

self._pull_sysinfo_keyval(host, outputdir, mytest)
self._pull_sysinfo_keyval(host, outputdir, mytest)


def cleanup(self, host_close=True):
Expand Down

0 comments on commit b3f72b4

Please sign in to comment.