]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Collect timing data for task execution
authorZack Cerza <zack@redhat.com>
Tue, 2 Feb 2016 23:42:08 +0000 (16:42 -0700)
committerZack Cerza <zack@redhat.com>
Fri, 5 Feb 2016 17:00:45 +0000 (10:00 -0700)
Just before we execute a task's enter or exit method, create a new timer
mark. If the archive is enabled, each timer.mark() call writes (or
re-writes) all the timing data to timing.yaml inside the archive.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/run_tasks.py

index ba9f86c4a3d41d947e2d01dd22a682cd6711c0b9..dfb0bdc57efbd4d21c40f4026ee6ac5b67b4c6bc 100644 (file)
@@ -1,11 +1,15 @@
-import sys
 import logging
-from .sentry import get_client as get_sentry_client
-from .job_status import set_status
-from .misc import get_http_log_path
+import os
+import sys
+
+from copy import deepcopy
+
 from .config import config as teuth_config
 from .exceptions import ConnectionLostError
-from copy import deepcopy
+from .job_status import set_status
+from .misc import get_http_log_path
+from .sentry import get_client as get_sentry_client
+from .timer import Timer
 
 log = logging.getLogger(__name__)
 
@@ -42,6 +46,11 @@ def run_one_task(taskname, **kwargs):
 
 
 def run_tasks(tasks, ctx):
+    archive_path = ctx.config.get('archive_path')
+    timer = Timer(
+        path=os.path.join(archive_path, 'timing.yaml'),
+        sync=True,
+    )
     stack = []
     try:
         for taskdict in tasks:
@@ -50,6 +59,7 @@ def run_tasks(tasks, ctx):
             except (ValueError, AttributeError):
                 raise RuntimeError('Invalid task definition: %s' % taskdict)
             log.info('Running task %s...', taskname)
+            timer.mark('%s enter' % taskname)
             manager = run_one_task(taskname, ctx=ctx, config=config)
             if hasattr(manager, '__enter__'):
                 stack.append((taskname, manager))
@@ -121,6 +131,7 @@ def run_tasks(tasks, ctx):
             while stack:
                 taskname, manager = stack.pop()
                 log.debug('Unwinding manager %s', taskname)
+                timer.mark('%s exit' % taskname)
                 try:
                     suppress = manager.__exit__(*exc_info)
                 except Exception as e:
@@ -155,3 +166,4 @@ def run_tasks(tasks, ctx):
         finally:
             # be careful about cyclic references
             del exc_info
+        timer.mark("tasks complete")