From: Zack Cerza Date: Thu, 15 May 2014 16:08:10 +0000 (-0500) Subject: Add Pulpito links to teuthology emails X-Git-Tag: 1.1.0~1447 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8c74392cda2ac2c6391ea0e5341d40baa4384b1;p=teuthology.git Add Pulpito links to teuthology emails Signed-off-by: Zack Cerza --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 185743fd..bee5e3fc 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -117,6 +117,22 @@ def get_http_log_path(archive_dir, job_id=None): return os.path.join(http_base, archive_subdir, str(job_id), '') +def get_results_url(run_name, job_id=None): + """ + :param run_name: The name of the test run + :param job_id: The job_id of the job. Optional. + :returns: URL to the run (or job, if job_id is passed) in the results web + UI. For example, Inktank uses Pulpito. + """ + if not config.results_ui_server: + return None + base_url = config.results_ui_server + + if job_id is None: + return os.path.join(base_url, run_name, '') + return os.path.join(base_url, run_name, str(job_id), '') + + def get_ceph_binary_url(package=None, branch=None, tag=None, sha1=None, dist=None, flavor=None, format=None, arch=None): diff --git a/teuthology/results.py b/teuthology/results.py index 4687a6fc..61857828 100644 --- a/teuthology/results.py +++ b/teuthology/results.py @@ -104,6 +104,13 @@ def build_email_body(name, archive_dir, timeout): job_dir = os.path.join(archive_dir, job) summary_file = os.path.join(job_dir, 'summary.yaml') + # Every job gets a link to e.g. pulpito's pages + info_url = misc.get_results_url(name, job) + if info_url: + info_line = email_templates['info_url_templ'].format(info=info_url) + else: + info_line = '' + # Unfinished jobs will have no summary.yaml if not os.path.exists(summary_file): info_file = os.path.join(job_dir, 'info.yaml') @@ -117,6 +124,7 @@ def build_email_body(name, archive_dir, timeout): hung[job] = email_templates['hung_templ'].format( job_id=job, desc=desc, + info_line=info_line, ) continue @@ -128,6 +136,7 @@ def build_email_body(name, archive_dir, timeout): job_id=job, desc=summary.get('description'), time=int(summary.get('duration', 0)), + info_line=info_line, ) else: log = misc.get_http_log_path(archive_dir, job) @@ -159,6 +168,7 @@ def build_email_body(name, archive_dir, timeout): desc=summary.get('description'), time=int(summary.get('duration', 0)), reason=reason, + info_line=info_line, log_line=log_line, sentry_line=sentry_line, ) @@ -196,6 +206,7 @@ def build_email_body(name, archive_dir, timeout): body = email_templates['body_templ'].format( name=name, + info_root=misc.get_results_url(name), log_root=misc.get_http_log_path(archive_dir), fail_count=len(failed), hung_count=len(hung), @@ -212,6 +223,7 @@ email_templates = { 'body_templ': dedent("""\ Test Run: {name} ================================================================= + info: {info_root} logs: {log_root} failed: {fail_count} hung: {hung_count} @@ -227,19 +239,20 @@ email_templates = { 'fail_templ': dedent("""\ [{job_id}] {desc} ----------------------------------------------------------------- - time: {time}s{log_line}{sentry_line} + time: {time}s{info_line}{log_line}{sentry_line} {reason} """), + 'info_url_templ': "\ninfo: {info}", 'fail_log_templ': "\nlog: {log}", 'fail_sentry_templ': "\nsentry: {sentry_event}", 'hung_templ': dedent("""\ - [{job_id}] {desc} + [{job_id}] {desc}{info_line} """), 'pass_templ': dedent("""\ [{job_id}] {desc} - time: {time}s + time: {time}s{info_line} """), } diff --git a/teuthology/test/test_results.py b/teuthology/test/test_results.py index 5318b7dc..f635b29c 100644 --- a/teuthology/test/test_results.py +++ b/teuthology/test/test_results.py @@ -1,5 +1,6 @@ import os import textwrap +from ..config import config from .. import results from .fake_archive import FakeArchive @@ -40,6 +41,7 @@ class TestResultsEmail(object): 'body': textwrap.dedent(""" Test Run: test_name ================================================================= + info: http://example.com/test_name/ logs: http://qa-proxy.ceph.com/teuthology/test_name/ failed: 1 hung: 1 @@ -50,6 +52,7 @@ class TestResultsEmail(object): [88979] description for job with name test_name ----------------------------------------------------------------- time: 35190s + info: http://example.com/test_name/88979/ log: http://qa-proxy.ceph.com/teuthology/test_name/88979/ Failure reason! @@ -58,15 +61,18 @@ class TestResultsEmail(object): Hung ================================================================= [30481] description for job with name test_name + info: http://example.com/test_name/30481/ Passed ================================================================= [68369] description for job with name test_name - time: 33771s + time: 33771s + info: http://example.com/test_name/68369/ """).strip(), } def setup(self): + config.results_ui_server = "http://example.com/" self.archive = FakeArchive() self.archive.setup() self.archive_base = self.archive.archive_base @@ -83,4 +89,5 @@ class TestResultsEmail(object): run_dir, 36000) assert subject == self.reference['subject'] + print body assert body == self.reference['body']