Basic support for "summary results" -- articifial test results that are explicitly recorded by a server-side control file or code that it calls. This CL just adds the record_summary() method to the server_job object. It lacks any special parser support or TKO DB changes, those will come later.
This also includes a couple of minor changes to support conitnuous parsing and final reparsing for hostless jobs. Since hostless jobs are a common intended use case for summary results, they'll need full parsing support to be useful. Signed-off-by: Steve Howard <[email protected]> --- autotest/scheduler/monitor_db.py 2010-01-21 11:33:22.000000000 -0800 +++ autotest/scheduler/monitor_db.py 2010-01-21 11:33:22.000000000 -0800 @@ -2219,17 +2219,9 @@ super(HostlessQueueTask, self).prolog() - def _final_status(self): - if self.queue_entries[0].aborted: - return models.HostQueueEntry.Status.ABORTED - if self.monitor.exit_code() == 0: - return models.HostQueueEntry.Status.COMPLETED - return models.HostQueueEntry.Status.FAILED - - def _finish_task(self): super(HostlessQueueTask, self)._finish_task() - self.queue_entries[0].set_status(self._final_status()) + self.queue_entries[0].set_status(models.HostQueueEntry.Status.PARSING) class PostJobTask(AgentTask): --- autotest/server/server_job.py 2010-01-21 11:33:22.000000000 -0800 +++ autotest/server/server_job.py 2010-01-21 11:33:22.000000000 -0800 @@ -135,7 +135,7 @@ utils.write_keyval(self.resultdir, job_data) self._parse_job = parse_job - self._using_parser = (self._parse_job and len(machines) == 1) + self._using_parser = (self._parse_job and len(machines) <= 1) self.pkgmgr = packages.PackageManager( self.autodir, run_function_dargs={'timeout':600}) self.num_tests_run = 0 @@ -703,6 +703,64 @@ return warnings + def _unique_subdirectory(self, base_subdirectory_name): + """Compute a unique results subdirectory based on the given name. + + Appends base_subdirectory_name with a number as necessary to find a + directory name that doesn't already exist. + """ + subdirectory = base_subdirectory_name + counter = 1 + while os.path.exists(os.path.join(self.resultdir, subdirectory)): + subdirectory = base_subdirectory_name + '.' + str(counter) + counter += 1 + return subdirectory + + + def record_summary(self, status_code, test_name, reason='', attributes=None, + distinguishing_attributes=(), child_test_ids=None): + """Record a summary test result. + + @param status_code: status code string, see + common_lib.log.is_valid_status() + @param test_name: name of the test + @param reason: (optional) string providing detailed reason for test + outcome + @param attributes: (optional) dict of string keyvals to associate with + this result + @param distinguishing_attributes: (optional) list of attribute names + that should be used to distinguish identically-named test + results. These attributes should be present in the attributes + parameter. This is used to generate user-friendly subdirectory + names. + @param child_test_ids: (optional) list of test indices for test results + used in generating this result. + """ + subdirectory_name_parts = [test_name] + for attribute in distinguishing_attributes: + assert attributes + assert attribute in attributes, '%s not in %s' % (attribute, + attributes) + subdirectory_name_parts.append(attributes[attribute]) + base_subdirectory_name = '.'.join(subdirectory_name_parts) + + subdirectory = self._unique_subdirectory(base_subdirectory_name) + subdirectory_path = os.path.join(self.resultdir, subdirectory) + os.mkdir(subdirectory_path) + + self.record(status_code, subdirectory, test_name, + status=reason, optional_fields={'is_summary': True}) + + if attributes: + utils.write_keyval(subdirectory_path, attributes) + + if child_test_ids: + ids_string = ','.join(str(test_id) for test_id in child_test_ids) + summary_data = {'child_test_ids': ids_string} + utils.write_keyval(os.path.join(subdirectory_path, 'summary_data'), + summary_data) + + def disable_warnings(self, warning_type): self.warning_manager.disable_warnings(warning_type) self.record("INFO", None, None, _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
