]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add Pulpito links to teuthology emails
authorZack Cerza <zack@cerza.org>
Thu, 15 May 2014 16:08:10 +0000 (11:08 -0500)
committerZack Cerza <zack@cerza.org>
Thu, 15 May 2014 16:08:10 +0000 (11:08 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/misc.py
teuthology/results.py
teuthology/test/test_results.py

index 185743fd32d6911eed61c4ceae8cc4dd288f1940..bee5e3fcaf7c553e1aa9c1df1f3a574b51736804 100644 (file)
@@ -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):
index 4687a6fc3c87172c097392f7ef62a8baa90c9247..618578287853ea5e6a821102222ccde4396f53e0 100644 (file)
@@ -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}
 
         """),
 }
index 5318b7dcf804a59718475aaac85e3f54eb03975b..f635b29c4fb664283e0702f662d6fdeca14626d0 100644 (file)
@@ -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']