]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add dry-run option
authorZack Cerza <zack.cerza@inktank.com>
Tue, 11 Nov 2014 17:41:14 +0000 (10:41 -0700)
committerZack Cerza <zack.cerza@inktank.com>
Wed, 12 Nov 2014 18:00:40 +0000 (11:00 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
scripts/results.py
teuthology/results.py

index 73b417ab30d0f8ce105fa4a92f5b960a259be60b..7ff01e98ed62adc71a6fbbe455899a6610862e5f 100644 (file)
@@ -1,11 +1,12 @@
 """
-usage: teuthology-results [-h] [-v] [--email EMAIL] [--timeout TIMEOUT] --archive-dir DIR --name NAME
+usage: teuthology-results [-h] [-v] [--dry-run] [--email EMAIL] [--timeout TIMEOUT] --archive-dir DIR --name NAME
 
 Email teuthology suite results
 
 optional arguments:
   -h, --help         show this help message and exit
   -v, --verbose      be more verbose
+  --dry-run          Instead of sending the email, just print it
   --email EMAIL      address to email test failures to
   --timeout TIMEOUT  how many seconds to wait for all tests to finish (default
                      no wait)
index 20274f39475ea650d37e62af5d57fb5e672b24d7..7fd31c9df2350a45fdab29166cd67552117f9115 100644 (file)
@@ -23,18 +23,19 @@ def main(args):
     if args['--verbose']:
         teuthology.log.setLevel(logging.DEBUG)
 
-    log_path = os.path.join(args['--archive-dir'], 'results.log')
-    teuthology.setup_log_file(log_path)
+    if not args['--dry-run']:
+        log_path = os.path.join(args['--archive-dir'], 'results.log')
+        teuthology.setup_log_file(log_path)
 
     try:
         results(args['--archive-dir'], args['--name'], args['--email'],
-                args['--timeout'])
+                args['--timeout'], args['--dry-run'])
     except Exception:
         log.exception('error generating results')
         raise
 
 
-def results(archive_dir, name, email, timeout):
+def results(archive_dir, name, email, timeout, dry_run):
     archive_base = os.path.split(archive_dir)[0]
     serializer = ResultsSerializer(archive_base)
     starttime = time.time()
@@ -51,10 +52,15 @@ def results(archive_dir, name, email, timeout):
     (subject, body) = build_email_body(name, archive_dir)
 
     try:
-        if email:
+        if email and dry_run:
+            print "From: %s" % (config.results_sending_email or 'teuthology')
+            print "To: %s" % email
+            print "Subject: %s" % subject
+            print body
+        elif email:
             email_results(
                 subject=subject,
-                from_=config.results_sending_email or 'teuthology',
+                from_=(config.results_sending_email or 'teuthology'),
                 to=email,
                 body=body,
             )