pass timeout parameter from run_test() to harness in call test_status_detail('START',...), so that harness has a chance to learn about timeout when test is started and react accordingly.
For example: harness could setup an external watchdog, which would live on server-side and reboot machine when needed. It is assumed, that harness will typically setup any external watchdog with a value slightly larger than test timeout, so client has a chance to terminate failing test by itself. Signed-off-by: Jan Stancek <jstan...@redhat.com> --- client/bin/harness.py | 3 ++- client/bin/harness_ABAT.py | 3 ++- client/bin/job.py | 17 ++++++++++++----- client/bin/job_unittest.py | 21 ++++++++++++++------- client/common_lib/base_job.py | 2 ++ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/client/bin/harness.py b/client/bin/harness.py index 6265ca2..d8a5191 100644 --- a/client/bin/harness.py +++ b/client/bin/harness.py @@ -77,7 +77,8 @@ class harness(object): pass - def test_status_detail(self, code, subdir, operation, status, tag): + def test_status_detail(self, code, subdir, operation, status, tag, + optional_fields): """A test within this job is completing (detail)""" pass diff --git a/client/bin/harness_ABAT.py b/client/bin/harness_ABAT.py index 4fdcf7b..2ee8694 100644 --- a/client/bin/harness_ABAT.py +++ b/client/bin/harness_ABAT.py @@ -131,7 +131,8 @@ class harness_ABAT(harness.harness): self.__send("DONE") - def test_status_detail(self, code, subdir, operation, msg, tag): + def test_status_detail(self, code, subdir, operation, msg, tag, + optional_fields): """A test within this job is completing (detail)""" # Send the first line with the status code as a STATUS message. diff --git a/client/bin/job.py b/client/bin/job.py index 3731e23..97412c0 100644 --- a/client/bin/job.py +++ b/client/bin/job.py @@ -193,7 +193,8 @@ class base_client_job(base_job.base_job): message = '\n'.join([entry.message] + entry.extra_message_lines) rendered_entry = self._logger.render_entry(entry) self.harness.test_status_detail(entry.status_code, entry.subdir, - entry.operation, message, msg_tag) + entry.operation, message, msg_tag, + entry.fields) self.harness.test_status(rendered_entry, msg_tag) # send the entry to stdout, if it's enabled logging.info(rendered_entry) @@ -573,7 +574,7 @@ class base_client_job(base_job.base_job): self.record('GOOD', subdir, testname, 'completed successfully') try: - self._rungroup(subdir, testname, group_func) + self._rungroup(subdir, testname, group_func, timeout) return True except error.TestBaseException: return False @@ -584,7 +585,7 @@ class base_client_job(base_job.base_job): # UnhandledTestError that is caught above. - def _rungroup(self, subdir, testname, function, *args, **dargs): + def _rungroup(self, subdir, testname, function, timeout, *args, **dargs): """\ subdir: name of the group @@ -599,7 +600,13 @@ class base_client_job(base_job.base_job): """ try: - self.record('START', subdir, testname) + optional_fields = None + if timeout: + optional_fields = {} + optional_fields['timeout'] = timeout + self.record('START', subdir, testname, + optional_fields=optional_fields) + self._state.set('client', 'unexpected_reboot', (subdir, testname)) try: result = function(*args, **dargs) @@ -643,7 +650,7 @@ class base_client_job(base_job.base_job): try: return self._rungroup(subdir=None, testname=name, - function=function, **dargs) + function=function, timeout=None, **dargs) except (SystemExit, error.TestBaseException): raise # If there was a different exception, turn it into a TestError. diff --git a/client/bin/job_unittest.py b/client/bin/job_unittest.py index 6b50ed0..f3e1ae1 100755 --- a/client/bin/job_unittest.py +++ b/client/bin/job_unittest.py @@ -504,7 +504,8 @@ class test_base_job(unittest.TestCase): self.job.pkgmgr.get_package_name.expect_call( testname, 'test').and_return(("", testname)) os.path.exists.expect_call(outputdir).and_return(False) - self.job.record.expect_call("START", testname, testname) + self.job.record.expect_call("START", testname, testname, + optional_fields=None) self.job._runtest.expect_call(testname, "", None, (), {}).and_raises( unhandled_error) self.job.record.expect_call("ERROR", testname, testname, @@ -538,7 +539,8 @@ class test_base_job(unittest.TestCase): self.job.pkgmgr.get_package_name.expect_call( testname, 'test').and_return(("", testname)) os.path.exists.expect_call(outputdir).and_return(False) - self.job.record.expect_call("START", testname, testname) + self.job.record.expect_call("START", testname, testname, + optional_fields=None) self.job._runtest.expect_call(testname, "", None, (), {}).and_raises( unhandled_error) self.job.record.expect_call("ERROR", testname, testname, reason) @@ -727,20 +729,25 @@ class test_base_job(unittest.TestCase): #unhandled_error = error.UnhandledTestError(real_error) # set up the recording - testname = "sleeptest" + testname = "test" outputdir = os.path.join(self.job.resultdir, testname) self.job.pkgmgr.get_package_name.expect_call( testname, 'test').and_return(("", testname)) os.path.exists.expect_call(outputdir).and_return(False) - self.job.record.expect_call("START", testname, testname) - self.job._runtest.expect_call(testname, "", 60, (), {}) - self.job.record.expect_call("GOOD", testname, testname, 'completed successfully') + timeout = 60 + optional_fields = {} + optional_fields['timeout'] = timeout + self.job.record.expect_call("START", testname, testname, + optional_fields=optional_fields) + self.job._runtest.expect_call(testname, "", timeout, (), {}) + self.job.record.expect_call("GOOD", testname, testname, + "completed successfully") self.job.record.expect_call("END GOOD", testname, testname) self.job.harness.run_test_complete.expect_call() utils.drop_caches.expect_call() # run and check - self.job.run_test(testname, timeout=60) + self.job.run_test(testname, timeout=timeout) self.god.check_playback() diff --git a/client/common_lib/base_job.py b/client/common_lib/base_job.py index c5f55f8..843c0e8 100644 --- a/client/common_lib/base_job.py +++ b/client/common_lib/base_job.py @@ -469,6 +469,8 @@ class status_log_entry(object): else: self.fields = fields.copy() for key, value in self.fields.iteritems(): + if type(value) is int: + value = str(value) if self.BAD_CHAR_REGEX.search(key + value): raise ValueError('Invalid character in %r=%r field' % (key, value)) -- 1.7.1 _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest