Make the autotest results email to be more concise and
legible. The current specification of the format follows:
Subject: Autotest <#jobid> | <job name> | success: <x%>
<job name>
<job URL>
Tests run: <n>; pass: <n>; skip: <n>; fail: <n>; sucess rate: <x%>
FAIL (n):
<shortened test name>
<failure description, restricted to 76 collumns, no
trailling whitespaces, idented and aligned>
<shortened test name>
<failure description, restricted to 76 collumns, no
trailling whitespaces, idented and aligned>
SKIPPED (n):
<shortened test name>
<reason>
<shortened test name>
<reason>
<shortened test name>
<reason>
<shortened test name>
<reason>
<shortened test name>
<reason>
PASS (n):
<shortened test name>
<shortened test name>
This patch implements this new formatting. Some adjustment
and tweaking is expected until we get to a final version.
Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
scheduler/scheduler_models.py | 84 +++++++++++++++++++++++++++++------------
1 file changed, 60 insertions(+), 24 deletions(-)
diff --git a/scheduler/scheduler_models.py b/scheduler/scheduler_models.py
index 44a28f8..17aa910 100644
--- a/scheduler/scheduler_models.py
+++ b/scheduler/scheduler_models.py
@@ -607,34 +607,33 @@ class HostQueueEntry(DBObject):
"""
job_stats = Job(id=self.job.id).get_execution_details()
- subject = ('Autotest | Job ID: %s "%s" | Status: %s ' %
- (self.job.id, self.job.name, status))
+ subject = ('Autotest #%s | "%s"' %
+ (self.job.id, self.job.name))
if hostname is not None:
subject += '| Hostname: %s ' % hostname
if status not in ["1 Failed", "Failed"]:
- subject += '| Success Rate: %.2f %%' % job_stats['success_rate']
+ subject += '| success: %.2f %%' % job_stats['success_rate']
- body = "Job ID: %s\n" % self.job.id
- body += "Job name: %s\n" % self.job.name
+ body = "%s\n" % self.job.name
+ body += "%s\n" % self._view_job_url()
+ if int(job_stats['total_executed']) > 0:
+ body += ("Tests run: %s | pass: %s | skip: %s | fail: %s"
+ "success rate: %.2f" % (job_stats['total_executed'],
+ job_stats['total_passed'],
+ job_stats['total_skipped'],
+ job_stats['total_failed'],
+ job_stats['success_rate']))
if hostname is not None:
body += "Host: %s\n" % hostname
if summary is not None:
body += "Summary: %s\n" % summary
- body += "Status: %s\n" % status
- body += "Results interface URL: %s\n" % self._view_job_url()
body += "Execution time (HH:MM:SS): %s\n" % job_stats['execution_time']
- if int(job_stats['total_executed']) > 0:
- body += "User tests executed: %s\n" % job_stats['total_executed']
- body += "User tests passed: %s\n" % job_stats['total_passed']
- body += "User tests failed: %s\n" % job_stats['total_failed']
- body += ("User tests success rate: %.2f %%\n" %
- job_stats['success_rate'])
-
- if job_stats['failed_rows']:
- body += "Failures:\n"
- body += job_stats['failed_rows']
+ body += job_stats['fail_detail']
+ body += job_stats['warn_detail']
+ body += job_stats['skip_detail']
+ body += job_stats['pass_detail']
return subject, body
@@ -883,6 +882,41 @@ class Job(DBObject):
return n_test_jobs
+ def _format_rows(rows, max_length=80):
+ """
+ Format failure rows, so they are legible on the resulting email.
+
+ @param rows: List of rows (matrix) with database results.
+ @param field: Field of the stats dict we want to fill.
+ @param max_length: Int with maximum length of a line printed.
+ """
+ formatted_row = ""
+
+ if rows:
+ formatted_row += "%s (%s)\n" % (rows[0][1], len(rows))
+ for row in rows:
+ # Add test name, status and count
+ formatted_row += "%s\n" % (row[0])
+ # start to add reasons
+ if row[2]:
+ reason = row[2].split()
+ curr_length = 0
+ formatted_row += " "
+ for word in reason:
+ previous_length = curr_length
+ curr_length += len(word)
+ if curr_length > max_length:
+ curr_length = 0
+ if previous_length != 0:
+ formatted_row += "\n %s " % word
+ else:
+ # Corner case, len(word) > 80 char
+ formatted_row += "%s\n " % word
+ else:
+ formatted_row += "%s " % word
+ formatted_row += "\n"
+ return formatted_row
+
stats = {}
rows = _db.execute("""
@@ -894,7 +928,11 @@ class Job(DBObject):
ORDER BY t.reason
""" % self.id)
- failed_rows = [r for r in rows if not r[1] == 'GOOD']
+ failed_rows = [r for r in rows if r[1] != 'GOOD']
+ explicitly_failed_rows = [r for r in rows if r[1] == 'FAIL']
+ warn_rows = [r for r in rows if r[1] == 'WARN']
+ skipped_rows = [r for r in rows if r[1] == 'TEST_NA']
+ passed_rows = [r for r in rows if r[1] == 'GOOD']
n_test_jobs = _find_test_jobs(rows)
n_test_jobs_failed = _find_test_jobs(failed_rows)
@@ -912,12 +950,10 @@ class Job(DBObject):
stats['total_passed'] = total_executed - total_failed
stats['success_rate'] = success_rate
- status_header = ("Test Name", "Status", "Reason")
- if failed_rows:
- stats['failed_rows'] = utils.matrix_to_string(failed_rows,
- status_header)
- else:
- stats['failed_rows'] = ''
+ stats['fail_detail'] = _format_rows(explicitly_failed_rows)
+ stats['warn_detail'] = _format_rows(warn_rows)
+ stats['skip_detail'] = _format_rows(skipped_rows)
+ stats['pass_detail'] = _format_rows(passed_rows)
time_row = _db.execute("""
SELECT started_time, finished_time
--
1.7.10.4
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel