]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Format durations as HH:MM:SS
authorZack Cerza <zack@redhat.com>
Thu, 5 Nov 2015 19:56:14 +0000 (12:56 -0700)
committerZack Cerza <zack@redhat.com>
Thu, 5 Nov 2015 19:56:14 +0000 (12:56 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/results.py
teuthology/test/test_results.py

index 5c0ea7da7d52e8618159ba32edaf2395f54d4808..b5e210cd7bc32c475a684039725132f89c85c733 100644 (file)
@@ -175,7 +175,7 @@ def format_job(run_name, job):
     job_id = job['job_id']
     status = job['status']
     description = job['description']
-    duration = int(job['duration'] or 0)
+    duration = seconds_to_hms(int(job['duration'] or 0))
 
     # Every job gets a link to e.g. pulpito's pages
     info_url = misc.get_results_url(run_name, job_id)
@@ -239,6 +239,12 @@ def format_job(run_name, job):
         return email_templates['fail_templ'].format(**format_args)
 
 
+def seconds_to_hms(seconds):
+    (minutes, seconds) = divmod(seconds, 60)
+    (hours, minutes) = divmod(minutes, 60)
+    return "%02d:%02d:%02d" % (hours, minutes, seconds)
+
+
 email_templates = {
     'body_templ': dedent("""\
         Test Run: {name}
@@ -262,7 +268,7 @@ email_templates = {
     'fail_templ': dedent("""\
         [{job_id}]  {desc}
         -----------------------------------------------------------------
-        time:   {time}s{info_line}{log_line}{sentry_line}{reason_lines}
+        time:   {time}{info_line}{log_line}{sentry_line}{reason_lines}
 
         """),
     'info_url_templ': "\ninfo:   {info}",
@@ -274,7 +280,7 @@ email_templates = {
         """),
     'pass_templ': dedent("""\
         [{job_id}] {desc}
-        time:   {time}s{info_line}
+        time:   {time}{info_line}
 
         """),
 }
index 00203ea61a8710a1c417e6c424ed5c69a4a0b712..6dab00afb46be4066d73950227daa361437ad65b 100644 (file)
@@ -88,7 +88,7 @@ class TestResultsEmail(object):
     =================================================================
     [88979]  description for job with name test_name
     -----------------------------------------------------------------
-    time:   35190s
+    time:   09:46:30
     info:   http://example.com/test_name/88979/
     log:    http://qa-proxy.ceph.com/teuthology/test_name/88979/
 
@@ -100,7 +100,7 @@ class TestResultsEmail(object):
     =================================================================
     [69152]  description for job with name test_name
     -----------------------------------------------------------------
-    time:   5225s
+    time:   01:27:05
     info:   http://example.com/test_name/69152/
     log:    http://qa-proxy.ceph.com/teuthology/test_name/69152/
 
@@ -126,7 +126,7 @@ class TestResultsEmail(object):
     Pass
     =================================================================
     [68369] description for job with name test_name
-    time:   33771s
+    time:   09:22:51
     info:   http://example.com/test_name/68369/
     """).strip(),
     }