]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add (and use) try_push_job_info() for easy pushin'
authorZack Cerza <zack@cerza.org>
Fri, 4 Oct 2013 15:25:07 +0000 (10:25 -0500)
committerZack Cerza <zack@cerza.org>
Fri, 4 Oct 2013 16:07:33 +0000 (11:07 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/report.py
teuthology/run.py

index de0ff43c0abe6bda622445eb4b2207d7101e5035..b896ff10c1810a55710bd00104e559ff6b8646a8 100755 (executable)
@@ -327,7 +327,6 @@ def push_job_info(run_name, job_id, job_info, base_uri=None):
     :param job_info: A dict containing the job's information.
     :param base_uri: The endpoint of the results server. If you leave it out
                      ResultsReporter will ask teuthology.config.
-    :returns:         True if the run was successfully created.
     """
     # We are using archive_base='' here because we KNOW the serializer isn't
     # needed for this codepath.
@@ -336,6 +335,31 @@ def push_job_info(run_name, job_id, job_info, base_uri=None):
     reporter.report_job(run_name, job_id, job_json)
 
 
+def try_push_job_info(job_config, job_info=None):
+    """
+    Wrap push_job_info, gracefully doing nothing if:
+        A RequestFailedError is raised
+        config.results_server is not set
+
+    :param job_config: The ctx.config object
+    :param job_info:   Dict to push (commonly None)
+    """
+    if not config.results_server:
+        msg = "No results_server set in {yaml}; not attempting to push results"
+        log.debug(msg.format(yaml=config.teuthology_yaml))
+    else:
+        run_name = job_config['name']
+        job_id = job_config['job_id']
+        if job_info is None:
+            job_info = job_config
+
+        try:
+            push_job_info(run_name, job_id, job_info)
+        except RequestFailedError:
+            log.exception("Could not report results to %s" %
+                          config.results_server)
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Submit test results to a web service")
index 15f4de8de833696d4f74a6d2f1bac0d433e9a284..767e131e2918f284d721b2e81917c1e2f9cd496a 100644 (file)
@@ -155,7 +155,6 @@ def main():
     import logging
 
     from . import report
-    from .config import config as teuth_config
 
     ctx = parse_args()
     set_up_logging(ctx)
@@ -166,15 +165,7 @@ def main():
         ctx.owner = get_user()
 
     write_initial_metadata(ctx)
-    if teuth_config.results_server:
-        try:
-            run_name = ctx.config['name']
-            report.create_run(run_name)
-            report.push_job_info(run_name, ctx.config['job_id'], ctx.config)
-        except report.RequestFailedError:
-            log.exception("Could not report results to %s" %
-                          teuth_config.results_server)
-
+    report.try_push_job_info(ctx.config)
 
     if 'targets' in ctx.config and 'roles' in ctx.config:
         targets = len(ctx.config['targets'])
@@ -259,15 +250,9 @@ def main():
                 subject = "Teuthology error -- %s" % ctx.summary['failure_reason']
                 from teuthology.suite import email_results
                 email_results(subject,"Teuthology",ctx.config['email-on-error'],emsg)
-        if teuth_config.results_server:
-            try:
-                run_name = ctx.config['name']
-                job_id = ctx.config['name']
-                report.push_job_info(run_name, job_id, ctx.config)
-                report.push_job_info(run_name, job_id, ctx.summary)
-            except report.RequestFailedError:
-                log.exception("Could not report results to %s" %
-                            teuth_config.results_server)
+
+        report.try_push_job_info(ctx.config, ctx.summary)
+        report.try_push_job_info(ctx.config)
 
         if ctx.summary.get('success', True):
             log.info('pass')
@@ -276,6 +261,7 @@ def main():
             import sys
             sys.exit(1)
 
+
 def schedule():
     parser = argparse.ArgumentParser(description='Schedule ceph integration tests')
     parser.add_argument(